feat: enforce tenant content moderation

This commit is contained in:
richjohnrambo
2026-09-16 22:21:25 +08:00
parent 0ae4af0c31
commit 0f8e3b82b7
26 changed files with 891 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
CREATE TABLE IF NOT EXISTS `im_content_moderation_logs` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`request_id` VARCHAR(64) NOT NULL,
`scene` VARCHAR(32) NOT NULL,
`topic` VARCHAR(96) NOT NULL DEFAULT '',
`seqid` BIGINT DEFAULT NULL,
`actor_id` BIGINT DEFAULT NULL,
`provider` VARCHAR(32) NOT NULL DEFAULT '',
`provider_request_id` VARCHAR(96) NOT NULL DEFAULT '',
`risk_level` VARCHAR(16) NOT NULL DEFAULT 'none',
`risk_labels` JSON DEFAULT NULL,
`action` VARCHAR(16) NOT NULL,
`content_hash` CHAR(64) NOT NULL,
`latency_ms` BIGINT NOT NULL DEFAULT 0,
`error_code` VARCHAR(64) NOT NULL DEFAULT '',
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY (`id`),
UNIQUE KEY `uk_im_content_moderation_request` (`request_id`),
KEY `idx_im_content_moderation_scene_time` (`scene`,`created_at` DESC,`id` DESC),
KEY `idx_im_content_moderation_actor_time` (`actor_id`,`created_at` DESC,`id` DESC),
KEY `idx_im_content_moderation_topic_seq` (`topic`,`seqid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;