[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
+12
View File
@@ -205,6 +205,8 @@ type feishuEvent struct {
type feishuMessage struct {
MessageID string `json:"message_id"`
RootID string `json:"root_id"`
ParentID string `json:"parent_id"`
MessageType string `json:"message_type"`
ChatType string `json:"chat_type"`
ChatID string `json:"chat_id"`
@@ -263,6 +265,12 @@ func (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error) {
}
msg := eventBody.Event.Message
// Compute thread ID: use root_id for threaded replies, or message_id for top-level messages.
threadID := msg.RootID
if threadID == "" {
threadID = msg.MessageID
}
// Determine chat type
chatType := im.ChatTypeDirect
chatID := ""
@@ -308,6 +316,7 @@ func (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error) {
ChatType: chatType,
Content: strings.TrimSpace(content),
MessageID: msg.MessageID,
ThreadID: threadID,
}, nil
case "file":
@@ -328,6 +337,7 @@ func (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error) {
ChatID: chatID,
ChatType: chatType,
MessageID: msg.MessageID,
ThreadID: threadID,
FileKey: fileContent.FileKey,
FileName: fileContent.FileName,
}, nil
@@ -349,6 +359,7 @@ func (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error) {
ChatID: chatID,
ChatType: chatType,
MessageID: msg.MessageID,
ThreadID: threadID,
FileKey: imageContent.ImageKey,
FileName: imageContent.ImageKey + ".png",
}, nil
@@ -411,6 +422,7 @@ func (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error) {
ChatType: chatType,
Content: content,
MessageID: msg.MessageID,
ThreadID: threadID,
}, nil
default: