Barazo AppView backend barazo.forum
at main 42 lines 1.6 kB view raw
1import { pgTable, pgPolicy, serial, text, jsonb, timestamp, index } from 'drizzle-orm/pg-core' 2import { sql } from 'drizzle-orm' 3import { appRole } from './roles.js' 4 5export const moderationQueue = pgTable( 6 'moderation_queue', 7 { 8 id: serial('id').primaryKey(), 9 contentUri: text('content_uri').notNull(), 10 contentType: text('content_type', { 11 enum: ['topic', 'reply'], 12 }).notNull(), 13 authorDid: text('author_did').notNull(), 14 communityDid: text('community_did').notNull(), 15 queueReason: text('queue_reason', { 16 enum: ['word_filter', 'first_post', 'link_hold', 'burst', 'topic_delay'], 17 }).notNull(), 18 matchedWords: jsonb('matched_words').$type<string[]>(), 19 status: text('status', { 20 enum: ['pending', 'approved', 'rejected'], 21 }) 22 .notNull() 23 .default('pending'), 24 reviewedBy: text('reviewed_by'), 25 createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), 26 reviewedAt: timestamp('reviewed_at', { withTimezone: true }), 27 }, 28 (table) => [ 29 index('mod_queue_author_did_idx').on(table.authorDid), 30 index('mod_queue_community_did_idx').on(table.communityDid), 31 index('mod_queue_status_idx').on(table.status), 32 index('mod_queue_created_at_idx').on(table.createdAt), 33 index('mod_queue_content_uri_idx').on(table.contentUri), 34 pgPolicy('tenant_isolation', { 35 as: 'permissive', 36 to: appRole, 37 for: 'all', 38 using: sql`community_did = current_setting('app.current_community_did', true)`, 39 withCheck: sql`community_did = current_setting('app.current_community_did', true)`, 40 }), 41 ] 42).enableRLS()