Page MenuHomePhabricator

D7110.id23907.diff
No OneTemporary

D7110.id23907.diff

diff --git a/keyserver/src/fetchers/message-fetchers.js b/keyserver/src/fetchers/message-fetchers.js
--- a/keyserver/src/fetchers/message-fetchers.js
+++ b/keyserver/src/fetchers/message-fetchers.js
@@ -21,6 +21,8 @@
messageTruncationStatus,
type FetchMessageInfosResult,
defaultMaxMessageAge,
+ type FetchPinnedMessagesRequest,
+ type FetchPinnedMessagesResult,
} from 'lib/types/message-types.js';
import { threadPermissions } from 'lib/types/thread-types.js';
import { ServerError } from 'lib/utils/errors.js';
@@ -659,6 +661,50 @@
return result;
}
+async function fetchPinnedMessageInfos(
+ viewer: Viewer,
+ request: FetchPinnedMessagesRequest,
+): Promise<?FetchPinnedMessagesResult> {
+ const messageRowsQuery = SQL`
+ SELECT m.id, m.thread AS threadID, m.content, m.time, m.type, m.creation,
+ m.user AS creatorID, m.target_message as targetMessageID,
+ NULL AS subthread_permissions, u.id AS uploadID,
+ u.type AS uploadType, u.secret AS uploadSecret, u.extra AS uploadExtra
+ FROM messages m
+ LEFT JOIN uploads u ON u.container = m.id
+ LEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = ${viewer.id}
+ WHERE m.thread = ${request.threadID}
+ AND m.pinned = 1
+ AND JSON_EXTRACT(mm.permissions, ${visibleExtractString}) IS TRUE
+ `;
+ const [messageRows] = await dbQuery(messageRowsQuery);
+ if (messageRows.length === 0) {
+ return null;
+ }
+ const derivedMessages = await fetchDerivedMessages(messageRows, viewer);
+
+ const pinnedRawMessageInfos = [];
+ for (const messageRow of messageRows) {
+ const rawMessageInfo = rawMessageInfoFromRows(
+ [messageRow],
+ viewer,
+ derivedMessages,
+ );
+ if (rawMessageInfo) {
+ pinnedRawMessageInfos.push(rawMessageInfo);
+ }
+ }
+
+ const shimmedPinnedRawMessageInfos = shimUnsupportedRawMessageInfos(
+ pinnedRawMessageInfos,
+ viewer.platformDetails,
+ );
+
+ return {
+ pinnedMessages: shimmedPinnedRawMessageInfos,
+ };
+}
+
async function fetchDerivedMessages(
rows: $ReadOnlyArray<Object>,
viewer?: Viewer,
@@ -729,4 +775,5 @@
fetchMessageInfoForEntryAction,
fetchMessageInfoByID,
fetchThreadMessagesCount,
+ fetchPinnedMessageInfos,
};
diff --git a/lib/types/message-types.js b/lib/types/message-types.js
--- a/lib/types/message-types.js
+++ b/lib/types/message-types.js
@@ -573,3 +573,11 @@
export type MessageStorePrunePayload = {
+threadIDs: $ReadOnlyArray<string>,
};
+
+export type FetchPinnedMessagesRequest = {
+ +threadID: string,
+};
+
+export type FetchPinnedMessagesResult = {
+ +pinnedMessages: $ReadOnlyArray<RawMessageInfo>,
+};

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 2:59 AM (21 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578111
Default Alt Text
D7110.id23907.diff (2 KB)

Event Timeline