diff --git a/messagetracking.go b/messagetracking.go index d53ee18..c13a6b9 100644 --- a/messagetracking.go +++ b/messagetracking.go @@ -46,6 +46,9 @@ var ( errMediaDecryptFailed = errors.New("failed to decrypt media") errMediaReuploadFailed = errors.New("failed to upload media to google") + errIncorrectUser = errors.New("incorrect user") + errNotLoggedIn = errors.New("not logged in") + errMessageTakingLong = errors.New("bridging the message is taking longer than usual") ) @@ -84,6 +87,8 @@ func errorToStatusReason(err error) (reason event.MessageStatusReason, status ev case errors.Is(err, errUnexpectedParsedContentType), errors.Is(err, errUnknownMsgType): return event.MessageStatusUnsupported, event.MessageStatusFail, true, true, "" + case errors.Is(err, errIncorrectUser), errors.Is(err, errNotLoggedIn): + return event.MessageStatusUnsupported, event.MessageStatusFail, true, true, err.Error() case errors.Is(err, errMNoticeDisabled): return event.MessageStatusUnsupported, event.MessageStatusFail, true, false, "" case errors.Is(err, errMediaUnsupportedType): diff --git a/portal.go b/portal.go index 3df8f26..02f4f86 100644 --- a/portal.go +++ b/portal.go @@ -312,6 +312,13 @@ func (portal *Portal) handleMessageLoopItem(msg PortalMessage) { } func (portal *Portal) handleMatrixMessageLoopItem(msg PortalMatrixMessage) { + if msg.user.RowID != portal.Receiver { + go portal.sendMessageMetrics(msg.user, msg.evt, errIncorrectUser, "Ignoring", nil) + return + } else if msg.user.Client == nil { + go portal.sendMessageMetrics(msg.user, msg.evt, errNotLoggedIn, "Ignoring", nil) + return + } portal.forwardBackfillLock.Lock() defer portal.forwardBackfillLock.Unlock() evtTS := time.UnixMilli(msg.evt.Timestamp)