diff --git a/database/entities/Status.ts b/database/entities/Status.ts index da7fcea6..b7401210 100644 --- a/database/entities/Status.ts +++ b/database/entities/Status.ts @@ -32,16 +32,16 @@ import { emojiToStatus, instance, type like, + notification, status, statusToMentions, user, - notification, } from "~drizzle/schema"; import { LogLevel } from "~packages/log-manager"; import type { Note } from "~types/lysand/Object"; import type { Attachment as APIAttachment } from "~types/mastodon/attachment"; import type { Status as APIStatus } from "~types/mastodon/status"; -import { applicationToAPI, type Application } from "./Application"; +import { type Application, applicationToAPI } from "./Application"; import { attachmentFromLysand, attachmentToAPI, diff --git a/database/entities/User.ts b/database/entities/User.ts index 79774088..5674532f 100644 --- a/database/entities/User.ts +++ b/database/entities/User.ts @@ -18,6 +18,7 @@ import { import { LogLevel } from "~packages/log-manager"; import type { Account as APIAccount } from "~types/mastodon/account"; import type { Source as APISource } from "~types/mastodon/source"; +import type { Application } from "./Application"; import { type EmojiWithInstance, emojiToAPI, @@ -28,7 +29,6 @@ import { objectToInboxRequest } from "./Federation"; import { addInstanceIfNotExists } from "./Instance"; import { createNewRelationship } from "./Relationship"; import type { Token } from "./Token"; -import type { Application } from "./Application"; export type User = InferSelectModel & { endpoints?: Partial<{ diff --git a/drizzle/0008_flawless_brother_voodoo.sql b/drizzle/0008_flawless_brother_voodoo.sql new file mode 100644 index 00000000..c704bdc8 --- /dev/null +++ b/drizzle/0008_flawless_brother_voodoo.sql @@ -0,0 +1 @@ +ALTER TABLE "Notification" ADD COLUMN "dismissed" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/drizzle/meta/0007_snapshot.json b/drizzle/meta/0007_snapshot.json index ae9d23bc..76ccbbe8 100644 --- a/drizzle/meta/0007_snapshot.json +++ b/drizzle/meta/0007_snapshot.json @@ -1,1753 +1,1575 @@ { - "id": "73c8df6a-c16d-4527-b959-46d6b32f56c6", - "prevId": "47f76353-0b58-4367-b273-8933b7c89e1f", - "version": "5", - "dialect": "pg", - "tables": { - "Application": { - "name": "Application", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" + "id": "73c8df6a-c16d-4527-b959-46d6b32f56c6", + "prevId": "47f76353-0b58-4367-b273-8933b7c89e1f", + "version": "5", + "dialect": "pg", + "tables": { + "Application": { + "name": "Application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "website": { + "name": "website", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vapid_key": { + "name": "vapid_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "redirect_uris": { + "name": "redirect_uris", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "Application_client_id_index": { + "name": "Application_client_id_index", + "columns": ["client_id"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true + "Attachment": { + "name": "Attachment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "remote_url": { + "name": "remote_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "thumbnail_url": { + "name": "thumbnail_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blurhash": { + "name": "blurhash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fps": { + "name": "fps", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "statusId": { + "name": "statusId", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Attachment_statusId_Status_id_fk": { + "name": "Attachment_statusId_Status_id_fk", + "tableFrom": "Attachment", + "tableTo": "Status", + "columnsFrom": ["statusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} }, - "website": { - "name": "website", - "type": "text", - "primaryKey": false, - "notNull": false + "Emoji": { + "name": "Emoji", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "shortcode": { + "name": "shortcode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visible_in_picker": { + "name": "visible_in_picker", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "alt": { + "name": "alt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "instanceId": { + "name": "instanceId", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Emoji_instanceId_Instance_id_fk": { + "name": "Emoji_instanceId_Instance_id_fk", + "tableFrom": "Emoji", + "tableTo": "Instance", + "columnsFrom": ["instanceId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} }, - "vapid_key": { - "name": "vapid_key", - "type": "text", - "primaryKey": false, - "notNull": false + "EmojiToStatus": { + "name": "EmojiToStatus", + "schema": "", + "columns": { + "emojiId": { + "name": "emojiId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "statusId": { + "name": "statusId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "EmojiToStatus_emojiId_statusId_index": { + "name": "EmojiToStatus_emojiId_statusId_index", + "columns": ["emojiId", "statusId"], + "isUnique": true + }, + "EmojiToStatus_statusId_index": { + "name": "EmojiToStatus_statusId_index", + "columns": ["statusId"], + "isUnique": false + } + }, + "foreignKeys": { + "EmojiToStatus_emojiId_Emoji_id_fk": { + "name": "EmojiToStatus_emojiId_Emoji_id_fk", + "tableFrom": "EmojiToStatus", + "tableTo": "Emoji", + "columnsFrom": ["emojiId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "EmojiToStatus_statusId_Status_id_fk": { + "name": "EmojiToStatus_statusId_Status_id_fk", + "tableFrom": "EmojiToStatus", + "tableTo": "Status", + "columnsFrom": ["statusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} }, - "client_id": { - "name": "client_id", - "type": "text", - "primaryKey": false, - "notNull": true + "EmojiToUser": { + "name": "EmojiToUser", + "schema": "", + "columns": { + "emojiId": { + "name": "emojiId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "EmojiToUser_emojiId_userId_index": { + "name": "EmojiToUser_emojiId_userId_index", + "columns": ["emojiId", "userId"], + "isUnique": true + }, + "EmojiToUser_userId_index": { + "name": "EmojiToUser_userId_index", + "columns": ["userId"], + "isUnique": false + } + }, + "foreignKeys": { + "EmojiToUser_emojiId_Emoji_id_fk": { + "name": "EmojiToUser_emojiId_Emoji_id_fk", + "tableFrom": "EmojiToUser", + "tableTo": "Emoji", + "columnsFrom": ["emojiId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "EmojiToUser_userId_User_id_fk": { + "name": "EmojiToUser_userId_User_id_fk", + "tableFrom": "EmojiToUser", + "tableTo": "User", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} }, - "secret": { - "name": "secret", - "type": "text", - "primaryKey": false, - "notNull": true + "Flag": { + "name": "Flag", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "flag_type": { + "name": "flag_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'other'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "flaggeStatusId": { + "name": "flaggeStatusId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "flaggedUserId": { + "name": "flaggedUserId", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Flag_flaggeStatusId_Status_id_fk": { + "name": "Flag_flaggeStatusId_Status_id_fk", + "tableFrom": "Flag", + "tableTo": "Status", + "columnsFrom": ["flaggeStatusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Flag_flaggedUserId_User_id_fk": { + "name": "Flag_flaggedUserId_User_id_fk", + "tableFrom": "Flag", + "tableTo": "User", + "columnsFrom": ["flaggedUserId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} }, - "scopes": { - "name": "scopes", - "type": "text", - "primaryKey": false, - "notNull": true + "Instance": { + "name": "Instance", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "disable_automoderation": { + "name": "disable_automoderation", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} }, - "redirect_uris": { - "name": "redirect_uris", - "type": "text", - "primaryKey": false, - "notNull": true + "Like": { + "name": "Like", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "likerId": { + "name": "likerId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "likedId": { + "name": "likedId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "Like_likerId_User_id_fk": { + "name": "Like_likerId_User_id_fk", + "tableFrom": "Like", + "tableTo": "User", + "columnsFrom": ["likerId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Like_likedId_Status_id_fk": { + "name": "Like_likedId_Status_id_fk", + "tableFrom": "Like", + "tableTo": "Status", + "columnsFrom": ["likedId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "LysandObject": { + "name": "LysandObject", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "remote_id": { + "name": "remote_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "authorId": { + "name": "authorId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "extra_data": { + "name": "extra_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "extensions": { + "name": "extensions", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "LysandObject_remote_id_index": { + "name": "LysandObject_remote_id_index", + "columns": ["remote_id"], + "isUnique": true + }, + "LysandObject_uri_index": { + "name": "LysandObject_uri_index", + "columns": ["uri"], + "isUnique": true + } + }, + "foreignKeys": { + "LysandObject_authorId_LysandObject_id_fk": { + "name": "LysandObject_authorId_LysandObject_id_fk", + "tableFrom": "LysandObject", + "tableTo": "LysandObject", + "columnsFrom": ["authorId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "ModNote": { + "name": "ModNote", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "notedStatusId": { + "name": "notedStatusId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notedUserId": { + "name": "notedUserId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "modId": { + "name": "modId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "ModNote_notedStatusId_Status_id_fk": { + "name": "ModNote_notedStatusId_Status_id_fk", + "tableFrom": "ModNote", + "tableTo": "Status", + "columnsFrom": ["notedStatusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModNote_notedUserId_User_id_fk": { + "name": "ModNote_notedUserId_User_id_fk", + "tableFrom": "ModNote", + "tableTo": "User", + "columnsFrom": ["notedUserId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModNote_modId_User_id_fk": { + "name": "ModNote_modId_User_id_fk", + "tableFrom": "ModNote", + "tableTo": "User", + "columnsFrom": ["modId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "ModTag": { + "name": "ModTag", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "taggedStatusId": { + "name": "taggedStatusId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "taggedUserId": { + "name": "taggedUserId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "modId": { + "name": "modId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "ModTag_taggedStatusId_Status_id_fk": { + "name": "ModTag_taggedStatusId_Status_id_fk", + "tableFrom": "ModTag", + "tableTo": "Status", + "columnsFrom": ["taggedStatusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModTag_taggedUserId_User_id_fk": { + "name": "ModTag_taggedUserId_User_id_fk", + "tableFrom": "ModTag", + "tableTo": "User", + "columnsFrom": ["taggedUserId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModTag_modId_User_id_fk": { + "name": "ModTag_modId_User_id_fk", + "tableFrom": "ModTag", + "tableTo": "User", + "columnsFrom": ["modId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Notification": { + "name": "Notification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "notifiedId": { + "name": "notifiedId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "accountId": { + "name": "accountId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "statusId": { + "name": "statusId", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Notification_notifiedId_User_id_fk": { + "name": "Notification_notifiedId_User_id_fk", + "tableFrom": "Notification", + "tableTo": "User", + "columnsFrom": ["notifiedId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notification_accountId_User_id_fk": { + "name": "Notification_accountId_User_id_fk", + "tableFrom": "Notification", + "tableTo": "User", + "columnsFrom": ["accountId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notification_statusId_Status_id_fk": { + "name": "Notification_statusId_Status_id_fk", + "tableFrom": "Notification", + "tableTo": "Status", + "columnsFrom": ["statusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "OpenIdAccount": { + "name": "OpenIdAccount", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "server_id": { + "name": "server_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issuer_id": { + "name": "issuer_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "OpenIdAccount_userId_User_id_fk": { + "name": "OpenIdAccount_userId_User_id_fk", + "tableFrom": "OpenIdAccount", + "tableTo": "User", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "OpenIdLoginFlow": { + "name": "OpenIdLoginFlow", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "code_verifier": { + "name": "code_verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "applicationId": { + "name": "applicationId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "issuer_id": { + "name": "issuer_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "OpenIdLoginFlow_applicationId_Application_id_fk": { + "name": "OpenIdLoginFlow_applicationId_Application_id_fk", + "tableFrom": "OpenIdLoginFlow", + "tableTo": "Application", + "columnsFrom": ["applicationId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Relationship": { + "name": "Relationship", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "ownerId": { + "name": "ownerId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subjectId": { + "name": "subjectId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "following": { + "name": "following", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "showing_reblogs": { + "name": "showing_reblogs", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "notifying": { + "name": "notifying", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "followed_by": { + "name": "followed_by", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "blocking": { + "name": "blocking", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "blocked_by": { + "name": "blocked_by", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "muting": { + "name": "muting", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "muting_notifications": { + "name": "muting_notifications", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "requested": { + "name": "requested", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "domain_blocking": { + "name": "domain_blocking", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "endorsed": { + "name": "endorsed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "languages": { + "name": "languages", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "Relationship_ownerId_User_id_fk": { + "name": "Relationship_ownerId_User_id_fk", + "tableFrom": "Relationship", + "tableTo": "User", + "columnsFrom": ["ownerId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Relationship_subjectId_User_id_fk": { + "name": "Relationship_subjectId_User_id_fk", + "tableFrom": "Relationship", + "tableTo": "User", + "columnsFrom": ["subjectId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Status": { + "name": "Status", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "authorId": { + "name": "authorId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reblogId": { + "name": "reblogId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text/plain'" + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "inReplyToPostId": { + "name": "inReplyToPostId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quotingPostId": { + "name": "quotingPostId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sensitive": { + "name": "sensitive", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "spoiler_text": { + "name": "spoiler_text", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "applicationId": { + "name": "applicationId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "content_source": { + "name": "content_source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + } + }, + "indexes": { + "Status_uri_index": { + "name": "Status_uri_index", + "columns": ["uri"], + "isUnique": true + } + }, + "foreignKeys": { + "Status_authorId_User_id_fk": { + "name": "Status_authorId_User_id_fk", + "tableFrom": "Status", + "tableTo": "User", + "columnsFrom": ["authorId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Status_applicationId_Application_id_fk": { + "name": "Status_applicationId_Application_id_fk", + "tableFrom": "Status", + "tableTo": "Application", + "columnsFrom": ["applicationId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "cascade" + }, + "Status_reblogId_Status_id_fk": { + "name": "Status_reblogId_Status_id_fk", + "tableFrom": "Status", + "tableTo": "Status", + "columnsFrom": ["reblogId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Status_inReplyToPostId_Status_id_fk": { + "name": "Status_inReplyToPostId_Status_id_fk", + "tableFrom": "Status", + "tableTo": "Status", + "columnsFrom": ["inReplyToPostId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "cascade" + }, + "Status_quotingPostId_Status_id_fk": { + "name": "Status_quotingPostId_Status_id_fk", + "tableFrom": "Status", + "tableTo": "Status", + "columnsFrom": ["quotingPostId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "StatusToMentions": { + "name": "StatusToMentions", + "schema": "", + "columns": { + "statusId": { + "name": "statusId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "StatusToMentions_statusId_userId_index": { + "name": "StatusToMentions_statusId_userId_index", + "columns": ["statusId", "userId"], + "isUnique": true + }, + "StatusToMentions_userId_index": { + "name": "StatusToMentions_userId_index", + "columns": ["userId"], + "isUnique": false + } + }, + "foreignKeys": { + "StatusToMentions_statusId_Status_id_fk": { + "name": "StatusToMentions_statusId_Status_id_fk", + "tableFrom": "StatusToMentions", + "tableTo": "Status", + "columnsFrom": ["statusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "StatusToMentions_userId_User_id_fk": { + "name": "StatusToMentions_userId_User_id_fk", + "tableFrom": "StatusToMentions", + "tableTo": "User", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Token": { + "name": "Token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "token_type": { + "name": "token_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "applicationId": { + "name": "applicationId", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Token_userId_User_id_fk": { + "name": "Token_userId_User_id_fk", + "tableFrom": "Token", + "tableTo": "User", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Token_applicationId_Application_id_fk": { + "name": "Token_applicationId_Application_id_fk", + "tableFrom": "Token", + "tableTo": "Application", + "columnsFrom": ["applicationId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "User": { + "name": "User", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "is_admin": { + "name": "is_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "endpoints": { + "name": "endpoints", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "avatar": { + "name": "avatar", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "header": { + "name": "header", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "is_bot": { + "name": "is_bot", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_locked": { + "name": "is_locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_discoverable": { + "name": "is_discoverable", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sanctions": { + "name": "sanctions", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "private_key": { + "name": "private_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "instanceId": { + "name": "instanceId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "disable_automoderation": { + "name": "disable_automoderation", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "User_uri_index": { + "name": "User_uri_index", + "columns": ["uri"], + "isUnique": true + }, + "User_username_index": { + "name": "User_username_index", + "columns": ["username"], + "isUnique": true + }, + "User_email_index": { + "name": "User_email_index", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": { + "User_instanceId_Instance_id_fk": { + "name": "User_instanceId_Instance_id_fk", + "tableFrom": "User", + "tableTo": "Instance", + "columnsFrom": ["instanceId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "UserToPinnedNotes": { + "name": "UserToPinnedNotes", + "schema": "", + "columns": { + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "statusId": { + "name": "statusId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "UserToPinnedNotes_userId_statusId_index": { + "name": "UserToPinnedNotes_userId_statusId_index", + "columns": ["userId", "statusId"], + "isUnique": true + }, + "UserToPinnedNotes_statusId_index": { + "name": "UserToPinnedNotes_statusId_index", + "columns": ["statusId"], + "isUnique": false + } + }, + "foreignKeys": { + "UserToPinnedNotes_userId_Status_id_fk": { + "name": "UserToPinnedNotes_userId_Status_id_fk", + "tableFrom": "UserToPinnedNotes", + "tableTo": "Status", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "UserToPinnedNotes_statusId_User_id_fk": { + "name": "UserToPinnedNotes_statusId_User_id_fk", + "tableFrom": "UserToPinnedNotes", + "tableTo": "User", + "columnsFrom": ["statusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} } - }, - "indexes": { - "Application_client_id_index": { - "name": "Application_client_id_index", - "columns": [ - "client_id" - ], - "isUnique": true - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} }, - "Attachment": { - "name": "Attachment", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "url": { - "name": "url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remote_url": { - "name": "remote_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "thumbnail_url": { - "name": "thumbnail_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "blurhash": { - "name": "blurhash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sha256": { - "name": "sha256", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "fps": { - "name": "fps", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "duration": { - "name": "duration", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "width": { - "name": "width", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "height": { - "name": "height", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "size": { - "name": "size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "statusId": { - "name": "statusId", - "type": "uuid", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "Attachment_statusId_Status_id_fk": { - "name": "Attachment_statusId_Status_id_fk", - "tableFrom": "Attachment", - "tableTo": "Status", - "columnsFrom": [ - "statusId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "Emoji": { - "name": "Emoji", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "shortcode": { - "name": "shortcode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "url": { - "name": "url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "visible_in_picker": { - "name": "visible_in_picker", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "alt": { - "name": "alt", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "content_type": { - "name": "content_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "instanceId": { - "name": "instanceId", - "type": "uuid", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "Emoji_instanceId_Instance_id_fk": { - "name": "Emoji_instanceId_Instance_id_fk", - "tableFrom": "Emoji", - "tableTo": "Instance", - "columnsFrom": [ - "instanceId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "EmojiToStatus": { - "name": "EmojiToStatus", - "schema": "", - "columns": { - "emojiId": { - "name": "emojiId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "statusId": { - "name": "statusId", - "type": "uuid", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "EmojiToStatus_emojiId_statusId_index": { - "name": "EmojiToStatus_emojiId_statusId_index", - "columns": [ - "emojiId", - "statusId" - ], - "isUnique": true - }, - "EmojiToStatus_statusId_index": { - "name": "EmojiToStatus_statusId_index", - "columns": [ - "statusId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "EmojiToStatus_emojiId_Emoji_id_fk": { - "name": "EmojiToStatus_emojiId_Emoji_id_fk", - "tableFrom": "EmojiToStatus", - "tableTo": "Emoji", - "columnsFrom": [ - "emojiId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "EmojiToStatus_statusId_Status_id_fk": { - "name": "EmojiToStatus_statusId_Status_id_fk", - "tableFrom": "EmojiToStatus", - "tableTo": "Status", - "columnsFrom": [ - "statusId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "EmojiToUser": { - "name": "EmojiToUser", - "schema": "", - "columns": { - "emojiId": { - "name": "emojiId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "uuid", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "EmojiToUser_emojiId_userId_index": { - "name": "EmojiToUser_emojiId_userId_index", - "columns": [ - "emojiId", - "userId" - ], - "isUnique": true - }, - "EmojiToUser_userId_index": { - "name": "EmojiToUser_userId_index", - "columns": [ - "userId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "EmojiToUser_emojiId_Emoji_id_fk": { - "name": "EmojiToUser_emojiId_Emoji_id_fk", - "tableFrom": "EmojiToUser", - "tableTo": "Emoji", - "columnsFrom": [ - "emojiId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "EmojiToUser_userId_User_id_fk": { - "name": "EmojiToUser_userId_User_id_fk", - "tableFrom": "EmojiToUser", - "tableTo": "User", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "Flag": { - "name": "Flag", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "flag_type": { - "name": "flag_type", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'other'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "flaggeStatusId": { - "name": "flaggeStatusId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "flaggedUserId": { - "name": "flaggedUserId", - "type": "uuid", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "Flag_flaggeStatusId_Status_id_fk": { - "name": "Flag_flaggeStatusId_Status_id_fk", - "tableFrom": "Flag", - "tableTo": "Status", - "columnsFrom": [ - "flaggeStatusId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "Flag_flaggedUserId_User_id_fk": { - "name": "Flag_flaggedUserId_User_id_fk", - "tableFrom": "Flag", - "tableTo": "User", - "columnsFrom": [ - "flaggedUserId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "Instance": { - "name": "Instance", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "base_url": { - "name": "base_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "version": { - "name": "version", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "logo": { - "name": "logo", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "disable_automoderation": { - "name": "disable_automoderation", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "Like": { - "name": "Like", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "likerId": { - "name": "likerId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "likedId": { - "name": "likedId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "Like_likerId_User_id_fk": { - "name": "Like_likerId_User_id_fk", - "tableFrom": "Like", - "tableTo": "User", - "columnsFrom": [ - "likerId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "Like_likedId_Status_id_fk": { - "name": "Like_likedId_Status_id_fk", - "tableFrom": "Like", - "tableTo": "Status", - "columnsFrom": [ - "likedId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "LysandObject": { - "name": "LysandObject", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "remote_id": { - "name": "remote_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "uri": { - "name": "uri", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "authorId": { - "name": "authorId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "extra_data": { - "name": "extra_data", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "extensions": { - "name": "extensions", - "type": "jsonb", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "LysandObject_remote_id_index": { - "name": "LysandObject_remote_id_index", - "columns": [ - "remote_id" - ], - "isUnique": true - }, - "LysandObject_uri_index": { - "name": "LysandObject_uri_index", - "columns": [ - "uri" - ], - "isUnique": true - } - }, - "foreignKeys": { - "LysandObject_authorId_LysandObject_id_fk": { - "name": "LysandObject_authorId_LysandObject_id_fk", - "tableFrom": "LysandObject", - "tableTo": "LysandObject", - "columnsFrom": [ - "authorId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "ModNote": { - "name": "ModNote", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "notedStatusId": { - "name": "notedStatusId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "notedUserId": { - "name": "notedUserId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "modId": { - "name": "modId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "ModNote_notedStatusId_Status_id_fk": { - "name": "ModNote_notedStatusId_Status_id_fk", - "tableFrom": "ModNote", - "tableTo": "Status", - "columnsFrom": [ - "notedStatusId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "ModNote_notedUserId_User_id_fk": { - "name": "ModNote_notedUserId_User_id_fk", - "tableFrom": "ModNote", - "tableTo": "User", - "columnsFrom": [ - "notedUserId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "ModNote_modId_User_id_fk": { - "name": "ModNote_modId_User_id_fk", - "tableFrom": "ModNote", - "tableTo": "User", - "columnsFrom": [ - "modId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "ModTag": { - "name": "ModTag", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "taggedStatusId": { - "name": "taggedStatusId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "taggedUserId": { - "name": "taggedUserId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "modId": { - "name": "modId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "tag": { - "name": "tag", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "ModTag_taggedStatusId_Status_id_fk": { - "name": "ModTag_taggedStatusId_Status_id_fk", - "tableFrom": "ModTag", - "tableTo": "Status", - "columnsFrom": [ - "taggedStatusId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "ModTag_taggedUserId_User_id_fk": { - "name": "ModTag_taggedUserId_User_id_fk", - "tableFrom": "ModTag", - "tableTo": "User", - "columnsFrom": [ - "taggedUserId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "ModTag_modId_User_id_fk": { - "name": "ModTag_modId_User_id_fk", - "tableFrom": "ModTag", - "tableTo": "User", - "columnsFrom": [ - "modId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "Notification": { - "name": "Notification", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "type": { - "name": "type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "notifiedId": { - "name": "notifiedId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "accountId": { - "name": "accountId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "statusId": { - "name": "statusId", - "type": "uuid", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "Notification_notifiedId_User_id_fk": { - "name": "Notification_notifiedId_User_id_fk", - "tableFrom": "Notification", - "tableTo": "User", - "columnsFrom": [ - "notifiedId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "Notification_accountId_User_id_fk": { - "name": "Notification_accountId_User_id_fk", - "tableFrom": "Notification", - "tableTo": "User", - "columnsFrom": [ - "accountId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "Notification_statusId_Status_id_fk": { - "name": "Notification_statusId_Status_id_fk", - "tableFrom": "Notification", - "tableTo": "Status", - "columnsFrom": [ - "statusId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "OpenIdAccount": { - "name": "OpenIdAccount", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "userId": { - "name": "userId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "server_id": { - "name": "server_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "issuer_id": { - "name": "issuer_id", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "OpenIdAccount_userId_User_id_fk": { - "name": "OpenIdAccount_userId_User_id_fk", - "tableFrom": "OpenIdAccount", - "tableTo": "User", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "OpenIdLoginFlow": { - "name": "OpenIdLoginFlow", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "code_verifier": { - "name": "code_verifier", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "applicationId": { - "name": "applicationId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "issuer_id": { - "name": "issuer_id", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "OpenIdLoginFlow_applicationId_Application_id_fk": { - "name": "OpenIdLoginFlow_applicationId_Application_id_fk", - "tableFrom": "OpenIdLoginFlow", - "tableTo": "Application", - "columnsFrom": [ - "applicationId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "Relationship": { - "name": "Relationship", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "ownerId": { - "name": "ownerId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "subjectId": { - "name": "subjectId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "following": { - "name": "following", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "showing_reblogs": { - "name": "showing_reblogs", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "notifying": { - "name": "notifying", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "followed_by": { - "name": "followed_by", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "blocking": { - "name": "blocking", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "blocked_by": { - "name": "blocked_by", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "muting": { - "name": "muting", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "muting_notifications": { - "name": "muting_notifications", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "requested": { - "name": "requested", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "domain_blocking": { - "name": "domain_blocking", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "endorsed": { - "name": "endorsed", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "languages": { - "name": "languages", - "type": "text[]", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "Relationship_ownerId_User_id_fk": { - "name": "Relationship_ownerId_User_id_fk", - "tableFrom": "Relationship", - "tableTo": "User", - "columnsFrom": [ - "ownerId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "Relationship_subjectId_User_id_fk": { - "name": "Relationship_subjectId_User_id_fk", - "tableFrom": "Relationship", - "tableTo": "User", - "columnsFrom": [ - "subjectId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "Status": { - "name": "Status", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "uri": { - "name": "uri", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "authorId": { - "name": "authorId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "createdAt": { - "name": "createdAt", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updatedAt": { - "name": "updatedAt", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "reblogId": { - "name": "reblogId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "content_type": { - "name": "content_type", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'text/plain'" - }, - "visibility": { - "name": "visibility", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "inReplyToPostId": { - "name": "inReplyToPostId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "quotingPostId": { - "name": "quotingPostId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "sensitive": { - "name": "sensitive", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "spoiler_text": { - "name": "spoiler_text", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "applicationId": { - "name": "applicationId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "content_source": { - "name": "content_source", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - } - }, - "indexes": { - "Status_uri_index": { - "name": "Status_uri_index", - "columns": [ - "uri" - ], - "isUnique": true - } - }, - "foreignKeys": { - "Status_authorId_User_id_fk": { - "name": "Status_authorId_User_id_fk", - "tableFrom": "Status", - "tableTo": "User", - "columnsFrom": [ - "authorId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "Status_applicationId_Application_id_fk": { - "name": "Status_applicationId_Application_id_fk", - "tableFrom": "Status", - "tableTo": "Application", - "columnsFrom": [ - "applicationId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "cascade" - }, - "Status_reblogId_Status_id_fk": { - "name": "Status_reblogId_Status_id_fk", - "tableFrom": "Status", - "tableTo": "Status", - "columnsFrom": [ - "reblogId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "Status_inReplyToPostId_Status_id_fk": { - "name": "Status_inReplyToPostId_Status_id_fk", - "tableFrom": "Status", - "tableTo": "Status", - "columnsFrom": [ - "inReplyToPostId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "cascade" - }, - "Status_quotingPostId_Status_id_fk": { - "name": "Status_quotingPostId_Status_id_fk", - "tableFrom": "Status", - "tableTo": "Status", - "columnsFrom": [ - "quotingPostId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "StatusToMentions": { - "name": "StatusToMentions", - "schema": "", - "columns": { - "statusId": { - "name": "statusId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "uuid", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "StatusToMentions_statusId_userId_index": { - "name": "StatusToMentions_statusId_userId_index", - "columns": [ - "statusId", - "userId" - ], - "isUnique": true - }, - "StatusToMentions_userId_index": { - "name": "StatusToMentions_userId_index", - "columns": [ - "userId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "StatusToMentions_statusId_Status_id_fk": { - "name": "StatusToMentions_statusId_Status_id_fk", - "tableFrom": "StatusToMentions", - "tableTo": "Status", - "columnsFrom": [ - "statusId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "StatusToMentions_userId_User_id_fk": { - "name": "StatusToMentions_userId_User_id_fk", - "tableFrom": "StatusToMentions", - "tableTo": "User", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "Token": { - "name": "Token", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "token_type": { - "name": "token_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scope": { - "name": "scope", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "access_token": { - "name": "access_token", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "userId": { - "name": "userId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "applicationId": { - "name": "applicationId", - "type": "uuid", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "Token_userId_User_id_fk": { - "name": "Token_userId_User_id_fk", - "tableFrom": "Token", - "tableTo": "User", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "Token_applicationId_Application_id_fk": { - "name": "Token_applicationId_Application_id_fk", - "tableFrom": "Token", - "tableTo": "Application", - "columnsFrom": [ - "applicationId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "User": { - "name": "User", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "uuid_generate_v7()" - }, - "uri": { - "name": "uri", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "username": { - "name": "username", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "note": { - "name": "note", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "is_admin": { - "name": "is_admin", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "endpoints": { - "name": "endpoints", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "avatar": { - "name": "avatar", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "header": { - "name": "header", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp(3)", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_bot": { - "name": "is_bot", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_locked": { - "name": "is_locked", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_discoverable": { - "name": "is_discoverable", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "sanctions": { - "name": "sanctions", - "type": "text[]", - "primaryKey": false, - "notNull": false - }, - "public_key": { - "name": "public_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "private_key": { - "name": "private_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "instanceId": { - "name": "instanceId", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disable_automoderation": { - "name": "disable_automoderation", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - } - }, - "indexes": { - "User_uri_index": { - "name": "User_uri_index", - "columns": [ - "uri" - ], - "isUnique": true - }, - "User_username_index": { - "name": "User_username_index", - "columns": [ - "username" - ], - "isUnique": true - }, - "User_email_index": { - "name": "User_email_index", - "columns": [ - "email" - ], - "isUnique": true - } - }, - "foreignKeys": { - "User_instanceId_Instance_id_fk": { - "name": "User_instanceId_Instance_id_fk", - "tableFrom": "User", - "tableTo": "Instance", - "columnsFrom": [ - "instanceId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "UserToPinnedNotes": { - "name": "UserToPinnedNotes", - "schema": "", - "columns": { - "userId": { - "name": "userId", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "statusId": { - "name": "statusId", - "type": "uuid", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "UserToPinnedNotes_userId_statusId_index": { - "name": "UserToPinnedNotes_userId_statusId_index", - "columns": [ - "userId", - "statusId" - ], - "isUnique": true - }, - "UserToPinnedNotes_statusId_index": { - "name": "UserToPinnedNotes_statusId_index", - "columns": [ - "statusId" - ], - "isUnique": false - } - }, - "foreignKeys": { - "UserToPinnedNotes_userId_Status_id_fk": { - "name": "UserToPinnedNotes_userId_Status_id_fk", - "tableFrom": "UserToPinnedNotes", - "tableTo": "Status", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - }, - "UserToPinnedNotes_statusId_User_id_fk": { - "name": "UserToPinnedNotes_statusId_User_id_fk", - "tableFrom": "UserToPinnedNotes", - "tableTo": "User", - "columnsFrom": [ - "statusId" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "cascade" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "schemas": {}, - "_meta": { - "columns": {}, + "enums": {}, "schemas": {}, - "tables": {} - } -} \ No newline at end of file + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/drizzle/meta/0008_snapshot.json b/drizzle/meta/0008_snapshot.json new file mode 100644 index 00000000..018e1f9f --- /dev/null +++ b/drizzle/meta/0008_snapshot.json @@ -0,0 +1,1582 @@ +{ + "id": "146b3c00-8c0f-4dec-8ce7-36f91a2fc445", + "prevId": "73c8df6a-c16d-4527-b959-46d6b32f56c6", + "version": "5", + "dialect": "pg", + "tables": { + "Application": { + "name": "Application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "website": { + "name": "website", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vapid_key": { + "name": "vapid_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "redirect_uris": { + "name": "redirect_uris", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "Application_client_id_index": { + "name": "Application_client_id_index", + "columns": ["client_id"], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Attachment": { + "name": "Attachment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "remote_url": { + "name": "remote_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "thumbnail_url": { + "name": "thumbnail_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blurhash": { + "name": "blurhash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fps": { + "name": "fps", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "statusId": { + "name": "statusId", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Attachment_statusId_Status_id_fk": { + "name": "Attachment_statusId_Status_id_fk", + "tableFrom": "Attachment", + "tableTo": "Status", + "columnsFrom": ["statusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Emoji": { + "name": "Emoji", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "shortcode": { + "name": "shortcode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visible_in_picker": { + "name": "visible_in_picker", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "alt": { + "name": "alt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "instanceId": { + "name": "instanceId", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Emoji_instanceId_Instance_id_fk": { + "name": "Emoji_instanceId_Instance_id_fk", + "tableFrom": "Emoji", + "tableTo": "Instance", + "columnsFrom": ["instanceId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "EmojiToStatus": { + "name": "EmojiToStatus", + "schema": "", + "columns": { + "emojiId": { + "name": "emojiId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "statusId": { + "name": "statusId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "EmojiToStatus_emojiId_statusId_index": { + "name": "EmojiToStatus_emojiId_statusId_index", + "columns": ["emojiId", "statusId"], + "isUnique": true + }, + "EmojiToStatus_statusId_index": { + "name": "EmojiToStatus_statusId_index", + "columns": ["statusId"], + "isUnique": false + } + }, + "foreignKeys": { + "EmojiToStatus_emojiId_Emoji_id_fk": { + "name": "EmojiToStatus_emojiId_Emoji_id_fk", + "tableFrom": "EmojiToStatus", + "tableTo": "Emoji", + "columnsFrom": ["emojiId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "EmojiToStatus_statusId_Status_id_fk": { + "name": "EmojiToStatus_statusId_Status_id_fk", + "tableFrom": "EmojiToStatus", + "tableTo": "Status", + "columnsFrom": ["statusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "EmojiToUser": { + "name": "EmojiToUser", + "schema": "", + "columns": { + "emojiId": { + "name": "emojiId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "EmojiToUser_emojiId_userId_index": { + "name": "EmojiToUser_emojiId_userId_index", + "columns": ["emojiId", "userId"], + "isUnique": true + }, + "EmojiToUser_userId_index": { + "name": "EmojiToUser_userId_index", + "columns": ["userId"], + "isUnique": false + } + }, + "foreignKeys": { + "EmojiToUser_emojiId_Emoji_id_fk": { + "name": "EmojiToUser_emojiId_Emoji_id_fk", + "tableFrom": "EmojiToUser", + "tableTo": "Emoji", + "columnsFrom": ["emojiId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "EmojiToUser_userId_User_id_fk": { + "name": "EmojiToUser_userId_User_id_fk", + "tableFrom": "EmojiToUser", + "tableTo": "User", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Flag": { + "name": "Flag", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "flag_type": { + "name": "flag_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'other'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "flaggeStatusId": { + "name": "flaggeStatusId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "flaggedUserId": { + "name": "flaggedUserId", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Flag_flaggeStatusId_Status_id_fk": { + "name": "Flag_flaggeStatusId_Status_id_fk", + "tableFrom": "Flag", + "tableTo": "Status", + "columnsFrom": ["flaggeStatusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Flag_flaggedUserId_User_id_fk": { + "name": "Flag_flaggedUserId_User_id_fk", + "tableFrom": "Flag", + "tableTo": "User", + "columnsFrom": ["flaggedUserId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Instance": { + "name": "Instance", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "disable_automoderation": { + "name": "disable_automoderation", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Like": { + "name": "Like", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "likerId": { + "name": "likerId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "likedId": { + "name": "likedId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "Like_likerId_User_id_fk": { + "name": "Like_likerId_User_id_fk", + "tableFrom": "Like", + "tableTo": "User", + "columnsFrom": ["likerId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Like_likedId_Status_id_fk": { + "name": "Like_likedId_Status_id_fk", + "tableFrom": "Like", + "tableTo": "Status", + "columnsFrom": ["likedId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "LysandObject": { + "name": "LysandObject", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "remote_id": { + "name": "remote_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "authorId": { + "name": "authorId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "extra_data": { + "name": "extra_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "extensions": { + "name": "extensions", + "type": "jsonb", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "LysandObject_remote_id_index": { + "name": "LysandObject_remote_id_index", + "columns": ["remote_id"], + "isUnique": true + }, + "LysandObject_uri_index": { + "name": "LysandObject_uri_index", + "columns": ["uri"], + "isUnique": true + } + }, + "foreignKeys": { + "LysandObject_authorId_LysandObject_id_fk": { + "name": "LysandObject_authorId_LysandObject_id_fk", + "tableFrom": "LysandObject", + "tableTo": "LysandObject", + "columnsFrom": ["authorId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "ModNote": { + "name": "ModNote", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "notedStatusId": { + "name": "notedStatusId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notedUserId": { + "name": "notedUserId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "modId": { + "name": "modId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "ModNote_notedStatusId_Status_id_fk": { + "name": "ModNote_notedStatusId_Status_id_fk", + "tableFrom": "ModNote", + "tableTo": "Status", + "columnsFrom": ["notedStatusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModNote_notedUserId_User_id_fk": { + "name": "ModNote_notedUserId_User_id_fk", + "tableFrom": "ModNote", + "tableTo": "User", + "columnsFrom": ["notedUserId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModNote_modId_User_id_fk": { + "name": "ModNote_modId_User_id_fk", + "tableFrom": "ModNote", + "tableTo": "User", + "columnsFrom": ["modId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "ModTag": { + "name": "ModTag", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "taggedStatusId": { + "name": "taggedStatusId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "taggedUserId": { + "name": "taggedUserId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "modId": { + "name": "modId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "tag": { + "name": "tag", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "ModTag_taggedStatusId_Status_id_fk": { + "name": "ModTag_taggedStatusId_Status_id_fk", + "tableFrom": "ModTag", + "tableTo": "Status", + "columnsFrom": ["taggedStatusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModTag_taggedUserId_User_id_fk": { + "name": "ModTag_taggedUserId_User_id_fk", + "tableFrom": "ModTag", + "tableTo": "User", + "columnsFrom": ["taggedUserId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "ModTag_modId_User_id_fk": { + "name": "ModTag_modId_User_id_fk", + "tableFrom": "ModTag", + "tableTo": "User", + "columnsFrom": ["modId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Notification": { + "name": "Notification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "notifiedId": { + "name": "notifiedId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "accountId": { + "name": "accountId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "statusId": { + "name": "statusId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dismissed": { + "name": "dismissed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "Notification_notifiedId_User_id_fk": { + "name": "Notification_notifiedId_User_id_fk", + "tableFrom": "Notification", + "tableTo": "User", + "columnsFrom": ["notifiedId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notification_accountId_User_id_fk": { + "name": "Notification_accountId_User_id_fk", + "tableFrom": "Notification", + "tableTo": "User", + "columnsFrom": ["accountId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Notification_statusId_Status_id_fk": { + "name": "Notification_statusId_Status_id_fk", + "tableFrom": "Notification", + "tableTo": "Status", + "columnsFrom": ["statusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "OpenIdAccount": { + "name": "OpenIdAccount", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "server_id": { + "name": "server_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issuer_id": { + "name": "issuer_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "OpenIdAccount_userId_User_id_fk": { + "name": "OpenIdAccount_userId_User_id_fk", + "tableFrom": "OpenIdAccount", + "tableTo": "User", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "OpenIdLoginFlow": { + "name": "OpenIdLoginFlow", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "code_verifier": { + "name": "code_verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "applicationId": { + "name": "applicationId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "issuer_id": { + "name": "issuer_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "OpenIdLoginFlow_applicationId_Application_id_fk": { + "name": "OpenIdLoginFlow_applicationId_Application_id_fk", + "tableFrom": "OpenIdLoginFlow", + "tableTo": "Application", + "columnsFrom": ["applicationId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Relationship": { + "name": "Relationship", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "ownerId": { + "name": "ownerId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subjectId": { + "name": "subjectId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "following": { + "name": "following", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "showing_reblogs": { + "name": "showing_reblogs", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "notifying": { + "name": "notifying", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "followed_by": { + "name": "followed_by", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "blocking": { + "name": "blocking", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "blocked_by": { + "name": "blocked_by", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "muting": { + "name": "muting", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "muting_notifications": { + "name": "muting_notifications", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "requested": { + "name": "requested", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "domain_blocking": { + "name": "domain_blocking", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "endorsed": { + "name": "endorsed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "languages": { + "name": "languages", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "Relationship_ownerId_User_id_fk": { + "name": "Relationship_ownerId_User_id_fk", + "tableFrom": "Relationship", + "tableTo": "User", + "columnsFrom": ["ownerId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Relationship_subjectId_User_id_fk": { + "name": "Relationship_subjectId_User_id_fk", + "tableFrom": "Relationship", + "tableTo": "User", + "columnsFrom": ["subjectId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Status": { + "name": "Status", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "authorId": { + "name": "authorId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updatedAt": { + "name": "updatedAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reblogId": { + "name": "reblogId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text/plain'" + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "inReplyToPostId": { + "name": "inReplyToPostId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "quotingPostId": { + "name": "quotingPostId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sensitive": { + "name": "sensitive", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "spoiler_text": { + "name": "spoiler_text", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "applicationId": { + "name": "applicationId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "content_source": { + "name": "content_source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + } + }, + "indexes": { + "Status_uri_index": { + "name": "Status_uri_index", + "columns": ["uri"], + "isUnique": true + } + }, + "foreignKeys": { + "Status_authorId_User_id_fk": { + "name": "Status_authorId_User_id_fk", + "tableFrom": "Status", + "tableTo": "User", + "columnsFrom": ["authorId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Status_applicationId_Application_id_fk": { + "name": "Status_applicationId_Application_id_fk", + "tableFrom": "Status", + "tableTo": "Application", + "columnsFrom": ["applicationId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "cascade" + }, + "Status_reblogId_Status_id_fk": { + "name": "Status_reblogId_Status_id_fk", + "tableFrom": "Status", + "tableTo": "Status", + "columnsFrom": ["reblogId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Status_inReplyToPostId_Status_id_fk": { + "name": "Status_inReplyToPostId_Status_id_fk", + "tableFrom": "Status", + "tableTo": "Status", + "columnsFrom": ["inReplyToPostId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "cascade" + }, + "Status_quotingPostId_Status_id_fk": { + "name": "Status_quotingPostId_Status_id_fk", + "tableFrom": "Status", + "tableTo": "Status", + "columnsFrom": ["quotingPostId"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "StatusToMentions": { + "name": "StatusToMentions", + "schema": "", + "columns": { + "statusId": { + "name": "statusId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "StatusToMentions_statusId_userId_index": { + "name": "StatusToMentions_statusId_userId_index", + "columns": ["statusId", "userId"], + "isUnique": true + }, + "StatusToMentions_userId_index": { + "name": "StatusToMentions_userId_index", + "columns": ["userId"], + "isUnique": false + } + }, + "foreignKeys": { + "StatusToMentions_statusId_Status_id_fk": { + "name": "StatusToMentions_statusId_Status_id_fk", + "tableFrom": "StatusToMentions", + "tableTo": "Status", + "columnsFrom": ["statusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "StatusToMentions_userId_User_id_fk": { + "name": "StatusToMentions_userId_User_id_fk", + "tableFrom": "StatusToMentions", + "tableTo": "User", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "Token": { + "name": "Token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "token_type": { + "name": "token_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "applicationId": { + "name": "applicationId", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "Token_userId_User_id_fk": { + "name": "Token_userId_User_id_fk", + "tableFrom": "Token", + "tableTo": "User", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "Token_applicationId_Application_id_fk": { + "name": "Token_applicationId_Application_id_fk", + "tableFrom": "Token", + "tableTo": "Application", + "columnsFrom": ["applicationId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "User": { + "name": "User", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "uuid_generate_v7()" + }, + "uri": { + "name": "uri", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "is_admin": { + "name": "is_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "endpoints": { + "name": "endpoints", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "avatar": { + "name": "avatar", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "header": { + "name": "header", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "is_bot": { + "name": "is_bot", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_locked": { + "name": "is_locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_discoverable": { + "name": "is_discoverable", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sanctions": { + "name": "sanctions", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "private_key": { + "name": "private_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "instanceId": { + "name": "instanceId", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "disable_automoderation": { + "name": "disable_automoderation", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "User_uri_index": { + "name": "User_uri_index", + "columns": ["uri"], + "isUnique": true + }, + "User_username_index": { + "name": "User_username_index", + "columns": ["username"], + "isUnique": true + }, + "User_email_index": { + "name": "User_email_index", + "columns": ["email"], + "isUnique": true + } + }, + "foreignKeys": { + "User_instanceId_Instance_id_fk": { + "name": "User_instanceId_Instance_id_fk", + "tableFrom": "User", + "tableTo": "Instance", + "columnsFrom": ["instanceId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "UserToPinnedNotes": { + "name": "UserToPinnedNotes", + "schema": "", + "columns": { + "userId": { + "name": "userId", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "statusId": { + "name": "statusId", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "UserToPinnedNotes_userId_statusId_index": { + "name": "UserToPinnedNotes_userId_statusId_index", + "columns": ["userId", "statusId"], + "isUnique": true + }, + "UserToPinnedNotes_statusId_index": { + "name": "UserToPinnedNotes_statusId_index", + "columns": ["statusId"], + "isUnique": false + } + }, + "foreignKeys": { + "UserToPinnedNotes_userId_Status_id_fk": { + "name": "UserToPinnedNotes_userId_Status_id_fk", + "tableFrom": "UserToPinnedNotes", + "tableTo": "Status", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "UserToPinnedNotes_statusId_User_id_fk": { + "name": "UserToPinnedNotes_statusId_User_id_fk", + "tableFrom": "UserToPinnedNotes", + "tableTo": "User", + "columnsFrom": ["statusId"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": {}, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 879a1e39..cabac106 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -1,62 +1,69 @@ { - "version": "5", - "dialect": "pg", - "entries": [ - { - "idx": 0, - "version": "5", - "when": 1712805159664, - "tag": "0000_illegal_living_lightning", - "breakpoints": true - }, - { - "idx": 1, - "version": "5", - "when": 1713055774123, - "tag": "0001_salty_night_thrasher", - "breakpoints": true - }, - { - "idx": 2, - "version": "5", - "when": 1713056370431, - "tag": "0002_stiff_ares", - "breakpoints": true - }, - { - "idx": 3, - "version": "5", - "when": 1713056528340, - "tag": "0003_spicy_arachne", - "breakpoints": true - }, - { - "idx": 4, - "version": "5", - "when": 1713056712218, - "tag": "0004_burly_lockjaw", - "breakpoints": true - }, - { - "idx": 5, - "version": "5", - "when": 1713056917973, - "tag": "0005_sleepy_puma", - "breakpoints": true - }, - { - "idx": 6, - "version": "5", - "when": 1713057159867, - "tag": "0006_messy_network", - "breakpoints": true - }, - { - "idx": 7, - "version": "5", - "when": 1713227918208, - "tag": "0007_naive_sleeper", - "breakpoints": true - } - ] -} \ No newline at end of file + "version": "5", + "dialect": "pg", + "entries": [ + { + "idx": 0, + "version": "5", + "when": 1712805159664, + "tag": "0000_illegal_living_lightning", + "breakpoints": true + }, + { + "idx": 1, + "version": "5", + "when": 1713055774123, + "tag": "0001_salty_night_thrasher", + "breakpoints": true + }, + { + "idx": 2, + "version": "5", + "when": 1713056370431, + "tag": "0002_stiff_ares", + "breakpoints": true + }, + { + "idx": 3, + "version": "5", + "when": 1713056528340, + "tag": "0003_spicy_arachne", + "breakpoints": true + }, + { + "idx": 4, + "version": "5", + "when": 1713056712218, + "tag": "0004_burly_lockjaw", + "breakpoints": true + }, + { + "idx": 5, + "version": "5", + "when": 1713056917973, + "tag": "0005_sleepy_puma", + "breakpoints": true + }, + { + "idx": 6, + "version": "5", + "when": 1713057159867, + "tag": "0006_messy_network", + "breakpoints": true + }, + { + "idx": 7, + "version": "5", + "when": 1713227918208, + "tag": "0007_naive_sleeper", + "breakpoints": true + }, + { + "idx": 8, + "version": "5", + "when": 1713246700119, + "tag": "0008_flawless_brother_voodoo", + "breakpoints": true + } + ] +} diff --git a/drizzle/schema.ts b/drizzle/schema.ts index 63844647..5e240bf7 100644 --- a/drizzle/schema.ts +++ b/drizzle/schema.ts @@ -195,6 +195,7 @@ export const notification = pgTable("Notification", { onDelete: "cascade", onUpdate: "cascade", }), + dismissed: boolean("dismissed").default(false).notNull(), }); export const status = pgTable( diff --git a/packages/glitch-server/main.ts b/packages/glitch-server/main.ts index 54412126..bd118c4d 100644 --- a/packages/glitch-server/main.ts +++ b/packages/glitch-server/main.ts @@ -1,9 +1,9 @@ import { join } from "node:path"; +import { redirect } from "@response"; import { config } from "config-manager"; +import { retrieveUserFromToken, userToAPI } from "~database/entities/User"; import type { LogManager, MultiLogManager } from "~packages/log-manager"; import { languages } from "./glitch-languages"; -import { redirect } from "@response"; -import { retrieveUserFromToken, userToAPI } from "~database/entities/User"; export const handleGlitchRequest = async ( req: Request, diff --git a/server/api/api/auth/login/index.ts b/server/api/api/auth/login/index.ts index 9beeffb8..4018f4d9 100644 --- a/server/api/api/auth/login/index.ts +++ b/server/api/api/auth/login/index.ts @@ -1,10 +1,10 @@ import { randomBytes } from "node:crypto"; import { apiRoute, applyConfig } from "@api"; +import { z } from "zod"; import { TokenType } from "~database/entities/Token"; import { findFirstUser } from "~database/entities/User"; import { db } from "~drizzle/db"; import { token } from "~drizzle/schema"; -import { z } from "zod"; export const meta = applyConfig({ allowedMethods: ["POST"], diff --git a/server/api/api/auth/mastodon-login/index.ts b/server/api/api/auth/mastodon-login/index.ts index 0527b66e..5fede64a 100644 --- a/server/api/api/auth/mastodon-login/index.ts +++ b/server/api/api/auth/mastodon-login/index.ts @@ -1,10 +1,10 @@ import { randomBytes } from "node:crypto"; import { apiRoute, applyConfig } from "@api"; +import { z } from "zod"; import { TokenType } from "~database/entities/Token"; import { findFirstUser } from "~database/entities/User"; import { db } from "~drizzle/db"; import { token } from "~drizzle/schema"; -import { z } from "zod"; import { config } from "~packages/config-manager"; export const meta = applyConfig({ diff --git a/server/api/api/v1/notifications/[id]/dismiss.test.ts b/server/api/api/v1/notifications/[id]/dismiss.test.ts new file mode 100644 index 00000000..ebb13b2c --- /dev/null +++ b/server/api/api/v1/notifications/[id]/dismiss.test.ts @@ -0,0 +1,93 @@ +import { afterAll, beforeAll, describe, expect, test } from "bun:test"; +import { config } from "config-manager"; +import { + deleteOldTestUsers, + getTestUsers, + sendTestRequest, +} from "~tests/utils"; +import type { Notification as APINotification } from "~types/mastodon/notification"; +import { meta } from "./dismiss"; + +await deleteOldTestUsers(); + +const { users, tokens, deleteUsers } = await getTestUsers(2); +let notifications: APINotification[] = []; + +// Create some test notifications: follow, favourite, reblog, mention +beforeAll(async () => { + await fetch( + new URL(`/api/v1/accounts/${users[0].id}/follow`, config.http.base_url), + { + method: "POST", + headers: { + Authorization: `Bearer ${tokens[1].accessToken}`, + }, + }, + ); + + notifications = await fetch( + new URL("/api/v1/notifications", config.http.base_url), + { + headers: { + Authorization: `Bearer ${tokens[0].accessToken}`, + }, + }, + ).then((r) => r.json()); + + expect(notifications.length).toBe(1); +}); + +afterAll(async () => { + await deleteUsers(); +}); + +// /api/v1/notifications/:id/dismiss +describe(meta.route, () => { + test("should return 401 if not authenticated", async () => { + const response = await sendTestRequest( + new Request(new URL(meta.route, config.http.base_url), { + method: "POST", + }), + ); + + expect(response.status).toBe(401); + }); + + test("should dismiss notification", async () => { + const response = await sendTestRequest( + new Request( + new URL( + meta.route.replace(":id", notifications[0].id), + config.http.base_url, + ), + { + method: "POST", + headers: { + Authorization: `Bearer ${tokens[0].accessToken}`, + }, + }, + ), + ); + + expect(response.status).toBe(200); + }); + + test("should not display dismissed notification", async () => { + const response = await sendTestRequest( + new Request( + new URL("/api/v1/notifications", config.http.base_url), + { + headers: { + Authorization: `Bearer ${tokens[0].accessToken}`, + }, + }, + ), + ); + + expect(response.status).toBe(200); + + const output = await response.json(); + + expect(output.length).toBe(0); + }); +}); diff --git a/server/api/api/v1/notifications/[id]/dismiss.ts b/server/api/api/v1/notifications/[id]/dismiss.ts new file mode 100644 index 00000000..71863e2d --- /dev/null +++ b/server/api/api/v1/notifications/[id]/dismiss.ts @@ -0,0 +1,37 @@ +import { apiRoute, applyConfig, idValidator } from "@api"; +import { errorResponse, jsonResponse } from "@response"; +import { eq } from "drizzle-orm"; +import { db } from "~drizzle/db"; +import { notification } from "~drizzle/schema"; + +export const meta = applyConfig({ + allowedMethods: ["POST"], + route: "/api/v1/notifications/:id/dismiss", + ratelimits: { + max: 100, + duration: 60, + }, + auth: { + required: true, + oauthPermissions: ["write:notifications"], + }, +}); + +export default apiRoute(async (req, matchedRoute, extraData) => { + const id = matchedRoute.params.id; + if (!id.match(idValidator)) { + return errorResponse("Invalid ID, must be of type UUIDv7", 404); + } + + const { user } = extraData.auth; + if (!user) return errorResponse("Unauthorized", 401); + + await db + .update(notification) + .set({ + dismissed: true, + }) + .where(eq(notification.id, id)); + + return jsonResponse({}); +}); diff --git a/server/api/api/v1/notifications/[id]/index.test.ts b/server/api/api/v1/notifications/[id]/index.test.ts new file mode 100644 index 00000000..112d342d --- /dev/null +++ b/server/api/api/v1/notifications/[id]/index.test.ts @@ -0,0 +1,117 @@ +import { afterAll, beforeAll, describe, expect, test } from "bun:test"; +import { config } from "config-manager"; +import { + deleteOldTestUsers, + getTestUsers, + sendTestRequest, +} from "~tests/utils"; +import type { Notification as APINotification } from "~types/mastodon/notification"; +import { meta } from "./index"; + +await deleteOldTestUsers(); + +const { users, tokens, deleteUsers } = await getTestUsers(2); +let notifications: APINotification[] = []; + +// Create some test notifications: follow, favourite, reblog, mention +beforeAll(async () => { + await fetch( + new URL(`/api/v1/accounts/${users[0].id}/follow`, config.http.base_url), + { + method: "POST", + headers: { + Authorization: `Bearer ${tokens[1].accessToken}`, + }, + }, + ); + + notifications = await fetch( + new URL("/api/v1/notifications", config.http.base_url), + { + headers: { + Authorization: `Bearer ${tokens[0].accessToken}`, + }, + }, + ).then((r) => r.json()); + + expect(notifications.length).toBe(1); +}); + +afterAll(async () => { + await deleteUsers(); +}); + +// /api/v1/notifications/:id +describe(meta.route, () => { + test("should return 401 if not authenticated", async () => { + const response = await sendTestRequest( + new Request(new URL(meta.route, config.http.base_url)), + ); + + expect(response.status).toBe(401); + }); + + test("should return 404 if ID is invalid", async () => { + const response = await sendTestRequest( + new Request( + new URL( + meta.route.replace(":id", "invalid"), + config.http.base_url, + ), + { + headers: { + Authorization: `Bearer ${tokens[0].accessToken}`, + }, + }, + ), + ); + expect(response.status).toBe(404); + }); + + test("should return 404 if notification not found", async () => { + const response = await sendTestRequest( + new Request( + new URL( + meta.route.replace( + ":id", + "00000000-0000-0000-0000-000000000000", + ), + config.http.base_url, + ), + { + headers: { + Authorization: `Bearer ${tokens[0].accessToken}`, + }, + }, + ), + ); + + expect(response.status).toBe(404); + }); + + test("should return notification", async () => { + const response = await sendTestRequest( + new Request( + new URL( + meta.route.replace(":id", notifications[0].id), + config.http.base_url, + ), + { + headers: { + Authorization: `Bearer ${tokens[0].accessToken}`, + }, + }, + ), + ); + + expect(response.status).toBe(200); + + const notification = (await response.json()) as APINotification; + + expect(notification).toBeDefined(); + expect(notification.id).toBe(notifications[0].id); + expect(notification.type).toBe("follow"); + expect(notification.account).toBeDefined(); + expect(notification.account?.id).toBe(users[1].id); + }); +}); diff --git a/server/api/api/v1/notifications/[id]/index.ts b/server/api/api/v1/notifications/[id]/index.ts new file mode 100644 index 00000000..0b176deb --- /dev/null +++ b/server/api/api/v1/notifications/[id]/index.ts @@ -0,0 +1,37 @@ +import { apiRoute, applyConfig, idValidator } from "@api"; +import { errorResponse, jsonResponse } from "@response"; +import { findManyNotifications } from "~database/entities/Notification"; + +export const meta = applyConfig({ + allowedMethods: ["GET"], + route: "/api/v1/notifications/:id", + ratelimits: { + max: 100, + duration: 60, + }, + auth: { + required: true, + oauthPermissions: ["read:notifications"], + }, +}); + +export default apiRoute(async (req, matchedRoute, extraData) => { + const id = matchedRoute.params.id; + if (!id.match(idValidator)) { + return errorResponse("Invalid ID, must be of type UUIDv7", 404); + } + + const { user } = extraData.auth; + if (!user) return errorResponse("Unauthorized", 401); + + const notification = ( + await findManyNotifications({ + where: (notification, { eq }) => eq(notification.id, id), + limit: 1, + }) + )[0]; + + if (!notification) return errorResponse("Notification not found", 404); + + return jsonResponse(notification); +}); diff --git a/server/api/api/v1/notifications/clear/index.test.ts b/server/api/api/v1/notifications/clear/index.test.ts new file mode 100644 index 00000000..44ed13d0 --- /dev/null +++ b/server/api/api/v1/notifications/clear/index.test.ts @@ -0,0 +1,79 @@ +import { afterAll, beforeAll, describe, expect, test } from "bun:test"; +import { config } from "config-manager"; +import { + deleteOldTestUsers, + getTestUsers, + sendTestRequest, +} from "~tests/utils"; +import type { Notification as APINotification } from "~types/mastodon/notification"; +import { meta } from "./index"; + +await deleteOldTestUsers(); + +const { users, tokens, deleteUsers } = await getTestUsers(2); +let notifications: APINotification[] = []; + +// Create some test notifications: follow, favourite, reblog, mention +beforeAll(async () => { + await fetch( + new URL(`/api/v1/accounts/${users[0].id}/follow`, config.http.base_url), + { + method: "POST", + headers: { + Authorization: `Bearer ${tokens[1].accessToken}`, + }, + }, + ); + + notifications = await fetch( + new URL("/api/v1/notifications", config.http.base_url), + { + headers: { + Authorization: `Bearer ${tokens[0].accessToken}`, + }, + }, + ).then((r) => r.json()); + + expect(notifications.length).toBe(1); +}); + +afterAll(async () => { + await deleteUsers(); +}); + +// /api/v1/notifications/clear +describe(meta.route, () => { + test("should return 401 if not authenticated", async () => { + const response = await sendTestRequest( + new Request(new URL(meta.route, config.http.base_url), { + method: "POST", + }), + ); + + expect(response.status).toBe(401); + }); + + test("should clear notifications", async () => { + const response = await sendTestRequest( + new Request(new URL(meta.route, config.http.base_url), { + method: "POST", + headers: { + Authorization: `Bearer ${tokens[0].accessToken}`, + }, + }), + ); + + expect(response.status).toBe(200); + + const newNotifications = await fetch( + new URL("/api/v1/notifications", config.http.base_url), + { + headers: { + Authorization: `Bearer ${tokens[0].accessToken}`, + }, + }, + ).then((r) => r.json()); + + expect(newNotifications.length).toBe(0); + }); +}); diff --git a/server/api/api/v1/notifications/clear/index.ts b/server/api/api/v1/notifications/clear/index.ts new file mode 100644 index 00000000..f87641d5 --- /dev/null +++ b/server/api/api/v1/notifications/clear/index.ts @@ -0,0 +1,32 @@ +import { apiRoute, applyConfig } from "@api"; +import { errorResponse, jsonResponse } from "@response"; +import { eq } from "drizzle-orm"; +import { db } from "~drizzle/db"; +import { notification } from "~drizzle/schema"; + +export const meta = applyConfig({ + allowedMethods: ["POST"], + route: "/api/v1/notifications/clear", + ratelimits: { + max: 100, + duration: 60, + }, + auth: { + required: true, + oauthPermissions: ["write:notifications"], + }, +}); + +export default apiRoute(async (req, matchedRoute, extraData) => { + const { user } = extraData.auth; + if (!user) return errorResponse("Unauthorized", 401); + + await db + .update(notification) + .set({ + dismissed: true, + }) + .where(eq(notification.notifiedId, user.id)); + + return jsonResponse({}); +}); diff --git a/server/api/api/v1/notifications/index.test.ts b/server/api/api/v1/notifications/index.test.ts index be6e0686..0c0a0ee3 100644 --- a/server/api/api/v1/notifications/index.test.ts +++ b/server/api/api/v1/notifications/index.test.ts @@ -6,8 +6,8 @@ import { getTestUsers, sendTestRequest, } from "~tests/utils"; -import { meta } from "./index"; import type { Notification as APINotification } from "~types/mastodon/notification"; +import { meta } from "./index"; await deleteOldTestUsers(); diff --git a/server/api/api/v1/notifications/index.ts b/server/api/api/v1/notifications/index.ts index b00fc22b..f26c0f38 100644 --- a/server/api/api/v1/notifications/index.ts +++ b/server/api/api/v1/notifications/index.ts @@ -17,6 +17,7 @@ export const meta = applyConfig({ }, auth: { required: true, + oauthPermissions: ["read:notifications"], }, }); @@ -115,6 +116,7 @@ export default apiRoute( : undefined, min_id ? gt(notification.id, min_id) : undefined, eq(notification.notifiedId, user.id), + eq(notification.dismissed, false), account_id ? eq(notification.accountId, account_id) : undefined,