mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-14 09:23:51 +01:00
Disallow sending status broadcast messages by default
Sending to big contact lists doesn't really work yet
This commit is contained in:
parent
0796d14133
commit
43d8fc5d2b
4 changed files with 22 additions and 1 deletions
|
@ -107,6 +107,7 @@ type BridgeConfig struct {
|
|||
FederateRooms bool `yaml:"federate_rooms"`
|
||||
URLPreviews bool `yaml:"url_previews"`
|
||||
|
||||
DisableStatusBroadcastSend bool `yaml:"disable_status_broadcast_send"`
|
||||
DisappearingMessagesInGroups bool `yaml:"disappearing_messages_in_groups"`
|
||||
|
||||
DisableBridgeAlerts bool `yaml:"disable_bridge_alerts"`
|
||||
|
|
|
@ -80,6 +80,7 @@ func DoUpgrade(helper *up.Helper) {
|
|||
helper.Copy(up.Str|up.Null, "bridge", "pinned_tag")
|
||||
helper.Copy(up.Bool, "bridge", "tag_only_on_create")
|
||||
helper.Copy(up.Bool, "bridge", "enable_status_broadcast")
|
||||
helper.Copy(up.Bool, "bridge", "disable_status_broadcast_send")
|
||||
helper.Copy(up.Bool, "bridge", "mute_status_broadcast")
|
||||
helper.Copy(up.Str|up.Null, "bridge", "status_broadcast_tag")
|
||||
helper.Copy(up.Bool, "bridge", "whatsapp_thumbnail")
|
||||
|
|
|
@ -249,6 +249,9 @@ bridge:
|
|||
# Should WhatsApp status messages be bridged into a Matrix room?
|
||||
# Disabling this won't affect already created status broadcast rooms.
|
||||
enable_status_broadcast: true
|
||||
# Should sending WhatsApp status messages be allowed?
|
||||
# This can cause issues if the user has lots of contacts, so it's disabled by default.
|
||||
disable_status_broadcast_send: true
|
||||
# Should the status broadcast room be muted and moved into low priority by default?
|
||||
# This is only applied when creating the room, the user can unmute it later.
|
||||
mute_status_broadcast: true
|
||||
|
|
18
portal.go
18
portal.go
|
@ -2907,6 +2907,9 @@ var (
|
|||
errTargetIsFake = errors.New("target is a fake event")
|
||||
errTargetSentBySomeoneElse = errors.New("target is a fake event")
|
||||
|
||||
errBroadcastReactionNotSupported = errors.New("reacting to status messages is not currently supported")
|
||||
errBroadcastSendDisabled = errors.New("sending status messages is disabled")
|
||||
|
||||
errMessageDisconnected = &whatsmeow.DisconnectedError{Action: "message send"}
|
||||
errMessageRetryDisconnected = &whatsmeow.DisconnectedError{Action: "message send (retry)"}
|
||||
)
|
||||
|
@ -2918,7 +2921,9 @@ func errorToStatusReason(err error) (reason event.MessageStatusReason, isCertain
|
|||
errors.Is(err, errUnknownMsgType),
|
||||
errors.Is(err, errInvalidGeoURI),
|
||||
errors.Is(err, whatsmeow.ErrUnknownServer),
|
||||
errors.Is(err, whatsmeow.ErrRecipientADJID):
|
||||
errors.Is(err, whatsmeow.ErrRecipientADJID),
|
||||
errors.Is(err, errBroadcastReactionNotSupported),
|
||||
errors.Is(err, errBroadcastSendDisabled):
|
||||
return event.MessageStatusUnsupported, true, false, true
|
||||
case errors.Is(err, errTargetNotFound),
|
||||
errors.Is(err, errTargetIsFake),
|
||||
|
@ -3033,6 +3038,9 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event) {
|
|||
if err := portal.canBridgeFrom(sender, true); err != nil {
|
||||
go portal.sendMessageMetrics(evt, err, "Ignoring")
|
||||
return
|
||||
} else if portal.Key.JID == types.StatusBroadcastJID && portal.bridge.Config.Bridge.DisableStatusBroadcastSend {
|
||||
go portal.sendMessageMetrics(evt, errBroadcastSendDisabled, "Ignoring")
|
||||
return
|
||||
}
|
||||
portal.log.Debugfln("Received message %s from %s", evt.ID, evt.Sender)
|
||||
msg, sender, err := portal.convertMatrixMessage(sender, evt)
|
||||
|
@ -3055,6 +3063,11 @@ func (portal *Portal) HandleMatrixReaction(sender *User, evt *event.Event) {
|
|||
if err := portal.canBridgeFrom(sender, false); err != nil {
|
||||
go portal.sendMessageMetrics(evt, err, "Ignoring")
|
||||
return
|
||||
} else if portal.Key.JID.Server == types.BroadcastServer {
|
||||
// TODO implement this, probably by only sending the reaction to the sender of the status message?
|
||||
// (whatsapp hasn't published the feature yet)
|
||||
go portal.sendMessageMetrics(evt, errBroadcastReactionNotSupported, "Ignoring")
|
||||
return
|
||||
}
|
||||
|
||||
content, ok := evt.Content.Parsed.(*event.ReactionEventContent)
|
||||
|
@ -3162,6 +3175,9 @@ func (portal *Portal) HandleMatrixRedaction(sender *User, evt *event.Event) {
|
|||
go portal.sendMessageMetrics(evt, errTargetIsFake, "Ignoring")
|
||||
} else if msg.Sender.User != sender.JID.User {
|
||||
go portal.sendMessageMetrics(evt, errTargetSentBySomeoneElse, "Ignoring")
|
||||
} else if portal.Key.JID == types.StatusBroadcastJID && portal.bridge.Config.Bridge.DisableStatusBroadcastSend {
|
||||
go portal.sendMessageMetrics(evt, errBroadcastSendDisabled, "Ignoring")
|
||||
return
|
||||
} else if msg.Type == database.MsgReaction {
|
||||
if reaction := portal.bridge.DB.Reaction.GetByMXID(evt.Redacts); reaction == nil {
|
||||
go portal.sendMessageMetrics(evt, errReactionDatabaseNotFound, "Ignoring")
|
||||
|
|
Loading…
Reference in a new issue