Commit Graph

80 Commits

Author SHA1 Message Date
James Houlahan 4876314cf5 fix(GODT-2341): Handle URL error 2023-02-07 14:31:06 +01:00
James Houlahan 48f2c56caa fix(GODT-2327): Better sleep (with context) 2023-02-07 14:31:06 +01:00
James Houlahan 20d83dd476 fix(GODT-2327): Loop to retry until sync has complete 2023-02-07 14:31:06 +01:00
James Houlahan 9c6be78b4c fix(GODT-2327): Don't retry with abortable context because it's canceled 2023-02-07 14:31:06 +01:00
James Houlahan 0a8e71771e fix(GODT-2327): Fix lint issue 2023-02-07 14:31:06 +01:00
James Houlahan ca1996a670 fix(GODT-2327): Properly cancel event stream when handling refresh 2023-02-07 14:31:06 +01:00
James Houlahan ab1c1c474a fix(GODT-2327): Clear update channels whenever clearing sync status 2023-02-07 14:31:06 +01:00
James Houlahan 63bc87cc86 fix(GODT-2327): Only start processing events once sync is finished 2023-02-07 14:31:06 +01:00
James Houlahan 232875d5cc fix(GODT-2327): Delay event processing until gluon user exists
We don't want to start processing events until those events have
somewhere to be sent to.

Also, to be safe, ensure remove and re-add the gluon user while
clearing its sync status. This shouldn't be necessary.
2023-02-07 14:31:02 +01:00
James Houlahan 5ea53ea5c0 fix(GODT-2318): Remove gluon DB if label sync was incomplete 2023-02-06 16:36:15 +00:00
James Houlahan e89dcb2cca fix(GODT-2343): Only poll after send if sync is complete 2023-02-06 16:33:53 +01:00
James Houlahan 2cb2ca15c7 fix(GODT-2336): Recover from changed address order while bridge is down 2023-02-03 16:05:30 +01:00
James Houlahan db41645159 test: Add failing test for changing address order while bridge is down 2023-02-03 15:51:18 +01:00
Leander Beernaert 76d732f247 fix(GODT-2326): Only run sync after addIMAPUser()
There is concurrency bug due to competing sync calls that can occur when
we clear the sync status in the Vault. Running sync at the end of
addIMAPUser() avoids the problem.

This patch also remove the execution of a sync task for
`user.ClearSyncStatus()`
2023-02-02 16:26:12 +01:00
James Houlahan cf32b84257 GODT-2305: Detect missing gluon DB 2023-01-25 14:55:13 +01:00
James Houlahan e8a778feca GODT-2266: Pause event stream while sending 2023-01-25 09:47:27 +01:00
James Houlahan 849c8bee78 GODT-2223: Handle bad events by logging user out 2023-01-18 14:10:23 +00:00
Leander Beernaert 93c7552a41 GODT-2202: Report update errors from Gluon
For every update sent to gluon wait and check the error code to see if
an error occurred.

Note: Updates can't be inspect on the call site as it can lead to
deadlocks.
2023-01-13 15:54:31 +01:00
Leander Beernaert 2562d1e77d GODT-1817: Do not allow authentication of disabled accounts 2023-01-09 15:10:39 +00:00
Leander Beernaert 6d0a128111 Other: Update copyright year 2023-01-02 11:09:11 +01:00
Jakub c39108043b Merge branch 'release/perth_narrows' into devel (3.0.7) 2022-12-13 19:37:12 +01:00
Jakub 2b25fe1fa4 GODT-2173: fix: Migrate Bridge password from v2.X. 2022-12-13 14:25:39 +00:00
Jakub 6c30a04ac0 Merge branch 'release/perth_narrows' into devel 2022-12-07 09:26:59 +01:00
James Houlahan bd6ae2ac2b GODT-2187: Placeholder for unbuildable messages 2022-12-06 16:35:32 +01:00
James Houlahan 58d04f9693 GODT-2187: Skip messages during sync that fail to build/parse 2022-12-06 14:07:13 +00:00
James Houlahan 71ad1e9939 Other: Only send to necessary update channel 2022-11-30 13:52:42 +00:00
James Houlahan e601245f01 Other(chore): Bump major version to v3 2022-11-23 16:08:27 +01:00
James Houlahan ad1fb47b0d Other: Switch from liteapi to go-proton-api 2022-11-23 15:17:56 +01:00
James Houlahan 61287d05bf Other: Retry sync after cooldown if it fails 2022-11-23 12:47:16 +01:00
Leander Beernaert 0df4f41269 Other: Remove unused SyncBuffers setting 2022-11-22 13:59:06 +01:00
James Houlahan d1f140ebcb Other: More descriptive event poll name 2022-11-21 10:20:28 +00:00
James Houlahan 721cd9f319 GODT-2002: Wait for API events to be applied after send
When we send a message, the send recorder records the sent message.
When the client then appends an identical message to the sent folder,
the deduplication works and instead returns the message ID of the
existing proton message, rather than creating a new message. Gluon is
expected to notice that it already has this message ID and perform
some deduplication stuff internally.

However, it can happen that gluon doesn't yet have this message ID,
because we haven't yet received the "Message Created" event from the
API. To prevent this, we poll the events after send and wait for all
new events to be applied.

There's still a chance that the event wasn't generated yet on the API
side. Not sure what we can do about this.
2022-11-21 10:20:28 +00:00
James Houlahan c22037462e Other: Only update event ID in vault once all gluon updates were applied 2022-11-21 09:12:52 +00:00
James Houlahan eb2423b0ed Other: Move sending logic to smtp.go 2022-11-18 17:05:20 +01:00
James Houlahan e60bbaa60f Other: Add more user-level logs 2022-11-18 13:30:45 +00:00
James Houlahan 1e48ab4b9c GODT-2047: Clear last event ID when clearing sync status 2022-11-17 13:18:47 +00:00
Jakub ae87d7b236 GODT-1913: pass reporter to gluon, limit restarts, add crash handlers. 2022-11-16 13:48:31 +01:00
James Houlahan 59278913ca GODT-2037: Handle and log API refresh event 2022-11-16 13:48:31 +01:00
James Houlahan 28d78453b7 GODT-2029: Handle deadlock when reordering user addresses 2022-11-16 13:48:31 +01:00
James Houlahan c548ba85fe Other: Add more extensive logging 2022-11-16 13:48:30 +01:00
James Houlahan bc7912e8fb GODT-2022: Fix change between address modes 2022-11-16 13:48:30 +01:00
James Houlahan af542a2fc1 Other: Ensure logout works when offline 2022-11-16 13:48:30 +01:00
James Houlahan 039d1b7f99 GODT-2023: Revert to v2 bridge password encoming format
v2 used base64.RawURLEncoding rather than hex to encode the bridge
password. We should use that in v3 as well.
2022-11-16 13:48:30 +01:00
James Houlahan dbfb7572a8 GODT-2008: Ensure user's addresses are returned in sorted order 2022-11-16 13:48:30 +01:00
James Houlahan a213b48f93 GODT-2002: Poll after SMTP send
After sending, a client might append to the sent folder over IMAP.
In this case, we perform deduplication and return the message ID of the
sent message. However, if we haven't already processed this message in
gluon, it doesn't work as expected.

This change polls the event stream immediately after send. Note that it
doesn't wait for these events to be processed; that should be done in a
follow-up commit.
2022-11-16 13:48:30 +01:00
James Houlahan b72de5e3a4 Other: Fix goroutine leak in OnStatusDown
We should spawn the goroutine as a bridge async task rather than as a
normal goroutine
2022-11-16 13:48:30 +01:00
James Houlahan 3c4e8730ac Other: Read sync workers setting from vault 2022-11-16 13:48:30 +01:00
James Houlahan d4da325e57 Other(refactor): Sort safe.Mutex types before locking to prevent deadlocks
This change implements safe.Mutex and safe.RWMutex, which wrap the
sync.Mutex and sync.RWMutex types and are assigned a globally unique
integer ID. The safe.Lock and safe.RLock methods sort the mutexes
by this integer ID before locking to ensure that locks for a given
set of mutexes are always performed in the same order, avoiding
deadlocks.
2022-11-16 13:48:30 +01:00
James Houlahan fd80848fcd Other(refactor): Use normal value + mutex for user.updateCh 2022-11-16 13:48:30 +01:00
James Houlahan cab5ee6752 Other(refactor): Use normal value + mutex for user.apiLabels 2022-11-16 13:48:30 +01:00