Skip to content

Commit

Permalink
chore: update message list query filter
Browse files Browse the repository at this point in the history
  • Loading branch information
aseerkt committed Aug 13, 2024
1 parent 2a3346f commit ad4d982
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions server/src/modules/messages/messages.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,14 @@ export const listMessages: RequestHandler = async (req, res, next) => {
cursorSelect: 'id',
orderBy: [desc(messagesTable.id)],
where: and(
groupId
? and(
eq(messagesTable.groupId, groupId),
isNull(messagesTable.receiverId),
)
: undefined,
groupId ? eq(messagesTable.groupId, groupId) : undefined,
partnerId
? and(
or(
eq(messagesTable.receiverId, partnerId),
? or(
eq(messagesTable.receiverId, partnerId),
and(
eq(messagesTable.senderId, partnerId),
isNull(messagesTable.groupId),
),
isNull(messagesTable.groupId),
)
: undefined,
cursor ? lt(messagesTable.id, cursor as number) : undefined,
Expand Down

0 comments on commit ad4d982

Please sign in to comment.