Skip to content

Commit

Permalink
hidden email: Record our own email as returned by /register.
Browse files Browse the repository at this point in the history
With the "hidden emails" feature (aka `email_address_visibility`)
that's now in beta on the server, the user's "email" as used as an
identifier for them in the Zulip API can be an opaque one made up by
the server -- different from `auth.email` aka `delivery_email`.  So we
need to switch our concept of "own email" to use the identifier-email;
this is #3196.

The server tells us this user's identifier-email in the `/register`
response, so one necessary step is to remember it.  Do that.

In principle we should then update this value on EVENT_USER_UPDATE.
But (a) the same is true of several other values here, and more
importantly (b) we already don't handle EVENT_USER_UPDATE at all,
either in our `users` state-subtree or in the various denormalized
spots where we store other users' emails, avatars, etc.  So punt.
Changing emails is pretty uncommon; and in the particular case where
it's happening for all an org's users en masse because hidden-emails
was turned on or off, the only near-term-feasible solution will
probably be to have the server just invalidate clients' event queues.
  • Loading branch information
gnprice committed Jul 17, 2019
1 parent 637d09b commit 30c4f7f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/boot/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ const migrations: { [string]: (GlobalState) => GlobalState } = {
ackedPushToken: a.ackedPushToken !== undefined ? a.ackedPushToken : null,
})),
}),

// $FlowMigrationFudge
'7': dropCache,
};

const reduxPersistConfig: Config = {
Expand Down
4 changes: 4 additions & 0 deletions src/realm/realmReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
const initialState = {
canCreateStreams: true,
crossRealmBots: [],
email: undefined,
twentyFourHourTime: false,
emoji: {},
filters: [],
Expand Down Expand Up @@ -41,6 +42,7 @@ export default (state: RealmState = initialState, action: Action): RealmState =>
...state,
canCreateStreams: action.data.can_create_streams,
crossRealmBots: action.data.cross_realm_bots,
email: action.data.email,
emoji: convertRealmEmoji(action.data.realm_emoji),
filters: action.data.realm_filters,
isAdmin: action.data.is_admin,
Expand All @@ -49,6 +51,8 @@ export default (state: RealmState = initialState, action: Action): RealmState =>
};
}

// TODO on EVENT_USER_UPDATE for self: update email, isAdmin, etc.

case EVENT_REALM_FILTERS:
return {
...state,
Expand Down
2 changes: 2 additions & 0 deletions src/reduxTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export type PresenceState = {|
* @prop emoji
*
* About the user:
* @prop email
* @prop twentyFourHourTime
* @prop canCreateStreams
* @prop isAdmin
Expand All @@ -224,6 +225,7 @@ export type RealmState = {|
filters: RealmFilter[],
emoji: RealmEmojiById,

email: string | void,
twentyFourHourTime: boolean,
canCreateStreams: boolean,
isAdmin: boolean,
Expand Down

0 comments on commit 30c4f7f

Please sign in to comment.