diff --git a/keyserver/src/session/viewer.js b/keyserver/src/session/viewer.js --- a/keyserver/src/session/viewer.js +++ b/keyserver/src/session/viewer.js @@ -158,7 +158,7 @@ } } - setDeviceToken(deviceToken: string) { + setDeviceToken(deviceToken: ?string) { if (this.data.loggedIn) { this.data = { ...this.data, deviceToken }; } else { diff --git a/keyserver/src/updaters/device-token-updaters.js b/keyserver/src/updaters/device-token-updaters.js --- a/keyserver/src/updaters/device-token-updaters.js +++ b/keyserver/src/updaters/device-token-updaters.js @@ -14,12 +14,15 @@ if (deviceType === undefined) { throw new ServerError('invalid_parameters'); } + const { deviceToken } = update; - viewer.setDeviceToken(update.deviceToken); - await clearDeviceToken(update.deviceToken); + viewer.setDeviceToken(deviceToken); + if (deviceToken) { + await clearDeviceToken(deviceToken); + } const setColumns = {}; - setColumns.device_token = update.deviceToken; + setColumns.device_token = deviceToken; setColumns.platform = deviceType; if (update.platformDetails) { const { platform, ...versions } = update.platformDetails; diff --git a/lib/types/device-types.js b/lib/types/device-types.js --- a/lib/types/device-types.js +++ b/lib/types/device-types.js @@ -30,7 +30,7 @@ } export type DeviceTokenUpdateRequest = { - +deviceToken: string, + +deviceToken: ?string, +deviceType?: DeviceType, +platformDetails?: PlatformDetails, };