Skip to content
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

Merged
merged 2 commits into from
Sep 14, 2023
Merged

fix: Do not show failed messages as delivered #15816

merged 2 commits into from
Sep 14, 2023

Conversation

atomrc
Copy link
Contributor

@atomrc atomrc commented Sep 14, 2023

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 than StatusType.DELIVERED we need to be explicit about the status that could be considered delivered.

Screenshots/Screencast (for UI changes)

Before

image

After

image

Checklist

  • PR has been self reviewed by the author;
  • Hard-to-understand areas of the code have been commented;
  • If it is a core feature, unit tests have been added;

@atomrc atomrc requested review from otto-the-bot and a team as code owners September 14, 2023 09:59
Comment on lines +1218 to +1223
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});
Copy link
Contributor Author

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());
Copy link
Contributor Author

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
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

Merging #15816 (eada2a2) into dev (866a1f2) will increase coverage by 0.00%.
Report is 1 commits behind head on dev.
The diff coverage is 25.00%.

@@           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           

@atomrc atomrc merged commit 0a76863 into dev Sep 14, 2023
13 checks passed
@atomrc atomrc deleted the fix/last-delivered branch September 14, 2023 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants