Skip to content

Commit e80e2ac

Browse files
committed
show reported state on archived stories
if there is nothing in the live comment actions for a user from a set of comment id's and the archive is available, use the archived comment actions to try and find their reported status for a comment.
1 parent dc018d5 commit e80e2ac

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

server/src/core/server/models/action/comment.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export async function retrieveManyUserActionPresence(
386386
}
387387
}
388388
} else {
389-
const cursor = mongo.commentActions().find(
389+
const liveCursor = mongo.commentActions().find(
390390
{
391391
tenantID,
392392
userID,
@@ -401,7 +401,26 @@ export async function retrieveManyUserActionPresence(
401401
}
402402
);
403403

404-
actions = await cursor.toArray();
404+
actions = await liveCursor.toArray();
405+
406+
if (actions.length === 0 && mongo.archive) {
407+
const archivedCursor = mongo.archivedCommentActions().find(
408+
{
409+
tenantID,
410+
userID,
411+
commentID: { $in: commentIDs },
412+
},
413+
{
414+
// We only need the commentID and actionType from the database.
415+
projection: {
416+
commentID: 1,
417+
actionType: 1,
418+
},
419+
}
420+
);
421+
422+
actions = await archivedCursor.toArray();
423+
}
405424
}
406425

407426
// For each of the actions returned by the query, group the actions by the

0 commit comments

Comments
 (0)