summaryrefslogtreecommitdiffstats
path: root/gateway/handlers.go
diff options
context:
space:
mode:
authorDuco van Amstel <helcaraxan@gmail.com>2019-05-30 14:00:40 +0100
committerWim <wim@42.be>2019-05-30 15:00:40 +0200
commitb79bf7d4143f7a962faa00e10c2d6705524607ee (patch)
tree2a0bab3b6c04a94d9d1497b7c974a1aebfdd4867 /gateway/handlers.go
parent3724cc3a15c76a0a0dd1cac15736aebb0410d8ca (diff)
downloadmatterbridge-msglm-b79bf7d4143f7a962faa00e10c2d6705524607ee.tar.gz
matterbridge-msglm-b79bf7d4143f7a962faa00e10c2d6705524607ee.tar.bz2
matterbridge-msglm-b79bf7d4143f7a962faa00e10c2d6705524607ee.zip
Forward only user-typing messages if supported by protocol (#832)
Fixes issue #814. This is a somewhat hacky way of achieving the required goal but it seems like this is the least problematic way of getting there. We might want to redesign some bridge information later such that we have a standardised way of specifying what is and what isn't supported by each chat protocol / bridge.
Diffstat (limited to 'gateway/handlers.go')
-rw-r--r--gateway/handlers.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/gateway/handlers.go b/gateway/handlers.go
index 74bf4334..26d3f189 100644
--- a/gateway/handlers.go
+++ b/gateway/handlers.go
@@ -14,6 +14,7 @@ import (
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
+ "github.com/42wim/matterbridge/gateway/bridgemap"
)
// handleEventFailure handles failures and reconnects bridges.
@@ -190,6 +191,14 @@ func (gw *Gateway) ignoreEvent(event string, dest *bridge.Bridge) bool {
func (gw *Gateway) handleMessage(rmsg *config.Message, dest *bridge.Bridge) []*BrMsgID {
var brMsgIDs []*BrMsgID
+ // Not all bridges support "user is typing" indications so skip the message
+ // if the targeted bridge does not support it.
+ if rmsg.Event == config.EventUserTyping {
+ if _, ok := bridgemap.UserTypingSupport[dest.Protocol]; !ok {
+ return nil
+ }
+ }
+
// if we have an attached file, or other info
if rmsg.Extra != nil && len(rmsg.Extra[config.EventFileFailureSize]) != 0 && rmsg.Text == "" {
return brMsgIDs