diff options
author | Wim <wim@42.be> | 2020-10-21 20:35:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-21 20:35:22 +0200 |
commit | 1e0b4532bdb8a549e704918740601866e599c508 (patch) | |
tree | 4cbef6cf271e3572e8c673745e6c35818974dc1a /gateway/gateway.go | |
parent | 4f8b19c6866ae61c2ca36b7c9935669ee2089ef2 (diff) | |
download | matterbridge-msglm-1e0b4532bdb8a549e704918740601866e599c508.tar.gz matterbridge-msglm-1e0b4532bdb8a549e704918740601866e599c508.tar.bz2 matterbridge-msglm-1e0b4532bdb8a549e704918740601866e599c508.zip |
Show deprecate warnings about old tengo settings (#1271)
Diffstat (limited to 'gateway/gateway.go')
-rw-r--r-- | gateway/gateway.go | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/gateway/gateway.go b/gateway/gateway.go index 27265d15..7a5ca8c8 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -363,10 +363,23 @@ func (gw *Gateway) modifyAvatar(msg *config.Message, dest *bridge.Bridge) string } func (gw *Gateway) modifyMessage(msg *config.Message) { - if err := modifyMessageTengo(gw.BridgeValues().General.TengoModifyMessage, msg); err != nil { + if gw.BridgeValues().General.TengoModifyMessage != "" { + gw.logger.Warnf("General TengoModifyMessage=%s is deprecated and will be removed in v1.20.0, please move to Tengo InMessage=%s", gw.BridgeValues().General.TengoModifyMessage, gw.BridgeValues().General.TengoModifyMessage) + } + + if err := modifyInMessageTengo(gw.BridgeValues().General.TengoModifyMessage, msg); err != nil { gw.logger.Errorf("TengoModifyMessage failed: %s", err) } - if err := modifyMessageTengo(gw.BridgeValues().Tengo.Message, msg); err != nil { + + inMessage := gw.BridgeValues().Tengo.InMessage + if inMessage == "" { + inMessage = gw.BridgeValues().Tengo.Message + if inMessage != "" { + gw.logger.Warnf("Tengo Message=%s is deprecated and will be removed in v1.20.0, please move to Tengo InMessage=%s", inMessage, inMessage) + } + } + + if err := modifyInMessageTengo(inMessage, msg); err != nil { gw.logger.Errorf("Tengo.Message failed: %s", err) } @@ -443,7 +456,7 @@ func (gw *Gateway) SendMessage( msg.ParentID = "msg-parent-not-found" } - err := gw.modifySendMessageTengo(rmsg, &msg, dest) + err := gw.modifyOutMessageTengo(rmsg, &msg, dest) if err != nil { gw.logger.Errorf("modifySendMessageTengo: %s", err) } @@ -505,7 +518,7 @@ func getProtocol(msg *config.Message) string { return p[0] } -func modifyMessageTengo(filename string, msg *config.Message) error { +func modifyInMessageTengo(filename string, msg *config.Message) error { if filename == "" { return nil } @@ -564,7 +577,7 @@ func (gw *Gateway) modifyUsernameTengo(msg *config.Message, br *bridge.Bridge) ( return c.Get("result").String(), nil } -func (gw *Gateway) modifySendMessageTengo(origmsg *config.Message, msg *config.Message, br *bridge.Bridge) error { +func (gw *Gateway) modifyOutMessageTengo(origmsg *config.Message, msg *config.Message, br *bridge.Bridge) error { filename := gw.BridgeValues().Tengo.OutMessage var res []byte var err error |