Simplify reaction error notices

This commit is contained in:
Tulir Asokan 2021-11-09 15:17:23 +02:00
parent b652281682
commit 445da09e1d
4 changed files with 8 additions and 25 deletions

View file

@ -68,6 +68,7 @@ func (helper *UpgradeHelper) doUpgrade() {
helper.Copy(Bool, "bridge", "delivery_receipts")
helper.Copy(Int, "bridge", "portal_message_buffer")
helper.Copy(Bool, "bridge", "call_start_notices")
helper.Copy(Bool, "bridge", "reaction_notices")
helper.Copy(Bool, "bridge", "history_sync", "create_portals")
helper.Copy(Int, "bridge", "history_sync", "max_age")
helper.Copy(Bool, "bridge", "history_sync", "backfill")

View file

@ -92,7 +92,7 @@ bridge:
delivery_receipts: false
# Should incoming calls send a message to the Matrix room?
call_start_notices: true
# Since WhatsApp does not support reactions, should a warning notice be sent to the Matrix room when a user reacts to a message?
# Should a "reactions not yet supported" warning be sent to the Matrix room when a user reacts to a message?
reaction_notices: true
portal_message_buffer: 128

View file

@ -436,13 +436,16 @@ func (mx *MatrixHandler) HandleReaction(evt *event.Event) {
}
user := mx.bridge.GetUserByMXID(evt.Sender)
if user == nil {
if user == nil || !user.RelayWhitelisted {
return
}
portal := mx.bridge.GetPortalByMXID(evt.RoomID)
if portal != nil && (user.Whitelisted || portal.HasRelaybot()) {
portal.HandleMatrixReaction(user, evt)
if portal != nil && (user.Whitelisted || portal.HasRelaybot()) && mx.bridge.Config.Bridge.ReactionNotices {
_, _ = portal.sendMainIntentMessage(&event.MessageEventContent{
MsgType: event.MsgNotice,
Body: fmt.Sprintf("\u26a0 Reactions are not yet supported by WhatsApp."),
})
}
}

View file

@ -2113,27 +2113,6 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event) {
}
}
func (portal *Portal) HandleMatrixReaction(sender *User, evt *event.Event) {
if !portal.canBridgeFrom(sender, "message") {
return
}
portal.log.Debugfln("Received reaction event %s from %s", evt.ID, evt.Sender)
if evt.Type.Type != event.EventReaction.Type {
portal.log.Warnfln("Reaction event is not of Reaction type: %s", evt.Type.Type)
}
if portal.bridge.Config.Bridge.ReactionNotices {
_, err := portal.sendMainIntentMessage(&event.MessageEventContent{
MsgType: event.MsgNotice,
Body: fmt.Sprintf("\u26a0 Reactions are not supported by WhatsApp."),
})
if err != nil {
portal.log.Warnfln("Failed to send reaction notice message:", err)
}
}
}
func (portal *Portal) HandleMatrixRedaction(sender *User, evt *event.Event) {
if !portal.canBridgeFrom(sender, "redaction") {
return