From a667f2898437c1721bfca65b0ab60d0fb2016759 Mon Sep 17 00:00:00 2001 From: N-Pex Date: Mon, 25 Aug 2025 14:47:12 +0200 Subject: [PATCH] Send proof hint flags for media messages --- src/models/attachmentManager.ts | 3 ++- src/models/proof.ts | 8 +++++++- src/plugins/utils.js | 9 +++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/models/attachmentManager.ts b/src/models/attachmentManager.ts index 6d029fc..ac0566f 100644 --- a/src/models/attachmentManager.ts +++ b/src/models/attachmentManager.ts @@ -627,7 +627,8 @@ export const createUploadBatch = (manager: AttachmentManager | null, room: Room }, eventId, attachment.dimensions, - attachment.thumbnail + attachment.thumbnail, + attachment.proofHintFlags ) .then((mediaEventId: string) => { // Look at last item rotation, flipping the sign on this, so looks more like a true stack diff --git a/src/models/proof.ts b/src/models/proof.ts index deee838..2340d3a 100644 --- a/src/models/proof.ts +++ b/src/models/proof.ts @@ -67,6 +67,8 @@ export type ProofHintFlags = { export const extractProofHintFlags = (proof?: Proof): (ProofHintFlags | undefined) => { if (!proof) return undefined; + let foundCreated = false; + let screenshot = false; let camera = false; let aiGenerated = false; @@ -104,10 +106,14 @@ export const extractProofHintFlags = (proof?: Proof): (ProofHintFlags | undefine ) { aiGenerated = true; } - return; + foundCreated = true; + break; } } } + if (foundCreated) { + break; + } } if (valid) { const flags: ProofHintFlags = { diff --git a/src/plugins/utils.js b/src/plugins/utils.js index 1231e49..500b03b 100644 --- a/src/plugins/utils.js +++ b/src/plugins/utils.js @@ -23,6 +23,7 @@ export const ROOM_TYPE_FILE_MODE = "im.keanu.room_type_file"; export const ROOM_TYPE_CHANNEL = "im.keanu.room_type_channel"; export const STATE_EVENT_ROOM_TYPE = "im.keanu.room_type"; +export const CLIENT_EVENT_PROOF_HINT = "im.keanu.proof_hint"; export const THUMBNAIL_MAX_WIDTH = 640; export const THUMBNAIL_MAX_HEIGHT = 640; @@ -410,7 +411,7 @@ class Util { return [encryptedBytes, encryptedFile]; } - sendFile(matrixClient, roomId, file, onUploadProgress, threadRoot, dimensions, thumbnail) { + sendFile(matrixClient, roomId, file, onUploadProgress, threadRoot, dimensions, thumbnail, proofHintFlags) { const uploadPromise = new UploadPromise(undefined); uploadPromise.wrappedPromise = new Promise((resolve, reject) => { var reader = new FileReader(); @@ -485,12 +486,16 @@ class Util { msgtype = "m.video"; } - var messageContent = { + let messageContent = { body: description, info: info, msgtype: msgtype, }; + if (proofHintFlags) { + messageContent[CLIENT_EVENT_PROOF_HINT] = JSON.stringify(proofHintFlags); + } + // If thread root (an eventId) is set, add that here if (threadRoot) { messageContent["m.relates_to"] = {