Something went wrong. Try again.
A decentralized music tracking and discovery platform built on AT Protocol ๐ต rocksky.app
spotify atproto lastfm musicbrainz scrobbling listenbrainz
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546import { type InferInsertModel, type InferSelectModel, sql } from "drizzle-orm";import { boolean, index, pgTable, text, timestamp } from "drizzle-orm/pg-core";import shouts from "./shouts";import users from "./users";
/** * A single notification row per event. `type` is one of: * - "like_scrobble" โ someone liked a song the recipient owns or loves * - "follow" โ someone followed the recipient * - "comment_scrobble" โ someone shouted about a song the recipient participates in * - "comment_profile" โ someone commented on the recipient's profile * - "reply" โ someone replied to the recipient's comment * - "react_comment" โ someone reacted to (liked) the recipient's comment * - "mention" โ someone @-mentioned the recipient in a shout * * `userId` is the recipient; `actorId` is the user who triggered the event. * `shoutId` / `subjectUri` point at the relevant record so the UI can deep-link. */const notifications = pgTable( "notifications", { id: text("xata_id").primaryKey().default(sql`xata_id()`), userId: text("user_id") .notNull() .references(() => users.id), actorId: text("actor_id") .notNull() .references(() => users.id), type: text("type").notNull(), shoutId: text("shout_id").references(() => shouts.id), subjectUri: text("subject_uri"), read: boolean("read").notNull().default(false), readAt: timestamp("read_at", { withTimezone: true }), createdAt: timestamp("xata_createdat").defaultNow().notNull(), }, (t) => [ index("notifications_user_id_read_idx").on(t.userId, t.read), index("notifications_user_id_createdat_idx").on(t.userId, t.createdAt), ],);
export type SelectNotification = InferSelectModel<typeof notifications>;export type InsertNotification = InferInsertModel<typeof notifications>;
export default notifications;