Send presence when typing changes

This commit is contained in:
abmantis 2022-01-01 02:29:39 +00:00
parent e60d5351a5
commit 50a6e383e7
4 changed files with 12 additions and 0 deletions

View file

@ -54,6 +54,7 @@ type BridgeConfig struct {
SyncDirectChatList bool `yaml:"sync_direct_chat_list"`
DefaultBridgeReceipts bool `yaml:"default_bridge_receipts"`
DefaultBridgePresence bool `yaml:"default_bridge_presence"`
SendPresenceOnTyping bool `yaml:"send_presence_on_typing"`
ForceActiveDeliveryReceipts bool `yaml:"force_active_delivery_receipts"`

View file

@ -82,6 +82,7 @@ func (helper *UpgradeHelper) doUpgrade() {
helper.Copy(Bool, "bridge", "sync_direct_chat_list")
helper.Copy(Bool, "bridge", "default_bridge_receipts")
helper.Copy(Bool, "bridge", "default_bridge_presence")
helper.Copy(Bool, "bridge", "send_presence_on_typing")
helper.Copy(Bool, "bridge", "force_active_delivery_receipts")
helper.Copy(Map, "bridge", "double_puppet_server_map")
helper.Copy(Bool, "bridge", "double_puppet_allow_discovery")

View file

@ -147,6 +147,10 @@ bridge:
# Existing users won't be affected when these are changed.
default_bridge_receipts: true
default_bridge_presence: true
# Send the presence as "available" to whatsapp when users start typing on a portal.
# This works as a workaround for homeservers that do not support presence, and allows
# users to see when the whatsapp user on the other side is typing during a conversation.
send_presence_on_typing: false
# Should the bridge always send "active" delivery receipts (two gray ticks on WhatsApp)
# even if the user isn't marked as online (e.g. when presence bridging isn't enabled)?
#

View file

@ -2815,6 +2815,12 @@ func (portal *Portal) setTyping(userIDs []id.UserID, state types.ChatPresence) {
if err != nil {
portal.log.Warnln("Error sending chat presence:", err)
}
if portal.bridge.Config.Bridge.SendPresenceOnTyping {
err = user.Client.SendPresence(types.PresenceAvailable)
if err != nil {
user.log.Warnln("Failed to set presence:", err)
}
}
}
}