-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Do not show failed messages as delivered #15816
Conversation
const errorStatus = | ||
isBackendError(error) && error.label === BackendErrorLabel.FEDERATION_REMOTE_ERROR | ||
? StatusType.FEDERATION_ERROR | ||
: StatusType.FAILED; | ||
messageEntity.status(errorStatus); | ||
return this.eventService.updateEvent(messageEntity.primary_key, {status: errorStatus}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a small refactoring to avoid code duplication
return this.messages() | ||
.slice() | ||
.reverse() | ||
.find(messageEntity => { | ||
const isDelivered = messageEntity.status() >= StatusType.DELIVERED; | ||
const isDelivered = [StatusType.DELIVERED, StatusType.SEEN].includes(messageEntity.status()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix.
For more explanation, here is what the enum looks like
export enum StatusType {
DELIVERED = 3,
FAILED = 0,
FEDERATION_ERROR = 5,
SEEN = 4,
SENDING = 1,
SENT = 2,
UNSPECIFIED = -1,
}
as you can see FEDERATION_ERROR
has a higher value than DELIVERED
and thus caused the bug
Codecov Report
@@ Coverage Diff @@
## dev #15816 +/- ##
=======================================
Coverage 44.48% 44.49%
=======================================
Files 673 673
Lines 22713 22711 -2
Branches 5166 5166
=======================================
Hits 10105 10105
+ Misses 11320 11318 -2
Partials 1288 1288 |
Description
We used to have a check that was to permissive to know if a message is delivered.
Now that we have errors in the
StatusType
enum that have a value higher thanStatusType.DELIVERED
we need to be explicit about the status that could be considereddelivered
.Screenshots/Screencast (for UI changes)
Before
After
Checklist