Page MenuHomePhabricator

D4601.id15273.diff
No OneTemporary

D4601.id15273.diff

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
@@ -3,6 +3,7 @@
import apn from '@parse/node-apn';
import type { ResponseFailure } from '@parse/node-apn';
import invariant from 'invariant';
+import _cloneDeep from 'lodash/fp/cloneDeep';
import _flow from 'lodash/fp/flow';
import _mapValues from 'lodash/fp/mapValues';
import _pickBy from 'lodash/fp/pickBy';
@@ -40,7 +41,12 @@
import { fetchUserInfos } from '../fetchers/user-fetchers';
import type { Viewer } from '../session/viewer';
import { getAPNsNotificationTopic } from './providers';
-import { apnPush, fcmPush, getUnreadCounts } from './utils';
+import {
+ apnPush,
+ fcmPush,
+ getUnreadCounts,
+ apnMaxNotificationPayloadByteSize,
+} from './utils';
type Device = {
+deviceType: DeviceType,
@@ -492,13 +498,21 @@
notification.pushType = 'alert';
notification.payload.id = uniqueID;
notification.payload.threadID = threadInfo.id;
- notification.payload.messageInfos = JSON.stringify(newRawMessageInfos);
if (codeVersion > 1000) {
notification.mutableContent = true;
}
if (collapseKey) {
notification.collapseId = collapseKey;
}
+ const messageInfos = JSON.stringify(newRawMessageInfos);
+ const copyWithMessageInfos = _cloneDeep(notification);
+ copyWithMessageInfos.payload = {
+ ...copyWithMessageInfos.payload,
+ messageInfos,
+ };
+ if (copyWithMessageInfos.length() <= apnMaxNotificationPayloadByteSize) {
+ notification.payload.messageInfos = messageInfos;
+ }
return notification;
}

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 8:14 AM (7 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2589581
Default Alt Text
D4601.id15273.diff (1 KB)

Event Timeline