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: delete asset file when removing self-deleting msg [WPB-1807] #3027

Merged

Conversation

saleniuk
Copy link
Contributor

@saleniuk saleniuk commented Sep 24, 2024

StoryWPB-1807 Self-deleting: Delete assets from internal storage once the timer runs out


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

Asset file is not removed from the storage once the self-deleting asset message timer runs out.

Causes (Optional)

Wrong order of actions:

  • the message is marked as deleted, which means that the content is cleared in db
  • attempt to send "deleted" messages
  • remove message completely from the db
  • try to remove the asset from the db and its file from the storage - at this point, because of the first step, the content of the message is already empty so the app doesn't know the id of the asset to remove and no file is being removed. Also, the app tries to remove the asset remotely by making a request which ends up with 403 error, probably because this asset belongs to someone other.

Solutions

Change the order of actions, so that now it will look like this:

  • get the content of the message
  • mark the message as deleted and clear the content from the db
  • use the retrieved content data from first step to remove asset, but only locally, together with deleting associated file from the storage
  • attempt to send "deleted" messages
  • remove message completely from the db
    Thanks to that, the asset file and asset data will be removed from the asset table right when the content of the message is being cleared and marked as deleted. Asset is being removed only locally, there's no need to make a request that will probably fail.
    Also, selectPendingEphemeralMessages is fixed to return only real pending messages, so messages that has yet not started (messages without end time) should be filtered out, to make sure that only messages that has been shown to the user are enqueued.

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Send a self-deleting message with asset, wait until that message disappears and check if "used storage" has changed.

Attachments (Optional)

Before After
self-deleting-remove-asset-before.mov
self-deleting-remove-asset-after.mov

PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@echoes-hq echoes-hq bot added the echoes: product-roadmap Work aligned with the customer-announced roadmap, targeting a specific release date. label Sep 24, 2024
Copy link

Copy link
Contributor

github-actions bot commented Sep 24, 2024

Test Results

3 196 tests  +1   3 089 ✔️ +1   3m 46s ⏱️ -10s
   548 suites ±0      107 💤 ±0 
   548 files   ±0          0 ±0 

Results for commit 2df0159. ± Comparison against base commit ed2bd50.

♻️ This comment has been updated with latest results.

@datadog-wireapp
Copy link

Datadog Report

Branch report: fix/delete-asset-when-removing-selfdeleting-msg
Commit report: 1ba2dae
Test service: kalium-jvm

✅ 0 Failed, 3089 Passed, 107 Skipped, 12.24s Total Time

@saleniuk saleniuk requested review from a team, typfel, yamilmedina, alexandreferris, Garzas and ohassine and removed request for a team September 25, 2024 07:03
Copy link
Member

@vitorhugods vitorhugods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done 💅

@saleniuk saleniuk added this pull request to the merge queue Sep 25, 2024
Merged via the queue into release/candidate with commit 112b901 Sep 25, 2024
23 checks passed
@saleniuk saleniuk deleted the fix/delete-asset-when-removing-selfdeleting-msg branch September 25, 2024 10:16
github-merge-queue bot pushed a commit that referenced this pull request Sep 25, 2024
…3034)

* fix: delete asset file when removing self-deleting msg [WPB-1807] (#3027)

* trigger build

---------

Co-authored-by: Michał Saleniuk <[email protected]>
Co-authored-by: Michał Saleniuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: product-roadmap Work aligned with the customer-announced roadmap, targeting a specific release date. 🚨 Potential breaking changes 👕 size: M type: bug / fix 🐞
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants