mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Create push_subscriptions table
This commit is contained in:
parent
141d5be999
commit
a10e810068
4 changed files with 29 additions and 7 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Nullable } from 'kysely';
|
||||
import { Generated, Nullable } from 'kysely';
|
||||
|
||||
import { NPostgresSchema } from '@nostrify/db';
|
||||
|
||||
|
|
@ -58,11 +58,11 @@ interface EventZapRow {
|
|||
}
|
||||
|
||||
interface PushSubscriptionRow {
|
||||
id: bigint;
|
||||
id: Generated<bigint>;
|
||||
pubkey: string;
|
||||
endpoint: string;
|
||||
key_p256dh: string;
|
||||
key_auth: string;
|
||||
p256dh: string;
|
||||
auth: string;
|
||||
data: {
|
||||
alerts?: {
|
||||
mention?: boolean;
|
||||
|
|
@ -78,6 +78,6 @@ interface PushSubscriptionRow {
|
|||
};
|
||||
policy?: 'all' | 'followed' | 'follower' | 'none';
|
||||
} | null;
|
||||
created_at: Date;
|
||||
updated_at: Date;
|
||||
created_at: Generated<Date>;
|
||||
updated_at: Generated<Date>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { Kysely, sql } from 'kysely';
|
|||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable('nip46_tokens')
|
||||
.addColumn('api_token', 'text', (col) => col.primaryKey().unique().notNull())
|
||||
.addColumn('api_token', 'text', (col) => col.primaryKey().notNull())
|
||||
.addColumn('user_pubkey', 'text', (col) => col.notNull())
|
||||
.addColumn('server_seckey', 'bytea', (col) => col.notNull())
|
||||
.addColumn('server_pubkey', 'text', (col) => col.notNull())
|
||||
|
|
|
|||
20
src/db/migrations/038_push_subscriptions.ts
Normal file
20
src/db/migrations/038_push_subscriptions.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable('push_subscriptions')
|
||||
.addColumn('id', 'bigint', (c) => c.primaryKey().autoIncrement())
|
||||
.addColumn('pubkey', 'char(64)', (c) => c.notNull())
|
||||
.addColumn('token', 'char(64)', (c) => c.notNull())
|
||||
.addColumn('endpoint', 'text', (c) => c.notNull())
|
||||
.addColumn('p256dh', 'text', (c) => c.notNull())
|
||||
.addColumn('auth', 'text', (c) => c.notNull())
|
||||
.addColumn('data', 'jsonb')
|
||||
.addColumn('created_at', 'timestamp', (c) => c.notNull().defaultTo(sql`CURRENT_TIMESTAMP`))
|
||||
.addColumn('updated_at', 'timestamp', (c) => c.notNull().defaultTo(sql`CURRENT_TIMESTAMP`))
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable('push_subscriptions').execute();
|
||||
}
|
||||
|
|
@ -230,6 +230,8 @@ async function streamOut(event: NostrEvent): Promise<void> {
|
|||
if (isFresh(event)) {
|
||||
const pubsub = await Storages.pubsub();
|
||||
await pubsub.event(event);
|
||||
|
||||
// TODO: Web Push
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue