-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathSourcePostModeration.ts
More file actions
161 lines (129 loc) · 4.05 KB
/
SourcePostModeration.ts
File metadata and controls
161 lines (129 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import {
Column,
CreateDateColumn,
Entity,
Index,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import type { Post, PostType } from './posts';
import type { Source } from './Source';
import type { User } from './user';
import type { PollOption } from './polls/PollOption';
export enum SourcePostModerationStatus {
Approved = 'approved',
Rejected = 'rejected',
Pending = 'pending',
}
export enum PostModerationReason {
OffTopic = 'OFF_TOPIC',
Violation = 'VIOLATION',
Promotional = 'PROMOTIONAL',
Duplicate = 'DUPLICATE',
LowQuality = 'LOW_QUALITY',
NSFW = 'NSFW',
Spam = 'SPAM',
Misinformation = 'MISINFORMATION',
Copyright = 'COPYRIGHT',
Other = 'OTHER',
}
export const rejectReason: Record<PostModerationReason, string> = {
[PostModerationReason.OffTopic]: 'Off-topic post unrelated to the Squad',
[PostModerationReason.Violation]: 'Violates the Squad’s code of conduct',
[PostModerationReason.Promotional]: 'Too promotional without adding value',
[PostModerationReason.Duplicate]:
'Duplicate or similar content already posted',
[PostModerationReason.LowQuality]: 'Lacks quality or clarity',
[PostModerationReason.NSFW]: 'Inappropriate, NSFW or offensive post',
[PostModerationReason.Spam]: 'Post is spam or scam',
[PostModerationReason.Misinformation]:
'Contains misleading or false information',
[PostModerationReason.Copyright]: 'Copyright or privacy violation',
[PostModerationReason.Other]: 'Other',
};
export enum WarningReason {
MultipleSquadPost = 'multiple_squad_post',
DuplicatedInSameSquad = 'duplicated_in_squad',
}
export type SourcePostModerationFlags = Partial<{
aiModerated: boolean;
vordr: boolean;
warningReason: WarningReason;
dedupKey: string;
}>;
export type CreatePollOption = Pick<PollOption, 'text' | 'order'>;
@Entity()
@Index(['sourceId'])
@Index(['sourceId', 'createdById'])
export class SourcePostModeration {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'text' })
sourceId: string;
@ManyToOne('Source', (source: Source) => source.id, {
lazy: true,
onDelete: 'CASCADE',
})
source: Promise<Source>;
@Column({ type: 'text' })
status: SourcePostModerationStatus;
@Column({ type: 'text' })
createdById: string;
@ManyToOne('User', (user: User) => user.id, {
lazy: true,
onDelete: 'CASCADE',
})
createdBy: Promise<User>;
@Column({ type: 'text', nullable: true })
moderatedById?: string | null;
@ManyToOne('User', (user: User) => user.id, {
lazy: true,
onDelete: 'SET NULL',
})
moderatedBy: Promise<User>;
@Column({ type: 'text', nullable: true })
moderatorMessage?: string | null;
@Column({ type: 'text', nullable: true })
rejectionReason?: PostModerationReason | null;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
@Column({ type: 'text', nullable: true })
postId?: string | null;
@ManyToOne('Post', (post: Post) => post.id, {
lazy: true,
onDelete: 'CASCADE',
})
post: Promise<Post>;
@Column({ type: 'text' })
type: PostType;
@Column({ type: 'text', nullable: true })
title?: string | null;
@Column({ type: 'text', nullable: true })
titleHtml?: string | null;
@Column({ type: 'text', nullable: true })
content?: string | null;
@Column({ type: 'text', nullable: true })
contentHtml?: string | null;
@Column({ type: 'text', nullable: true })
image?: string | null;
@Column({ type: 'text', nullable: true })
sharedPostId?: string | null;
@ManyToOne('Post', (post: Post) => post.id, {
lazy: true,
onDelete: 'CASCADE',
})
sharedPost?: Promise<Post>;
@Column({ type: 'text', nullable: true })
externalLink?: string | null;
@Column({ type: 'jsonb', default: {} })
@Index('IDX_source_post_moderation_flags_vordr', { synchronize: false })
@Index('IDX_source_post_moderation_flags_dedupKey', { synchronize: false })
flags: SourcePostModerationFlags;
@Column({ type: 'jsonb', default: [] })
pollOptions?: CreatePollOption[];
@Column({ type: 'integer', default: null })
duration?: number | null;
}