Page MenuHomePhabricator

Use notification service on ios to store notification in sqlite
AbandonedPublic

Authored by marcin on May 17 2022, 1:59 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 25, 6:53 AM
Unknown Object (File)
Mon, Nov 25, 3:41 AM
Unknown Object (File)
Mon, Nov 25, 2:33 AM
Unknown Object (File)
Mon, Nov 25, 2:17 AM
Unknown Object (File)
Mon, Nov 25, 12:26 AM
Unknown Object (File)
Fri, Nov 22, 10:12 PM
Unknown Object (File)
Sat, Nov 2, 11:15 AM
Unknown Object (File)
Sat, Nov 2, 11:14 AM

Details

Reviewers
tomek
karol
Summary

This differential uses C++ functionality implemented in previous diffs to update SQLite directly in response to notifications. SQLite database is update if and only if database has been already created by the app (SQLite file exists)

Test Plan

In XCode debugger examine Message and Media database entities created from raw notification JSON string by translation functionality written in C++. Ensure also that SQLiteQueryExecutor::replaceMessage() method gets called. execute this process for all message types we define in Comm that hae generate_notifs flag set.

Comment out set_encryption_key method in SQLiteQueryExecutor (to disable encryption) code build app on an emulator, launch it and immediately kill. Then send a message from another client. Download comm.sqlite database from XCode. Examine its content in some sqlite explorer (vscode has a pretty good one) to ensure that messages are there even though app was not launched after sending message.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

tomek requested changes to this revision.May 18 2022, 9:44 AM
tomek added inline comments.
native/ios/NotificationService/NotificationService.mm
32 ↗(On Diff #12885)

Should we call this function after every notification?

36–38 ↗(On Diff #12885)

I don't we need to log it - there will be a lot of notifications without it and we expect that

This revision now requires changes to proceed.May 18 2022, 9:44 AM
native/ios/NotificationService/NotificationService.mm
32 ↗(On Diff #12885)

comm::SQLiteQueryExecutor::initialize(sqliteFilePathStdStr) is implemented with std::call_once semantics, so multiple call to initialization method do not perform unnecessary operations. On the other hand I understand it might be confusing. Probably we could extend SQLiteQueryExecutor API to check if it is already initialized or add a flag in NotificationService. What do you think?

36–38 ↗(On Diff #12885)

Ok, I will remove this log.

tomek requested changes to this revision.May 20 2022, 1:04 AM
tomek added inline comments.
native/ios/NotificationService/NotificationService.mm
34–36 ↗(On Diff #12942)

We're checking if the notification contains message infos, and not the existence of the database.

32 ↗(On Diff #12885)

I wouldn't change the API - it is really convenient. But what do you think about changing the name to e.g. initializeIfNecessary?

This revision now requires changes to proceed.May 20 2022, 1:04 AM
native/ios/NotificationService/NotificationService.mm
34–36 ↗(On Diff #12942)

Actually this if statement checks whether database exists. The first if statement checks whether notification contains message info and database exists. If the condition fails in the first if then it means either message does not contain messageInfos or the database does not exists or both. Then the second if is executed and if the message contains messageInfos key the it means previous if statement failed because database does not exists. I understand it is not that obvious at the first sight but it optimizes indenation.

marcin added inline comments.
native/ios/NotificationService/NotificationService.mm
34–36 ↗(On Diff #12942)

Perhaps I should think about implementing it in a way that is more self-explanatory. @palys-swm let me know what do you think.

tomek added inline comments.
native/ios/NotificationService/NotificationService.mm
34–36 ↗(On Diff #12942)

Ah, that makes sense. For me decreasing the indentation is a really useful tool when improving the readability. So the goal is readability and when deeper indentation produces more readable code, it should be preferred.

In this case nested ifs would be more readable for me, but we have a strong preference for decreasing the indentation, so let's leave it.

This revision is now accepted and ready to land.May 20 2022, 7:45 AM

This diff is no longer relevant - abandoning.