Ignore link preview tombstones in groups as well

This commit is contained in:
Tulir Asokan 2023-08-21 11:09:36 +03:00
parent 667613f0c5
commit 16b1f5d0c9

View file

@ -791,7 +791,7 @@ func addDownloadStatus(content *event.MessageEventContent, status string) {
} }
} }
func shouldIgnoreStatus(status gmproto.MessageStatusType) bool { func (portal *Portal) shouldIgnoreStatus(status gmproto.MessageStatusType) bool {
switch status { switch status {
case gmproto.MessageStatusType_TOMBSTONE_PROTOCOL_SWITCH_TO_TEXT, case gmproto.MessageStatusType_TOMBSTONE_PROTOCOL_SWITCH_TO_TEXT,
gmproto.MessageStatusType_TOMBSTONE_PROTOCOL_SWITCH_TO_RCS, gmproto.MessageStatusType_TOMBSTONE_PROTOCOL_SWITCH_TO_RCS,
@ -800,8 +800,9 @@ func shouldIgnoreStatus(status gmproto.MessageStatusType) bool {
gmproto.MessageStatusType_MESSAGE_STATUS_TOMBSTONE_PROTOCOL_SWITCH_TEXT_TO_E2EE, gmproto.MessageStatusType_MESSAGE_STATUS_TOMBSTONE_PROTOCOL_SWITCH_TEXT_TO_E2EE,
gmproto.MessageStatusType_MESSAGE_STATUS_TOMBSTONE_PROTOCOL_SWITCH_E2EE_TO_TEXT, gmproto.MessageStatusType_MESSAGE_STATUS_TOMBSTONE_PROTOCOL_SWITCH_E2EE_TO_TEXT,
gmproto.MessageStatusType_MESSAGE_STATUS_TOMBSTONE_PROTOCOL_SWITCH_RCS_TO_E2EE, gmproto.MessageStatusType_MESSAGE_STATUS_TOMBSTONE_PROTOCOL_SWITCH_RCS_TO_E2EE,
gmproto.MessageStatusType_MESSAGE_STATUS_TOMBSTONE_PROTOCOL_SWITCH_E2EE_TO_RCS, gmproto.MessageStatusType_MESSAGE_STATUS_TOMBSTONE_PROTOCOL_SWITCH_E2EE_TO_RCS:
gmproto.MessageStatusType_TOMBSTONE_SHOW_LINK_PREVIEWS: return portal.IsPrivateChat()
case gmproto.MessageStatusType_TOMBSTONE_SHOW_LINK_PREVIEWS:
return true return true
default: default:
return false return false
@ -817,7 +818,7 @@ func (portal *Portal) convertGoogleMessage(ctx context.Context, source *User, ev
cm.ID = evt.MessageID cm.ID = evt.MessageID
cm.PartCount = len(evt.GetMessageInfo()) cm.PartCount = len(evt.GetMessageInfo())
cm.Timestamp = time.UnixMicro(evt.Timestamp) cm.Timestamp = time.UnixMicro(evt.Timestamp)
cm.DontBridge = portal.IsPrivateChat() && shouldIgnoreStatus(cm.Status) cm.DontBridge = portal.shouldIgnoreStatus(cm.Status)
if cm.Status >= 200 && cm.Status < 300 { if cm.Status >= 200 && cm.Status < 300 {
cm.Intent = portal.bridge.Bot cm.Intent = portal.bridge.Bot
if !portal.Encrypted && portal.IsPrivateChat() { if !portal.Encrypted && portal.IsPrivateChat() {