mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
Slight refactoring, begin work on major moderation overhaul
This commit is contained in:
parent
e05dca9fc1
commit
2bc9ff51ea
45 changed files with 639 additions and 109 deletions
|
|
@ -0,0 +1,40 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "Instance" ADD COLUMN "disableAutomoderation" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "disableAutomoderation" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ModerationData" (
|
||||
"id" UUID NOT NULL DEFAULT uuid_generate_v7(),
|
||||
"statusId" UUID NOT NULL,
|
||||
"creatorId" UUID NOT NULL,
|
||||
"note" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "ModerationData_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Flag" (
|
||||
"id" UUID NOT NULL DEFAULT uuid_generate_v7(),
|
||||
"statusId" UUID NOT NULL,
|
||||
"userId" UUID NOT NULL,
|
||||
"flagType" TEXT NOT NULL DEFAULT 'other',
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "Flag_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ModerationData" ADD CONSTRAINT "ModerationData_statusId_fkey" FOREIGN KEY ("statusId") REFERENCES "Status"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ModerationData" ADD CONSTRAINT "ModerationData_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Flag" ADD CONSTRAINT "Flag_statusId_fkey" FOREIGN KEY ("statusId") REFERENCES "Status"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Flag" ADD CONSTRAINT "Flag_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
|
@ -37,14 +37,15 @@ model Emoji {
|
|||
}
|
||||
|
||||
model Instance {
|
||||
id String @id @default(dbgenerated("uuid_generate_v7()")) @db.Uuid
|
||||
base_url String
|
||||
name String
|
||||
version String
|
||||
logo Json
|
||||
emojis Emoji[] // One to many relation with Emoji
|
||||
statuses Status[] // One to many relation with Status
|
||||
users User[] // One to many relation with User
|
||||
id String @id @default(dbgenerated("uuid_generate_v7()")) @db.Uuid
|
||||
base_url String
|
||||
name String
|
||||
version String
|
||||
logo Json
|
||||
emojis Emoji[] // One to many relation with Emoji
|
||||
statuses Status[] // One to many relation with Status
|
||||
users User[] // One to many relation with User
|
||||
disableAutomoderation Boolean @default(false)
|
||||
}
|
||||
|
||||
model Like {
|
||||
|
|
@ -93,38 +94,62 @@ model Relationship {
|
|||
}
|
||||
|
||||
model Status {
|
||||
id String @id @default(dbgenerated("uuid_generate_v7()")) @db.Uuid
|
||||
uri String @unique
|
||||
author User @relation("UserStatuses", fields: [authorId], references: [id], onDelete: Cascade)
|
||||
authorId String @db.Uuid
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
reblog Status? @relation("StatusToStatus", fields: [reblogId], references: [id], onDelete: Cascade)
|
||||
reblogId String? @db.Uuid
|
||||
id String @id @default(dbgenerated("uuid_generate_v7()")) @db.Uuid
|
||||
uri String @unique
|
||||
author User @relation("UserStatuses", fields: [authorId], references: [id], onDelete: Cascade)
|
||||
authorId String @db.Uuid
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
reblog Status? @relation("StatusToStatus", fields: [reblogId], references: [id], onDelete: Cascade)
|
||||
reblogId String? @db.Uuid
|
||||
isReblog Boolean
|
||||
content String @default("")
|
||||
contentType String @default("text/plain")
|
||||
contentSource String @default("")
|
||||
content String @default("")
|
||||
contentType String @default("text/plain")
|
||||
contentSource String @default("")
|
||||
visibility String
|
||||
inReplyToPost Status? @relation("StatusToStatusReply", fields: [inReplyToPostId], references: [id], onDelete: SetNull)
|
||||
inReplyToPostId String? @db.Uuid
|
||||
quotingPost Status? @relation("StatusToStatusQuote", fields: [quotingPostId], references: [id], onDelete: SetNull)
|
||||
quotingPostId String? @db.Uuid
|
||||
instance Instance? @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String? @db.Uuid
|
||||
inReplyToPost Status? @relation("StatusToStatusReply", fields: [inReplyToPostId], references: [id], onDelete: SetNull)
|
||||
inReplyToPostId String? @db.Uuid
|
||||
quotingPost Status? @relation("StatusToStatusQuote", fields: [quotingPostId], references: [id], onDelete: SetNull)
|
||||
quotingPostId String? @db.Uuid
|
||||
instance Instance? @relation(fields: [instanceId], references: [id], onDelete: Cascade)
|
||||
instanceId String? @db.Uuid
|
||||
sensitive Boolean
|
||||
spoilerText String @default("")
|
||||
application Application? @relation(fields: [applicationId], references: [id], onDelete: SetNull)
|
||||
applicationId String? @db.Uuid
|
||||
emojis Emoji[] @relation
|
||||
spoilerText String @default("")
|
||||
application Application? @relation(fields: [applicationId], references: [id], onDelete: SetNull)
|
||||
applicationId String? @db.Uuid
|
||||
emojis Emoji[] @relation
|
||||
mentions User[]
|
||||
likes Like[] @relation("LikedToStatus")
|
||||
reblogs Status[] @relation("StatusToStatus")
|
||||
replies Status[] @relation("StatusToStatusReply")
|
||||
quotes Status[] @relation("StatusToStatusQuote")
|
||||
pinnedBy User[] @relation("UserPinnedNotes")
|
||||
likes Like[] @relation("LikedToStatus")
|
||||
reblogs Status[] @relation("StatusToStatus")
|
||||
replies Status[] @relation("StatusToStatusReply")
|
||||
quotes Status[] @relation("StatusToStatusQuote")
|
||||
pinnedBy User[] @relation("UserPinnedNotes")
|
||||
attachments Attachment[]
|
||||
relatedNotifications Notification[]
|
||||
flags Flag[]
|
||||
moderationData ModerationData[]
|
||||
}
|
||||
|
||||
model ModerationData {
|
||||
id String @id @default(dbgenerated("uuid_generate_v7()")) @db.Uuid
|
||||
status Status @relation(fields: [statusId], references: [id], onDelete: Cascade)
|
||||
statusId String @db.Uuid
|
||||
creator User @relation(fields: [creatorId], references: [id], onDelete: Cascade)
|
||||
creatorId String @db.Uuid
|
||||
note String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
// Used for moderation purposes
|
||||
model Flag {
|
||||
id String @id @default(dbgenerated("uuid_generate_v7()")) @db.Uuid
|
||||
status Status @relation(fields: [statusId], references: [id], onDelete: Cascade)
|
||||
statusId String @db.Uuid
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId String @db.Uuid
|
||||
flagType String @default("other")
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model Token {
|
||||
|
|
@ -179,39 +204,42 @@ model Notification {
|
|||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(dbgenerated("uuid_generate_v7()")) @db.Uuid
|
||||
uri String @unique
|
||||
username String @unique
|
||||
displayName String
|
||||
password String? // Nullable
|
||||
email String? @unique // Nullable
|
||||
note String @default("")
|
||||
isAdmin Boolean @default(false)
|
||||
endpoints Json? // Nullable
|
||||
source Json
|
||||
avatar String
|
||||
header String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
isBot Boolean @default(false)
|
||||
isLocked Boolean @default(false)
|
||||
isDiscoverable Boolean @default(false)
|
||||
sanctions String[] @default([])
|
||||
publicKey String
|
||||
privateKey String? // Nullable
|
||||
relationships Relationship[] @relation("OwnerToRelationship") // One to many relation with Relationship
|
||||
relationshipSubjects Relationship[] @relation("SubjectToRelationship") // One to many relation with Relationship
|
||||
instance Instance? @relation(fields: [instanceId], references: [id], onDelete: Cascade) // Many to one relation with Instance
|
||||
instanceId String? @db.Uuid
|
||||
pinnedNotes Status[] @relation("UserPinnedNotes") // Many to many relation with Status
|
||||
emojis Emoji[] // Many to many relation with Emoji
|
||||
statuses Status[] @relation("UserStatuses") // One to many relation with Status
|
||||
tokens Token[] // One to many relation with Token
|
||||
likes Like[] @relation("UserLiked") // One to many relation with Like
|
||||
statusesMentioned Status[] // Many to many relation with Status
|
||||
notifications Notification[] // One to many relation with Notification
|
||||
notified Notification[] @relation("NotificationToNotified") // One to many relation with Notification
|
||||
linkedOpenIdAccounts OpenIdAccount[] // One to many relation with OpenIdAccount
|
||||
id String @id @default(dbgenerated("uuid_generate_v7()")) @db.Uuid
|
||||
uri String @unique
|
||||
username String @unique
|
||||
displayName String
|
||||
password String? // Nullable
|
||||
email String? @unique // Nullable
|
||||
note String @default("")
|
||||
isAdmin Boolean @default(false)
|
||||
endpoints Json? // Nullable
|
||||
source Json
|
||||
avatar String
|
||||
header String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
isBot Boolean @default(false)
|
||||
isLocked Boolean @default(false)
|
||||
isDiscoverable Boolean @default(false)
|
||||
sanctions String[] @default([])
|
||||
publicKey String
|
||||
privateKey String? // Nullable
|
||||
relationships Relationship[] @relation("OwnerToRelationship") // One to many relation with Relationship
|
||||
relationshipSubjects Relationship[] @relation("SubjectToRelationship") // One to many relation with Relationship
|
||||
instance Instance? @relation(fields: [instanceId], references: [id], onDelete: Cascade) // Many to one relation with Instance
|
||||
instanceId String? @db.Uuid
|
||||
pinnedNotes Status[] @relation("UserPinnedNotes") // Many to many relation with Status
|
||||
emojis Emoji[] // Many to many relation with Emoji
|
||||
statuses Status[] @relation("UserStatuses") // One to many relation with Status
|
||||
tokens Token[] // One to many relation with Token
|
||||
likes Like[] @relation("UserLiked") // One to many relation with Like
|
||||
statusesMentioned Status[] // Many to many relation with Status
|
||||
notifications Notification[] // One to many relation with Notification
|
||||
notified Notification[] @relation("NotificationToNotified") // One to many relation with Notification
|
||||
linkedOpenIdAccounts OpenIdAccount[] // One to many relation with OpenIdAccount
|
||||
flags Flag[] @relation
|
||||
moderationData ModerationData[]
|
||||
disableAutomoderation Boolean @default(false)
|
||||
}
|
||||
|
||||
model OpenIdAccount {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue