Files
akmon/utils/msgTypes.uts
2026-01-20 08:04:15 +08:00

257 lines
7.0 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 消息系统类型定义 - 严格遵循UTS Android要求
* 基于 message_system.sql 数据库设计
*/
// 基础类型定义
export type MessageSenderType = 'user' | 'device' | 'system'
export type MessageReceiverType = 'user' | 'group' | 'broadcast' | 'class'
export type MessageContentType = 'text' | 'html' | 'markdown' | 'json'
export type MessageStatus = 'draft' | 'sent' | 'delivered' | 'failed'
export type RecipientStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'failed'
export type DeliveryMethod = 'push' | 'email' | 'sms' | 'websocket'
export type GroupType = 'normal' | 'class' | 'team' | 'system' | 'temporary'
export type MemberRole = 'owner' | 'admin' | 'moderator' | 'member'
export type MemberStatus = 'active' | 'muted' | 'banned' | 'left'
// 消息类型信息
export type MessageType = {
id: string
code: string
name: string
description: string | null
icon: string | null
color: string | null
priority: number
is_system: boolean
is_active: boolean
auto_read_timeout: number | null
retention_days: number
created_at: string
updated_at: string
}
// 消息主体
export type Message = {
id: string
message_type_id: string
sender_type: MessageSenderType
sender_id: string | null
sender_name: string | null
receiver_type: MessageReceiverType
receiver_id: string | null
title: string | null
content: string | null
content_type: MessageContentType
attachments: UTSJSONObject | null
media_urls: UTSJSONObject | null
metadata: UTSJSONObject | null
device_data: UTSJSONObject | null
location_data: UTSJSONObject | null
priority: number
expires_at: string | null
is_broadcast: boolean
is_urgent: boolean
conversation_id: string | null
parent_message_id: string | null
thread_count: number
status: MessageStatus
total_recipients: number
delivered_count: number
read_count: number
reply_count: number
delivery_options: UTSJSONObject | null
push_notification: boolean
email_notification: boolean
sms_notification: boolean
created_at: string
updated_at: string
scheduled_at: string | null
delivered_at: string | null
}
// 消息接收记录
export type MessageRecipient = {
id: string
message_id: string
recipient_type: MessageSenderType
recipient_id: string
recipient_name: string | null
status: RecipientStatus
delivery_method: DeliveryMethod | null
sent_at: string | null
delivered_at: string | null
read_at: string | null
replied_at: string | null
delivery_attempts: number
last_attempt_at: string | null
failure_reason: string | null
device_token: string | null
is_starred: boolean
is_archived: boolean
is_deleted: boolean
deleted_at: string | null
read_duration_sec: number | null
interaction_data: UTSJSONObject | null
created_at: string
updated_at: string
}
// 消息群组
export type MessageGroup = {
id: string
name: string
description: string | null
group_type: GroupType
owner_id: string | null
avatar_url: string | null
is_active: boolean
is_public: boolean
member_limit: number
message_limit_per_day: number
file_size_limit_mb: number
settings: UTSJSONObject
permissions: UTSJSONObject
auto_archive_days: number
auto_delete_days: number
related_class_id: string | null
related_school_id: string | null
created_at: string
updated_at: string
}
// 群组成员
export type GroupMember = {
id: string
group_id: string
user_id: string
role: MemberRole
permissions: UTSJSONObject
status: MemberStatus
nickname: string | null
is_muted: boolean
muted_until: string | null
muted_by: string | null
mute_reason: string | null
last_read_message_id: string | null
last_read_at: string | null
unread_count: number
notification_enabled: boolean
mention_only: boolean
message_count: number
join_count: number
joined_at: string
left_at: string | null
created_at: string
updated_at: string
}
// 消息统计信息
export type MessageStats = {
total_messages: number
unread_messages: number
sent_messages: number
received_messages: number
urgent_messages: number
draft_messages: number
}
// 查询参数类型
export type MessageListParams = {
limit?: number
offset?: number
message_type?: string
sender_type?: MessageSenderType
sender_id?: string
receiver_type?: MessageReceiverType
receiver_id?: string
status?: MessageStatus
is_urgent?: boolean
start_date?: string
end_date?: string
search?: string
}
// 发送消息参数
export type SendMessageParams = {
message_type_id: string
receiver_type: MessageReceiverType
receiver_id?: string
receivers?: string[] // 新增,支持批量接收人
title?: string
content: string
content_type?: MessageContentType
priority?: number
is_urgent?: boolean
push_notification?: boolean
email_notification?: boolean
sms_notification?: boolean
scheduled_at?: string
expires_at?: string
attachments?: UTSJSONObject
media_urls?: UTSJSONObject // 新增,兼容服务端参数
metadata?: UTSJSONObject
// 新增,兼容服务端参数
sender_type?: MessageSenderType
sender_id?: string
sender_name?: string
}
// 用户选项类型
export type UserOption = {
id: string
username: string
nickname: string
avatar: string | null
}
// 扩展的Message类型包含接收者信息用于UI显示
export type MessageWithRecipient = {
// 从Message类型复制的所有字段
id: string
message_type_id: string
sender_type: MessageSenderType
sender_id: string | null
sender_name: string | null
receiver_type: MessageReceiverType
receiver_id: string | null
title: string | null
content: string | null
content_type: MessageContentType
attachments: UTSJSONObject | null
media_urls: UTSJSONObject | null
metadata: UTSJSONObject | null
device_data: UTSJSONObject | null
location_data: UTSJSONObject | null
priority: number
expires_at: string | null
is_broadcast: boolean
is_urgent: boolean
conversation_id: string | null
parent_message_id: string | null
thread_count: number
status: MessageStatus
total_recipients: number
delivered_count: number
read_count: number
reply_count: number
delivery_options: UTSJSONObject | null
push_notification: boolean
email_notification: boolean
sms_notification: boolean
created_at: string
updated_at: string
scheduled_at: string | null
delivered_at: string | null
// 从MessageRecipient中添加的字段
is_read?: boolean
is_starred?: boolean
is_archived?: boolean
is_deleted?: boolean
read_at?: string | null
replied_at?: string | null
// 扩展字段
message_type?: string // 消息类型代码,用于兼容
recipients?: Array<MessageRecipient> // 接收者列表
}