mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(api): ✨ Add initial Push Notifications support
This commit is contained in:
parent
acd2bcb469
commit
d096ab830c
21 changed files with 3301 additions and 3 deletions
14
drizzle/migrations/0040_good_nocturne.sql
Normal file
14
drizzle/migrations/0040_good_nocturne.sql
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
CREATE TABLE "PushSubscriptions" (
|
||||
"id" uuid PRIMARY KEY DEFAULT uuid_generate_v7() NOT NULL,
|
||||
"endpoint" text NOT NULL,
|
||||
"public_key" text NOT NULL,
|
||||
"auth_secret" text NOT NULL,
|
||||
"alerts" jsonb NOT NULL,
|
||||
"policy" text NOT NULL,
|
||||
"created_at" timestamp(3) DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp(3) DEFAULT now() NOT NULL,
|
||||
"tokenId" uuid NOT NULL,
|
||||
CONSTRAINT "PushSubscriptions_tokenId_unique" UNIQUE("tokenId")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "PushSubscriptions" ADD CONSTRAINT "PushSubscriptions_tokenId_Tokens_id_fk" FOREIGN KEY ("tokenId") REFERENCES "public"."Tokens"("id") ON DELETE cascade ON UPDATE cascade;
|
||||
2323
drizzle/migrations/meta/0040_snapshot.json
Normal file
2323
drizzle/migrations/meta/0040_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -281,6 +281,13 @@
|
|||
"when": 1734555117380,
|
||||
"tag": "0039_special_serpent_society",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 40,
|
||||
"version": "7",
|
||||
"when": 1735776034097,
|
||||
"tag": "0040_good_nocturne",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,49 @@ export const Emojis = pgTable("Emojis", {
|
|||
category: text("category"),
|
||||
});
|
||||
|
||||
export const PushSubscriptions = pgTable("PushSubscriptions", {
|
||||
id: id(),
|
||||
endpoint: text("endpoint").notNull(),
|
||||
publicKey: text("public_key").notNull(),
|
||||
authSecret: text("auth_secret").notNull(),
|
||||
alerts: jsonb("alerts").notNull().$type<
|
||||
Partial<{
|
||||
mention: boolean;
|
||||
favourite: boolean;
|
||||
reblog: boolean;
|
||||
follow: boolean;
|
||||
poll: boolean;
|
||||
follow_request: boolean;
|
||||
status: boolean;
|
||||
update: boolean;
|
||||
"admin.sign_up": boolean;
|
||||
"admin.report": boolean;
|
||||
}>
|
||||
>(),
|
||||
policy: text("policy")
|
||||
.notNull()
|
||||
.$type<"all" | "followed" | "follower" | "none">(),
|
||||
createdAt: createdAt(),
|
||||
updatedAt: updatedAt(),
|
||||
tokenId: uuid("tokenId")
|
||||
.references(() => Tokens.id, {
|
||||
onDelete: "cascade",
|
||||
onUpdate: "cascade",
|
||||
})
|
||||
.notNull()
|
||||
.unique(),
|
||||
});
|
||||
|
||||
export const PushSubscriptionsRelations = relations(
|
||||
PushSubscriptions,
|
||||
({ one }) => ({
|
||||
token: one(Tokens, {
|
||||
fields: [PushSubscriptions.tokenId],
|
||||
references: [Tokens.id],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
export const Reactions = pgTable("Reaction", {
|
||||
id: id(),
|
||||
uri: uri(),
|
||||
|
|
@ -548,6 +591,7 @@ export enum RolePermissions {
|
|||
ManageOwnFollows = "owner:follow",
|
||||
ManageOwnApps = "owner:app",
|
||||
Search = "search",
|
||||
UsePushNotifications = "push_notifications",
|
||||
ViewPublicTimelines = "public_timelines",
|
||||
ViewPrivateTimelines = "private_timelines",
|
||||
IgnoreRateLimits = "ignore_rate_limits",
|
||||
|
|
@ -583,6 +627,7 @@ export const DEFAULT_ROLES = [
|
|||
RolePermissions.ManageOwnFollows,
|
||||
RolePermissions.ManageOwnApps,
|
||||
RolePermissions.Search,
|
||||
RolePermissions.UsePushNotifications,
|
||||
RolePermissions.ViewPublicTimelines,
|
||||
RolePermissions.ViewPrivateTimelines,
|
||||
RolePermissions.OAuth,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue