From bb3dfdc8a5f81009e4ce49a4a121b8acc0a5d222 Mon Sep 17 00:00:00 2001 From: Jamie <113370520+jamiebuilds-signal@users.noreply.github.com> Date: Wed, 11 Feb 2026 09:42:45 -0800 Subject: [PATCH] Fix go to pinned message targeting outgoing messages --- ts/sql/Interface.std.ts | 1 + ts/sql/Server.node.ts | 11 +++++++++-- ts/state/ducks/composer.preload.ts | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ts/sql/Interface.std.ts b/ts/sql/Interface.std.ts index 4ae8037430..7343e23c2e 100644 --- a/ts/sql/Interface.std.ts +++ b/ts/sql/Interface.std.ts @@ -895,6 +895,7 @@ type ReadableInterface = { _getAllReactions: () => Array; getMessageByAuthorAciAndSentAt: ( + ourAci: AciString, authorAci: AciString, sentAtTimestamp: number, options: { includeEdits: boolean } diff --git a/ts/sql/Server.node.ts b/ts/sql/Server.node.ts index 7296e14879..8a0a642917 100644 --- a/ts/sql/Server.node.ts +++ b/ts/sql/Server.node.ts @@ -3450,11 +3450,18 @@ function getAllMessageIds(db: ReadableDB): Array { function getMessageByAuthorAciAndSentAt( db: ReadableDB, + ourAci: AciString, authorAci: AciString, sentAtTimestamp: number, options: { includeEdits: boolean } ): MessageType | null { return db.transaction(() => { + const isSentByUs = ourAci === authorAci; + + const senderPredicate = isSentByUs + ? sqlFragment`(messages.sourceServiceId = ${authorAci} OR messages.type IS 'outgoing')` + : sqlFragment`(messages.sourceServiceId = ${authorAci})`; + // Return sentAt/readStatus from the messages table, when we edit a message // we add the original message to messages.editHistory and update original // message's sentAt/readStatus columns. @@ -3466,14 +3473,14 @@ function getMessageByAuthorAciAndSentAt( FROM edited_messages INNER JOIN messages ON messages.id = edited_messages.messageId - WHERE messages.sourceServiceId = ${authorAci} + WHERE ${senderPredicate} AND edited_messages.sentAt = ${sentAtTimestamp} `; const messagesQuery = sqlFragment` SELECT ${MESSAGE_COLUMNS_FRAGMENT} FROM messages - WHERE messages.sourceServiceId = ${authorAci} + WHERE ${senderPredicate} AND messages.sent_at = ${sentAtTimestamp} `; diff --git a/ts/state/ducks/composer.preload.ts b/ts/state/ducks/composer.preload.ts index e75bb59acd..d254f3bada 100644 --- a/ts/state/ducks/composer.preload.ts +++ b/ts/state/ducks/composer.preload.ts @@ -107,6 +107,7 @@ import { isVideoTypeSupported, } from '../../util/GoogleChrome.std.js'; import type { StateThunk } from '../types.std.js'; +import { itemStorage } from '../../textsecure/Storage.preload.js'; const { debounce, isEqual } = lodash; @@ -390,7 +391,10 @@ function scrollToPinnedMessage( pinMessage: PinMessageData ): StateThunk { return async (dispatch, getState) => { + const ourAci = itemStorage.user.getCheckedAci(); + const pinnedMessage = await DataReader.getMessageByAuthorAciAndSentAt( + ourAci, pinMessage.targetAuthorAci, pinMessage.targetSentTimestamp, { includeEdits: true }