Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3299493
D3348.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D3348.diff
View Options
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
@@ -441,6 +441,7 @@
export type MessageSelectionCriteria = {
+threadCursors?: ?ThreadCursors,
+joinedThreads?: ?boolean,
+ +newerThan?: ?number,
};
export type FetchMessageInfosRequest = {
diff --git a/server/src/fetchers/message-fetchers.js b/server/src/fetchers/message-fetchers.js
--- a/server/src/fetchers/message-fetchers.js
+++ b/server/src/fetchers/message-fetchers.js
@@ -23,7 +23,12 @@
import { threadPermissions } from 'lib/types/thread-types';
import { ServerError } from 'lib/utils/errors';
-import { dbQuery, SQL, mergeOrConditions } from '../database/database';
+import {
+ dbQuery,
+ SQL,
+ mergeOrConditions,
+ mergeAndConditions,
+} from '../database/database';
import type { PushInfo } from '../push/send';
import type { Viewer } from '../session/viewer';
import { creationString, localIDFromCreationString } from '../utils/idempotent';
@@ -348,24 +353,32 @@
function messageSelectionCriteriaToSQLClause(
criteria: MessageSelectionCriteria,
) {
- const conditions = [];
+ const threadConditions = [];
if (criteria.joinedThreads === true) {
- conditions.push(SQL`mm.role > 0`);
+ threadConditions.push(SQL`mm.role > 0`);
}
if (criteria.threadCursors) {
for (const threadID in criteria.threadCursors) {
const cursor = criteria.threadCursors[threadID];
if (cursor) {
- conditions.push(SQL`(m.thread = ${threadID} AND m.id < ${cursor})`);
+ threadConditions.push(
+ SQL`(m.thread = ${threadID} AND m.id < ${cursor})`,
+ );
} else {
- conditions.push(SQL`m.thread = ${threadID}`);
+ threadConditions.push(SQL`m.thread = ${threadID}`);
}
}
}
- if (conditions.length === 0) {
+ if (threadConditions.length === 0) {
throw new ServerError('internal_error');
}
- return mergeOrConditions(conditions);
+ const threadClause = mergeOrConditions(threadConditions);
+
+ const conditions = [threadClause];
+ if (criteria.newerThan) {
+ conditions.push(SQL`m.time > ${criteria.newerThan}`);
+ }
+ return mergeAndConditions(conditions);
}
function messageSelectionCriteriaToInitialTruncationStatuses(
@@ -384,7 +397,6 @@
async function fetchMessageInfosSince(
viewer: Viewer,
criteria: MessageSelectionCriteria,
- currentAsOf: number,
maxNumberPerThread: number,
): Promise<FetchMessageInfosResult> {
const selectionClause = messageSelectionCriteriaToSQLClause(criteria);
@@ -406,8 +418,7 @@
LEFT JOIN memberships mm ON mm.thread = m.thread AND mm.user = ${viewerID}
LEFT JOIN memberships stm ON m.type = ${messageTypes.CREATE_SUB_THREAD}
AND stm.thread = m.content AND stm.user = ${viewerID}
- WHERE m.time > ${currentAsOf} AND
- JSON_EXTRACT(mm.permissions, ${visibleExtractString}) IS TRUE AND
+ WHERE JSON_EXTRACT(mm.permissions, ${visibleExtractString}) IS TRUE AND
`;
query.append(selectionClause);
query.append(SQL`
diff --git a/server/src/socket/socket.js b/server/src/socket/socket.js
--- a/server/src/socket/socket.js
+++ b/server/src/socket/socket.js
@@ -426,7 +426,11 @@
for (const watchedThreadID of watchedIDs) {
threadCursors[watchedThreadID] = null;
}
- const messageSelectionCriteria = { threadCursors, joinedThreads: true };
+ const messageSelectionCriteria = {
+ threadCursors,
+ joinedThreads: true,
+ newerThan: oldMessagesCurrentAsOf,
+ };
const [
fetchMessagesResult,
{ serverRequests, activityUpdateResult },
@@ -434,7 +438,6 @@
fetchMessageInfosSince(
viewer,
messageSelectionCriteria,
- oldMessagesCurrentAsOf,
defaultNumberPerThread,
),
processClientResponses(viewer, clientResponses),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 12:42 PM (22 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2534942
Default Alt Text
D3348.diff (3 KB)
Attached To
Mode
D3348: [server] Move fetchMessageInfosSince's currentAsOf param to MessageSelectionCriteria
Attached
Detach File
Event Timeline
Log In to Comment