From 0e52308a255fe59cdebee53757a9454367b76db2 Mon Sep 17 00:00:00 2001 From: zhaoYangguang <1163765691@qq.com> Date: Thu, 2 Jun 2022 18:46:48 +0800 Subject: [PATCH] add config item for sync contact --- config/bridge.go | 2 ++ example-config.yaml | 3 +++ user.go | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config/bridge.go b/config/bridge.go index 06e0029..1ae7842 100644 --- a/config/bridge.go +++ b/config/bridge.go @@ -40,6 +40,7 @@ type BridgeConfig struct { RecoverChatSync int `yaml:"recovery_chat_sync_count"` RecoverHistory bool `yaml:"recovery_history_backfill"` SyncChatMaxAge uint64 `yaml:"sync_max_chat_age"` + SyncContact bool `yaml:"sync_contact"` SyncWithCustomPuppets bool `yaml:"sync_with_custom_puppets"` @@ -101,6 +102,7 @@ func (bc *BridgeConfig) setDefaults() { bc.RecoverChatSync = -1 bc.RecoverHistory = true bc.SyncChatMaxAge = 259200 + bc.SyncContact = false bc.SyncWithCustomPuppets = true diff --git a/example-config.yaml b/example-config.yaml index 47efdff..432eb78 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -126,6 +126,9 @@ bridge: # Default is 3 days = 259200 seconds sync_max_chat_age: 259200 + # sync contact, Non-martix-standard parameter, defaults to false + sync_contact: false + # Whether or not to sync with custom puppets to receive EDUs that # are not normally sent to appservices. sync_with_custom_puppets: true diff --git a/user.go b/user.go index bce9f16..3eb7650 100644 --- a/user.go +++ b/user.go @@ -630,9 +630,11 @@ func (user *User) syncPuppets(contacts map[string]skype.Contact, toHomeserver bo matrixContacts = append(matrixContacts, string(puppet.MXID)) } } - customPuppet := user.bridge.GetPuppetByCustomMXID(user.MXID) - if customPuppet != nil && customPuppet.CustomIntent() != nil { - customPuppet.SetMatrixContacts(matrixContacts) + if user.bridge.Config.Bridge.SyncContact { + customPuppet := user.bridge.GetPuppetByCustomMXID(user.MXID) + if customPuppet != nil && customPuppet.CustomIntent() != nil { + customPuppet.SetMatrixContacts(matrixContacts) + } } user.log.Infoln("Finished syncing puppet info from contacts") }