Skip to content

Notifications · Repositories

0 modules · 0 exports · 1 repository · 1 e2e test · 4 routes

Every table a function queries, its own helpers included, read or written. Calls to other repositories are listed apart, their tables are on their own page.

NotificationRepository

app/features/notifications/NotificationRepository.server.ts
Tables
NotificationNotificationUserNotificationUserSubscriptionUser
Calls
no other repositories
Imports
no other modules
Used by
1 loader3 routes4 routines2 scripts4 other

Functions & values

function

insert

no JSDoc:13
export function insert(
	notification: Notification,
	users: Array<Omit<TablesInsertable["NotificationUser"], "notificationId">>,
)
function

findByUserId

no JSDoc:45
export function findByUserId(
	userId: number,
	{ limit }: { limit?: number } = {},
)
function

findAllByType

no JSDoc:72
export function findAllByType<T extends Notification["type"]>(type: T)
function

markAsSeenByType

:86

Marks the users' unseen notifications of the type (optionally only those whose meta matches every key/value) as seen, returning the user ids whose rows changed. The correlated exists keeps this proportional to the users' own notifications; notificationId in (select ...) makes SQLite materialize every notification of the type first, ~80x slower on a hot path.

export async function markAsSeenByType({
	userIds,
	type,
	meta,
}: {
	userIds: number[];
	type: Notification["type"];
	meta?: Record<string, number | string>;
}): Promise<number[]>
Unit tests (6)
function

findUserIdsWithUnseenByType

no JSDoc:128
export async function findUserIdsWithUnseenByType({
	userIds,
	type,
	meta,
}: {
	userIds: number[];
	type: Notification["type"];
	meta: Record<string, number | string>;
}): Promise<number[]>
function

markOwnAsSeen

:165

Marks the actor's notifications as seen. Returns [actorId] if any row changed, else [], shaped for ChatSystemMessage.notifyNotificationsChanged.

export async function markOwnAsSeen(notificationIds: number[])
Unit tests (4)
function

deleteOld

no JSDoc:178
export function deleteOld()
function

upsertOwnSubscription

:190

Saves the actor's push subscription, keeping only their {@link NOTIFICATIONS.MAX_PUSH_SUBSCRIPTIONS_PER_USER} most recent ones.

export function upsertOwnSubscription(subscription: NotificationSubscription)
Unit tests (6)
function

findUnseenSubscriptionsByNotificationId

:229

Push subscriptions of the notification's recipients who have not seen it yet, so the push sender skips users who addressed it during the grace period.

export function findUnseenSubscriptionsByNotificationId(
	notificationId: number,
)
Unit tests (4)
function

findAllSubscriptionsByUserIds

no JSDoc:251
export function findAllSubscriptionsByUserIds(userIds: number[])
function

deleteSubscriptionById

no JSDoc:259
export function deleteSubscriptionById(id: number)