浏览代码

Add option to disable call start/end notifications. Fixes #68

Tulir Asokan 5 年之前
父节点
当前提交
80a0edd855
共有 3 个文件被更改,包括 22 次插入0 次删除
  1. 8 0
      config/bridge.go
  2. 5 0
      example-config.yaml
  3. 9 0
      user.go

+ 8 - 0
config/bridge.go

@@ -41,6 +41,11 @@ type BridgeConfig struct {
 	ReportConnectionRetry bool `yaml:"report_connection_retry"`
 	ContactWaitDelay      int  `yaml:"contact_wait_delay"`
 
+	CallNotices struct {
+		Start bool `yaml:"start"`
+		End   bool `yaml:"end"`
+	} `yaml:"call_notices"`
+
 	InitialChatSync    int    `yaml:"initial_chat_sync_count"`
 	InitialHistoryFill int    `yaml:"initial_history_fill_count"`
 	RecoverChatSync    int    `yaml:"recovery_chat_sync_count"`
@@ -71,6 +76,9 @@ func (bc *BridgeConfig) setDefaults() {
 	bc.ReportConnectionRetry = true
 	bc.ContactWaitDelay = 1
 
+	bc.CallNotices.Start = true
+	bc.CallNotices.End = true
+
 	bc.InitialChatSync = 10
 	bc.InitialHistoryFill = 20
 	bc.RecoverChatSync = -1

+ 5 - 0
example-config.yaml

@@ -79,6 +79,11 @@ bridge:
     # If you have lots of chats, it might take more than a second.
     contact_wait_delay: 1
 
+    # Whether or not to send call start/end notices to Matrix.
+    call_notices:
+        start: true
+        end: true
+
     # Number of chats to sync for new users.
     initial_chat_sync_count: 10
     # Number of old messages to fill when creating new portal rooms.

+ 9 - 0
user.go

@@ -578,10 +578,19 @@ func (user *User) HandleCallInfo(info whatsappExt.CallInfo) {
 	}
 	switch info.Type {
 	case whatsappExt.CallOffer:
+		if !user.bridge.Config.Bridge.CallNotices.Start {
+			return
+		}
 		data.Text = "Incoming call"
 	case whatsappExt.CallOfferVideo:
+		if !user.bridge.Config.Bridge.CallNotices.Start {
+			return
+		}
 		data.Text = "Incoming video call"
 	case whatsappExt.CallTerminate:
+		if !user.bridge.Config.Bridge.CallNotices.End {
+			return
+		}
 		data.Text = "Call ended"
 		data.ID += "E"
 	default: