diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js --- a/keyserver/src/creators/message-creator.js +++ b/keyserver/src/creators/message-creator.js @@ -48,7 +48,7 @@ +devices: Map< string, { - +deviceType: string, + +platform: string, +deviceToken: string, +codeVersion: ?string, }, @@ -376,7 +376,7 @@ } if (deviceToken) { thisUserInfo.devices.set(deviceToken, { - deviceType: platform, + platform, deviceToken, codeVersion: versions ? versions.codeVersion : null, }); diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js --- a/keyserver/src/push/send.js +++ b/keyserver/src/push/send.js @@ -22,7 +22,7 @@ rawThreadInfoFromServerThreadInfo, threadInfoFromRawThreadInfo, } from 'lib/shared/thread-utils.js'; -import type { DeviceType } from 'lib/types/device-types.js'; +import type { Platform } from 'lib/types/device-types.js'; import { type RawMessageInfo, type MessageInfo, @@ -51,7 +51,7 @@ import { getENSNames } from '../utils/ens-cache.js'; type Device = { - +deviceType: DeviceType, + +platform: Platform, +deviceToken: string, +codeVersion: ?number, }; @@ -144,7 +144,7 @@ const dbID = dbIDs.shift(); invariant(dbID, 'should have sufficient DB IDs'); - const byDeviceType = getDevicesByDeviceType(pushInfo[userID].devices); + const byPlatform = getDevicesByPlatform(pushInfo[userID].devices); const firstMessageID = firstNewMessageInfo.id; invariant(firstMessageID, 'RawMessageInfo.id should be set on server'); const notificationInfo = { @@ -156,7 +156,7 @@ collapseKey: notifInfo.collapseKey, }; - const iosVersionsToTokens = byDeviceType.get('ios'); + const iosVersionsToTokens = byPlatform.get('ios'); if (iosVersionsToTokens) { for (const [codeVer, deviceTokens] of iosVersionsToTokens) { const codeVersion = parseInt(codeVer, 10); // only for Flow @@ -182,7 +182,7 @@ deliveryPromises.push(deliveryPromise); } } - const androidVersionsToTokens = byDeviceType.get('android'); + const androidVersionsToTokens = byPlatform.get('android'); if (androidVersionsToTokens) { for (const [codeVer, deviceTokens] of androidVersionsToTokens) { const codeVersion = parseInt(codeVer, 10); // only for Flow @@ -448,15 +448,15 @@ return await createIDs('notifications', numIDsNeeded); } -function getDevicesByDeviceType( +function getDevicesByPlatform( devices: Device[], -): Map>> { - const byDeviceType = new Map(); +): Map>> { + const byPlatform = new Map(); for (const device of devices) { - let innerMap = byDeviceType.get(device.deviceType); + let innerMap = byPlatform.get(device.platform); if (!innerMap) { innerMap = new Map(); - byDeviceType.set(device.deviceType, innerMap); + byPlatform.set(device.platform, innerMap); } const codeVersion: number = device.codeVersion !== null && device.codeVersion !== undefined @@ -469,7 +469,7 @@ } innerMostSet.add(device.deviceToken); } - return byDeviceType; + return byPlatform; } async function prepareIOSNotification( @@ -789,15 +789,15 @@ const unreadCount = unreadCounts[userID]; const devices = deviceTokenResult.map(row => ({ - deviceType: row.platform, + platform: row.platform, deviceToken: row.device_token, codeVersion: JSON.parse(row.versions)?.codeVersion, })); - const byDeviceType = getDevicesByDeviceType(devices); + const byPlatform = getDevicesByPlatform(devices); const deliveryPromises = []; - const iosVersionsToTokens = byDeviceType.get('ios'); + const iosVersionsToTokens = byPlatform.get('ios'); if (iosVersionsToTokens) { for (const [codeVer, deviceTokens] of iosVersionsToTokens) { const codeVersion = parseInt(codeVer, 10); // only for Flow @@ -816,7 +816,7 @@ } } - const androidVersionsToTokens = byDeviceType.get('android'); + const androidVersionsToTokens = byPlatform.get('android'); if (androidVersionsToTokens) { for (const [codeVer, deviceTokens] of androidVersionsToTokens) { const codeVersion = parseInt(codeVer, 10); // only for Flow