Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33311123
D3349.1768810176.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D3349.1768810176.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
@@ -468,6 +468,7 @@
+currentAsOf: number,
};
export const defaultNumberPerThread = 20;
+export const defaultMaxMessageAge = 14 * 24 * 60 * 60 * 1000; // 2 weeks
export type SendMessageResponse = {
+newMessageInfo: RawMessageInfo,
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
@@ -19,6 +19,7 @@
type MessageTruncationStatus,
messageTruncationStatus,
type FetchMessageInfosResult,
+ defaultMaxMessageAge,
} from 'lib/types/message-types';
import { threadPermissions } from 'lib/types/thread-types';
import { ServerError } from 'lib/utils/errors';
@@ -353,8 +354,19 @@
function messageSelectionCriteriaToSQLClause(
criteria: MessageSelectionCriteria,
) {
+ const minMessageTime = Date.now() - defaultMaxMessageAge;
+
+ let globalTimeFilter;
+ if (criteria.newerThan) {
+ globalTimeFilter = SQL`m.time > ${criteria.newerThan}`;
+ } else if (!criteria.threadCursors) {
+ globalTimeFilter = SQL`m.time > ${minMessageTime}`;
+ }
+
const threadConditions = [];
- if (criteria.joinedThreads === true) {
+ if (criteria.joinedThreads === true && !globalTimeFilter) {
+ threadConditions.push(SQL`(mm.role > 0 AND m.time > ${minMessageTime})`);
+ } else if (criteria.joinedThreads === true) {
threadConditions.push(SQL`mm.role > 0`);
}
if (criteria.threadCursors) {
@@ -374,10 +386,7 @@
}
const threadClause = mergeOrConditions(threadConditions);
- const conditions = [threadClause];
- if (criteria.newerThan) {
- conditions.push(SQL`m.time > ${criteria.newerThan}`);
- }
+ const conditions = [globalTimeFilter, threadClause].filter(Boolean);
return mergeAndConditions(conditions);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 8:09 AM (20 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5955324
Default Alt Text
D3349.1768810176.diff (1 KB)
Attached To
Mode
D3349: [server] Always filter message queries by message creation time
Attached
Detach File
Event Timeline
Log In to Comment