Don't bridge auto-downloading messages

This commit is contained in:
Tulir Asokan 2023-08-13 17:10:37 +03:00
parent 8adad5ea1b
commit 3f417ba719

View file

@ -534,10 +534,15 @@ func (portal *Portal) handleMessage(source *User, evt *gmproto.Message) {
if portal.handleExistingMessage(ctx, source, evt, false) { if portal.handleExistingMessage(ctx, source, evt, false) {
return return
} }
if evt.GetMessageStatus().GetStatus() == gmproto.MessageStatusType_MESSAGE_DELETED { switch evt.GetMessageStatus().GetStatus() {
case gmproto.MessageStatusType_MESSAGE_DELETED:
log.Debug().Msg("Not handling unknown deleted message") log.Debug().Msg("Not handling unknown deleted message")
return return
} else if eventTS.Add(24 * time.Hour).Before(time.Now()) { case gmproto.MessageStatusType_INCOMING_AUTO_DOWNLOADING, gmproto.MessageStatusType_INCOMING_RETRYING_AUTO_DOWNLOAD:
log.Debug().Msg("Not handling incoming auto-downloading MMS")
return
}
if eventTS.Add(24 * time.Hour).Before(time.Now()) {
lastMessage, err := portal.bridge.DB.Message.GetLastInChat(ctx, portal.Key) lastMessage, err := portal.bridge.DB.Message.GetLastInChat(ctx, portal.Key)
if err != nil { if err != nil {
log.Warn().Err(err).Msg("Failed to get last message to check if received old message is too old") log.Warn().Err(err).Msg("Failed to get last message to check if received old message is too old")
@ -820,7 +825,7 @@ func (portal *Portal) convertGoogleMessage(ctx context.Context, source *User, ev
} }
if downloadStatus != "" { if downloadStatus != "" {
content := event.MessageEventContent{ content := event.MessageEventContent{
MsgType: event.MsgText, MsgType: event.MsgNotice,
Body: downloadStatus, Body: downloadStatus,
} }
if subject != "" { if subject != "" {
@ -1614,6 +1619,7 @@ func (portal *Portal) HandleMatrixMessage(sender *User, evt *event.Event, timing
go ms.sendMessageMetrics(evt, err, "Error converting", true) go ms.sendMessageMetrics(evt, err, "Error converting", true)
return return
} }
log.Debug().Str("tmp_id", req.TmpID).Msg("Sending Matrix message to Google Messages")
start = time.Now() start = time.Now()
_, err = sender.Client.SendMessage(req) _, err = sender.Client.SendMessage(req)
timings.send = time.Since(start) timings.send = time.Since(start)