Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcinwasowicz/09f1c94e27c07032c95aa86a3b60682a to your computer and use it in GitHub Desktop.
Save marcinwasowicz/09f1c94e27c07032c95aa86a3b60682a to your computer and use it in GitHub Desktop.
diff --git a/lib/utils/services-utils.js b/lib/utils/services-utils.js
index 684f444314..c22609665e 100644
--- a/lib/utils/services-utils.js
+++ b/lib/utils/services-utils.js
@@ -7,7 +7,7 @@ import type { AuthMetadata } from '../shared/identity-client-context.js';
// If this is true then we're using the identity service for auth. After we
// auth, the identity service gives us a CSAT, which we can use to auth with
// other Comm services.
-const usingCommServicesAccessToken = false;
+const usingCommServicesAccessToken = true;
// If this is true, then the app is able to support multiple keyservers. This
// requires the use of Tunnelbroker and the backup service to persist and sync
diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js
index b7e3d6bf76..9ece090f45 100644
--- a/native/input/input-state-container.react.js
+++ b/native/input/input-state-container.react.js
@@ -118,6 +118,16 @@ import { useSelector } from '../redux/redux-utils.js';
import blobServiceUploadHandler from '../utils/blob-service-upload.js';
import { useStaffCanSee } from '../utils/staff-utils.js';
+import type {
+ SenderDeviceID,
+ EncryptedNotifUtilsAPI,
+ TargetedNotificationWithPlatform,
+} from 'lib/types/notif-types.js';
+import type { MessageData } from 'lib/types/message-types.js';
+import { usePreparePushNotifs } from 'lib/push/send-hooks.react.js';
+import encryptedNotifsUtilsAPI from '../push/encrypted-notif-utils-api.js';
+import { getContentSigningKey } from 'lib/utils/crypto-utils.js';
+
type MediaIDs =
| { +type: 'photo', +localMediaID: string }
| { +type: 'video', +localMediaID: string, +localThumbnailID: string };
@@ -155,6 +165,13 @@ type Props = {
input: SendMultimediaMessageInput,
) => Promise<SendMessageResult>,
+sendTextMessage: (input: SendTextMessageInput) => Promise<SendMessageResult>,
+ +preparePushNotifs: (
+ encryptedNotifsUtilsAPI: EncryptedNotifUtilsAPI,
+ senderDeviceID: SenderDeviceID,
+ messageDatas: $ReadOnlyArray<MessageData>,
+ ) => Promise<?{
+ +[userID: string]: $ReadOnlyArray<TargetedNotificationWithPlatform>,
+ }>,
+newThread: (request: ClientNewThreadRequest) => Promise<NewThreadResult>,
+textMessageCreationSideEffectsFunc: CreationSideEffectsFunc<RawTextMessageInfo>,
};
@@ -580,6 +597,32 @@ class InputStateContainer extends React.PureComponent<Props, State> {
);
const sidebarCreation =
this.pendingSidebarCreationMessageLocalIDs.has(localID);
+ const signingKey = await getContentSigningKey();
+ if (this.props.viewerID) {
+ const result = await this.props.preparePushNotifs(
+ encryptedNotifsUtilsAPI,
+ { senderDeviceID: signingKey },
+ [
+ {
+ type: 0,
+ creatorID: this.props.viewerID,
+ time: Date.now(),
+ threadID: messageInfo.threadID,
+ localID,
+ text: messageInfo.text,
+ sidebarCreation,
+ },
+ ],
+ );
+
+ for (const userID in result) {
+ console.log(userID);
+ for (const obj of result[userID]) {
+ console.log(obj);
+ console.log(obj.targetedNotification.notification);
+ }
+ }
+ }
const result = await this.props.sendTextMessage({
threadID: messageInfo.threadID,
localID,
@@ -1734,6 +1777,7 @@ const ConnectedInputStateContainer: React.ComponentType<BaseProps> =
const callBlobServiceUpload = useBlobServiceUpload();
const callSendMultimediaMessage = useSendMultimediaMessage();
const callSendTextMessage = useSendTextMessage();
+ const preparePushNotifs = usePreparePushNotifs();
const callNewThread = useNewThread();
const dispatchActionPromise = useDispatchActionPromise();
const dispatch = useDispatch();
@@ -1755,6 +1799,7 @@ const ConnectedInputStateContainer: React.ComponentType<BaseProps> =
blobServiceUpload={callBlobServiceUpload}
sendMultimediaMessage={callSendMultimediaMessage}
sendTextMessage={callSendTextMessage}
+ preparePushNotifs={preparePushNotifs}
newThread={callNewThread}
dispatchActionPromise={dispatchActionPromise}
dispatch={dispatch}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment