This differential encrypts rescinds before sending them.
Details
- Reviewers
tomek bartek kamil - Commits
- rCOMMe51ad2aadbff: Encrypt rescinds
Ensure rescinds are working correctly and each time they are sent (messages are read on another device) olm session version in db is incremented
Diff Detail
- Repository
- rCOMM Comm
- Branch
- marcin/eng-4003
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
| keyserver/src/push/rescind.js | ||
|---|---|---|
| 50–67 ↗ | (On Diff #28267) | I discussed with @tomek what would be the best approach here to get cookie ids associated with relevant device tokens necessary to encrypt notifications. We considered three different approaches:
Therefore we decided it is best to issue additional query where to get relevant cookie ids based on device tokens returned from previous query. This approach does not necessarily have to be poorer in terms of performance but it does force use iterate over fetchResults twice. (first to get cookie ids and device tokens, second to use cookie ids and device tokens to encrypt and send rescinds.) if there is a disagreement as to whether the approach above is correct, I would rather refactor the way we store data contained within delivery field into something relational. That would allow us to modify the original query to use JOIN to easily get relevant cookie ids. |
Refactor: use generic typed function to avoid repeated code when conditionally encrypting and sending notifications paired with device token
| native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java | ||
|---|---|---|
| 102–107 ↗ | (On Diff #28334) | Why do we use warning level? For me these are at most info, probably even just debug. |
| native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java | ||
|---|---|---|
| 102–107 ↗ | (On Diff #28334) | My bad. I left logs I used for debugging. I will remove them since they are of no use here. |
| keyserver/src/push/rescind.js | ||
|---|---|---|
| 217–221 ↗ | (On Diff #28334) | Can we modify the encryptCallback so that it returns pairs notif - device token? The current solution has some assumptions about ordering and length of notifications and deviceTokens arrays. |
| 50–67 ↗ | (On Diff #28267) | Although it is ok to iterate twice, we should avoid repeating as much work as possible. For example, it doesn't make sense to JSON.parse results twice. |
- Remove unnecessary logs
- Ensure deviceToken and cookieID are related to the same device
| keyserver/src/push/rescind.js | ||
|---|---|---|
| 52–73 | You're still parsing the result twice. | |
| 208 | Just a nit, but we're using this variable only when !shouldBeEncrypted so it can be moved into that if. Additionally, we're mapping from devices to deviceTokens and then to {notif, token} - instead, we can directly map from devices to the result. | |
| keyserver/src/push/rescind.js | ||
|---|---|---|
| 59 ↗ | (On Diff #28439) | Is it possible that some deviceTokens appear multiple times in fetch results? Should we use a Set here? |
| 287–311 ↗ | (On Diff #28439) | Why do we await the return in only one function? |
| native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java | ||
| 81 ↗ | (On Diff #28439) | It should be at most info, maybe even debug |
| keyserver/src/push/rescind.js | ||
|---|---|---|
| 59 ↗ | (On Diff #28439) | If a couple of notifications are sent to the same device then we indeed can have multiple same deviceToken. Each row in notifications table contains delivery column which contains all device tokens this notification was successfully sent to. Therefore using a set here should be functionally equivalent to raw array. We eventually create a map deviceToken => cookieID. Database schema enforces that each cookieID corresponds to exactly one deviceToken. I am not sure about the performance here. Adding to an array (at the end) should be faster that adding to a set, but using a set could speed up SQL query that lookups cookieIDs. Therefore we can use a Set here. |
| 287–311 ↗ | (On Diff #28439) | It is my oversight. I should have added await in both. |
| 217–221 ↗ | (On Diff #28334) | This would require us to modify prepareEncryptedAndroidNotifications and prepareEncrypted |
| native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java | ||
| 81 ↗ | (On Diff #28439) | It is my oversight. I forgot to remove debugging logs. |
| keyserver/src/push/rescind.js | ||
|---|---|---|
| 59 ↗ | (On Diff #28439) | According to docs: https://mariadb.com/kb/en/in/ MariaDB sorts list passed to IN and then does binary search on it. Therefore using a Set will let us pass shorter list and therefore improve performance. |