From 57326f72e6118e120ebca53fd0406bc074424a6c Mon Sep 17 00:00:00 2001 From: wangai-studio <256938352+wangai-studio@users.noreply.github.com> Date: Fri, 6 Feb 2026 08:25:21 +0800 Subject: [PATCH] fix(nextcloud-talk): sign message text instead of JSON body (#2092) Nextcloud Talk's ChecksumVerificationService verifies HMAC against the extracted message/reaction text, not the full JSON body. This fixes 401 authentication errors when sending messages via the bot API. - sendMessageNextcloudTalk: sign 'message' text only - sendReactionNextcloudTalk: sign 'reaction' string only --- extensions/nextcloud-talk/src/send.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/nextcloud-talk/src/send.ts b/extensions/nextcloud-talk/src/send.ts index 2ac71f461..365526c40 100644 --- a/extensions/nextcloud-talk/src/send.ts +++ b/extensions/nextcloud-talk/src/send.ts @@ -93,8 +93,12 @@ export async function sendMessageNextcloudTalk( } const bodyStr = JSON.stringify(body); + // Nextcloud Talk verifies signature against the extracted message text, + // not the full JSON body. See ChecksumVerificationService.php: + // hash_hmac('sha256', $random . $data, $secret) + // where $data is the "message" parameter, not the raw request body. const { random, signature } = generateNextcloudTalkSignature({ - body: bodyStr, + body: message, secret, }); @@ -183,8 +187,9 @@ export async function sendReactionNextcloudTalk( const normalizedToken = normalizeRoomToken(roomToken); const body = JSON.stringify({ reaction }); + // Sign only the reaction string, not the full JSON body const { random, signature } = generateNextcloudTalkSignature({ - body, + body: reaction, secret, });