Page MenuHomePhabricator

[lib] add conditions for adding keyserver to the keyserver store
ClosedPublic

Authored by ginsu on Oct 31 2023, 9:18 PM.
Tags
None
Referenced Files
F2204737: D9664.id32598.diff
Sat, Jul 6, 5:37 PM
Unknown Object (File)
Thu, Jul 4, 1:56 PM
Unknown Object (File)
Wed, Jul 3, 7:43 PM
Unknown Object (File)
Tue, Jul 2, 5:53 AM
Unknown Object (File)
Mon, Jul 1, 1:11 PM
Unknown Object (File)
Mon, Jul 1, 7:26 AM
Unknown Object (File)
Sun, Jun 30, 7:22 PM
Unknown Object (File)
Sat, Jun 29, 6:47 PM

Details

Summary

This diff adds two conditions for adding a new keyserver to the keyserver store. The first condition resets the keyserver store whenever we logout/delete account/or change session, the second adds the keyserver into the keyserver store

Making @inka a blocking reviewer since she is currently working a lot with this file and I want to make sure that these changes don't interfere with anything that is currently "in flight"

Linear task: https://linear.app/comm/issue/ENG-5342/add-a-condition-for-the-new-addkeyserveractiontype

Depends on D9591

Test Plan

Confirmed that the keyserver was added to the keyserver store

Logs of the keyserver store where I added a dummy keyserver info

Screenshot 2023-10-31 at 4.03.18 AM.png (1×1 px, 170 KB)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ginsu edited the test plan for this revision. (Show Details)
ginsu added reviewers: inka, rohan, michal.
ginsu edited the summary of this revision. (Show Details)
ginsu added a subscriber: inka.
ginsu requested review of this revision.Oct 31 2023, 9:39 PM

Nit – we usually use } else if in reducers. It doesn't matter since each condition returns, but it would be good to be consistent

lib/reducers/keyserver-reducer.js
51 ↗(On Diff #32598)

Convert this to else if as well

lib/reducers/keyserver-reducer.js
32–37 ↗(On Diff #32599)

setNewSession is an action that can be called for every keyserver separately. We shouldn't be clearing the whole keyserver store

inka accepted this revision.EditedNov 6 2023, 8:49 AM

On second thoughts, this cannot be handled yet. Disregard my comment
This will be refactored in ENG-5350

This revision is now accepted and ready to land.Nov 6 2023, 8:49 AM

Did you check if no errors are thrown when a user logs out and back in? I feel like the lack of ashoatKeyserverID might cause problems

inka requested changes to this revision.Nov 6 2023, 9:55 AM

Adding

if (
  action.type === logOutActionTypes.success ||
  (action.type === setNewSessionActionType &&
    action.payload.sessionChange.cookieInvalidated)
) {
  return {
    keyserverInfos: {},
  };
}

to my current code causes logout action to fail. Please check if this happens for you as well

This revision now requires changes to proceed.Nov 6 2023, 9:55 AM

This diff will be conflicting with my changes in this stack: D9750, but if you land this before me I will just update it. Before I land my changes you cannot write it in a way that wouldn't conflict with me, so don't worry about it

lib/reducers/keyserver-reducer.js
37–48 ↗(On Diff #32999)

Please follow the pattern of updating only what needs to be updated. This will make it easier to add new fields into KeyserverStore or KeyserverInfos in the future

37–48 ↗(On Diff #32999)

Also - you are overwriting here fields that are reduced in other reducers (see the bottom of this file), and:

  1. you are returning, so the reducers don't get called
  2. you are putting in different values than those reducers would have

For example on logOutActionTypes.success you make the connection null, whereas the reduceConnectionInfo would have made it

{
      ...connection,
      queuedActivityUpdates: [],
}

deviceToken and lastCommunicatedPlatformDetails are not changed at all by their reducers on logOutActionTypes.success. And so on.

Can you explain why that is?

inka added inline comments.
lib/reducers/keyserver-reducer.js
37–41 ↗(On Diff #33125)

@ginsu and I discussed this, and we actually want to remove the other keyservers, so we are avoiding the other spreads here.
This will be refactored a bit when I rebase D9750 stack on it

This revision is now accepted and ready to land.Nov 13 2023, 8:59 AM
inka requested changes to this revision.Nov 13 2023, 9:06 AM

Actually we need to fix setNewSessionActionType

This revision now requires changes to proceed.Nov 13 2023, 9:06 AM

update after syncing with @inka

Here is the keyserver store after the logout action:

Screenshot 2023-11-13 at 12.43.24 PM.png (2×3 px, 1 MB)

This revision is now accepted and ready to land.Nov 13 2023, 9:43 AM
This revision was landed with ongoing or failed builds.Nov 13 2023, 12:00 PM
This revision was automatically updated to reflect the committed changes.