Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send presence when typing changes #452

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions config/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
1 change: 1 addition & 0 deletions config/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)?
#
Expand Down
6 changes: 6 additions & 0 deletions portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}

Expand Down