Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

[NEW] Sync deleted messages #2617

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

luismachado
Copy link
Contributor

Checks for deleted messages every time messages are fetched (direct messages)

For now I've only implemented it for direct messages (and it's lacking optimisation), but would this be a viable way to sync (i.e. remove from the device) deleted messages?

@RocketChat/ios

Closes #2208

let roomId: String?
let since: Date?

// How to improve this default date? We only want deleted messages as far as the older message we have on cache! (older ones won't be returned)

Choose a reason for hiding this comment

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

Line Length Violation: Line should be 120 characters or less: currently 147 characters (line_length)


private func loadDeletedMessages(subscription: Subscription, completion: (([String]) -> Void)? = nil) {

// TODO: Save latest date? Older messages may have been deleted so we probably should always check up to the oldest

Choose a reason for hiding this comment

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

Line Length Violation: Line should be 120 characters or less: currently 123 characters (line_length)
Todo Violation: TODOs should be resolved (Save latest date? Older messag...). (todo)

@CLAassistant
Copy link

CLAassistant commented Mar 29, 2019

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov
Copy link

codecov bot commented Mar 29, 2019

Codecov Report

Merging #2617 into develop will increase coverage by 0.16%.
The diff coverage is 66.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2617      +/-   ##
===========================================
+ Coverage    26.15%   26.32%   +0.16%     
===========================================
  Files          463      464       +1     
  Lines        17216    17252      +36     
===========================================
+ Hits          4503     4541      +38     
+ Misses       12713    12711       -2
Impacted Files Coverage Δ
...API/Requests/Room/RoomDeletedMessagesRequest.swift 55% <55%> (ø)
Rocket.Chat/API/Clients/SubscriptionsClient.swift 67.14% <77.27%> (+0.13%) ⬆️
...anagers/Model/AuthManager/AuthManagerRecover.swift 36.36% <0%> (-60.61%) ⬇️
Rocket.Chat/Extensions/Models/AuthExtensions.swift 66.66% <0%> (-33.34%) ⬇️
...Chat/Models/Subscription/SubscriptionQueries.swift 70% <0%> (-30%) ⬇️
Rocket.Chat/Managers/PushManager.swift 24.13% <0%> (-10.35%) ⬇️
Rocket.Chat/Managers/AppManager.swift 36.04% <0%> (-4.07%) ⬇️
Rocket.Chat/API/APIRequest.swift 97.29% <0%> (+2.7%) ⬆️
...Chat/Controllers/Chat/MessagesViewController.swift 34.25% <0%> (+2.75%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecad166...c4d7b22. Read the comment docs.

@rafaelks
Copy link
Contributor

@luismachado Amazing, thanks for the PR! Gonna review it for release 3.5, we're wrapping up 3.4 right now. 👏

@rafaelks rafaelks self-assigned this Mar 29, 2019
@rafaelks rafaelks self-requested a review March 29, 2019 13:33
@rafaelks rafaelks added this to the 3.5.0 milestone Mar 29, 2019
@rafaelks rafaelks changed the title Sync deleted messages [NEW] Sync deleted messages Mar 29, 2019
@rafaelks
Copy link
Contributor

rafaelks commented Apr 2, 2019

@luismachado This PR is missing your signature of CLA, could you do that please?

Copy link
Contributor

@rafaelks rafaelks left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @luismachado, most of it looks very good, but the way you're doing the request is not the way it should be based on the API. Here's how it should work:

Every time the user opens a subscription, we need to request the latest deleted messages based on the last time we requested them, so for example: if we requested them on time 1000, next time we'll pass 1000 as since parameter. If now the time is 2000, we will update the 1000 value to 2000 for the next request (next time user opens the subscription). Got it?

  1. We don't need to request it every time we request the history of messages;
  2. It needs to have a since parameter valid, not 0. This will prevent us from downloading very old data from the server.

Let me know if that makes sense to you please.

Thank you!

@luismachado
Copy link
Contributor Author

Hello @rafaelks,

I do understand what you're saying (and the fix definitely needs some improvements) but I'm not sure I would 100% agree with you (or maybe I didn't understand you fully :P).

  • What I was thinking would be to grab the oldest message timestamp (I think this is already done) and then use that timestamp to fetch the deleted list.
  • I'm not sure that we can avoid fetching deleted info that was already fetched because the users can delete any message, old or new, so we have to make sure that we always have the most recent info on deleted messages for the our current scope (i.e. the messages we have on cache).

We don't need to request it every time we request the history of messages
In which situations could we avoid it? Maybe we could only call the endpoint for the first time the history is requested (i.e, when the messages controller is opened). I'm thinking this because (and please correct me if I'm wrong) if a (unfetched) message was deleted in the meanwhile it won't be returned by the api.

@rafaelks
Copy link
Contributor

rafaelks commented Apr 3, 2019

What I was thinking would be to grab the oldest message timestamp (I think this is already done) and then use that timestamp to fetch the deleted list.

I'm not sure that we can avoid fetching deleted info that was already fetched because the users can delete any message, old or new, so we have to make sure that we always have the most recent info on deleted messages for the our current scope (i.e. the messages we have on cache).

AFAIK the date you pass as a parameter is not the date of the message, but the date that the "updates" happen, so if a message from 5 days ago was deleted today and you fetch the API with the "since" from today, you will get the deleted message information, you know?

@luismachado
Copy link
Contributor Author

luismachado commented Apr 3, 2019 via email

@rafaelks rafaelks modified the milestones: 3.4.1, 3.5.0 Apr 5, 2019
@rafaelks rafaelks modified the milestones: 3.5.0, 3.6.0 May 8, 2019
@rafaelks rafaelks removed their assignment Aug 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Visible all deleted/cleaned messages in channels
4 participants