Skip to content

Commit

Permalink
Update Notifications Read for Lists
Browse files Browse the repository at this point in the history
  • Loading branch information
casesandberg committed Sep 26, 2024
1 parent 5ac2129 commit 976f62a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/api/app/api/users/me/resource-viewed/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export async function POST(req: Request): Promise<SchemaResponse<typeof schema.p

if (resourceType === 'MARKET') {
await updateNotificationsRead({ userId: session.user.id, marketId: resourceId })
} else if (resourceType === 'LIST') {
await updateNotificationsRead({ userId: session.user.id, listId: resourceId })
}

return NextResponse.json({ success: true })
Expand Down
3 changes: 3 additions & 0 deletions packages/notifications/lib/updateNotificationsRead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import db from '@play-money/database'
export async function updateNotificationsRead({
userId,
marketId,
listId,
}: {
userId: string
marketId?: string
listId?: string
}): Promise<number> {
const now = new Date()

Expand All @@ -14,6 +16,7 @@ export async function updateNotificationsRead({
recipientId: userId,
readAt: null,
marketId: marketId,
listId: listId,
},
data: {
readAt: now,
Expand Down

0 comments on commit 976f62a

Please sign in to comment.