[NELO-1102] feat(im): add thread-based session mode for IM channels

Add session_mode ("user" | "thread") to IM channel config. In thread
mode, each message thread gets its own session, enabling multi-user
collaboration within the same thread context.

Backend:
- Add SessionMode type constants and validation
- Add ThreadID field to IncomingMessage and ChannelSession
- Split resolveSession into resolveUserSession/resolveThreadSession
- Update makeUserKey to include threadID only in thread mode
- Extract ThreadID in Slack, Mattermost, Feishu, Telegram adapters
- Add message_thread_id to Telegram SendReply/StartStream for Forums
- DB migration 000028: session_mode column + thread_id column + index

Frontend:
- Add session_mode radio group to IMChannelPanel dialog
- Auto-reset session_mode when switching to non-thread platform
- Show thread badge on channel card for thread-mode channels
- Add i18n keys for en-US, ko-KR, zh-CN, ru-RU
This commit is contained in:
ochan.kwon
2026-03-27 20:49:10 +09:00
committed by lyingbug
parent 930a953f41
commit 2d5782992e
22 changed files with 1015 additions and 22 deletions
+19
View File
@@ -19,6 +19,16 @@ const (
PlatformMattermost Platform = "mattermost"
)
// SessionMode determines how IM sessions are resolved.
type SessionMode string
const (
// SessionModeUser resolves sessions by (platform, user_id, chat_id, tenant_id).
SessionModeUser SessionMode = "user"
// SessionModeThread resolves sessions by (platform, thread_id, chat_id, tenant_id).
SessionModeThread SessionMode = "thread"
)
// MessageType identifies the kind of IM message.
type MessageType string
@@ -52,6 +62,15 @@ type IncomingMessage struct {
FileName string
// FileSize is the file size in bytes (for file messages, optional).
FileSize int64
// ThreadID is the platform-specific thread identifier.
// - Slack: thread_ts (top-level message uses its own timestamp)
// - Mattermost: root_id, or post_id if top-level
// - Feishu: root_id, or message_id if top-level
// - Telegram: message_thread_id (Forum Topics only)
// Empty for platforms without thread support (WeCom, DingTalk).
// In thread mode, top-level messages use their own ID as ThreadID,
// effectively creating a new session per top-level message.
ThreadID string
// Extra holds platform-specific fields (e.g., WeCom stream ID).
Extra map[string]string
}