Don't panic on Matrix message when user isn't logged in
This commit is contained in:
parent
15015f280e
commit
1b7f876b44
2 changed files with 12 additions and 0 deletions
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue