Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

add is memory token property to sessions #2004

Conversation

udaraweerasinghege
Copy link
Contributor

@@ -4,7 +4,7 @@ set -eu

glob=$*
if [ -z "$glob" ]; then
glob="--recursive test/local test/remote"
glob="--recursive test/remote/db_tests.js"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@udaraweerasinghege Do you need to undo this change?

@@ -526,7 +526,8 @@ module.exports = (
uaOSVersion: token.uaOSVersion,
uaDeviceType: token.uaDeviceType,
lastAccessTime: token.lastAccessTime,
createdAt: token.createdAt
createdAt: token.createdAt,
isMemoryToken: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@udaraweerasinghege we also need to update the response schemas for /sessions and /devices, to handle this optional property. I'm hoping API.md will auto update with this

@@ -1202,6 +1208,12 @@ for the authenticated user.

<!--end-response-body-get-accountsessions-isCurrentDevice-->

* `isMemoryToken`: *boolean, required*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With appologies for the late drive-by comment, this seems like it's piercing a layer of abstraction - it's taking an internal implementation detail of the server and exposing it in the API for consumption by the client. To display the correct information, the content-server needs to know that the auth-server sometimes stores tokens in redis, and that these tokens are the only ones that are up-to-date.

I wonder if a better abstraction here would involve us sending two separate timestamps:

  • lastAccessTime: the value from redis, but it might be null if we don't have a correct value to show
  • createdTime: the "started syncing" timestamp which we know we can always get from the db

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if a better abstraction here would involve us sending two separate timestamps

Yeah we had that idea earlier, but I Think @philbooth wanted to keep the fields from redis and mysql consistent (to avoid confusion, etc)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from mtg:

lastAccessTimeFormatted - redis token
createdTimeFormatted - created token

@philbooth
Copy link
Contributor

Yeah we had that idea earlier, but I Think @philbooth wanted to keep the fields from redis and mysql consistent (to avoid confusion, etc)

Fwiw, I just checked with @philbooth and he's +1 to @rfk's suggestion. 😄

The consistency comment concerned whether session tokens returned from redis should also include data that was fetched from MySQL, IIRC. I see no conflict here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants