[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:
@@ -114,7 +114,14 @@ func (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error) {
|
||||
} else {
|
||||
threadRoot = payload.RootID
|
||||
if threadRoot == "" {
|
||||
threadRoot = payload.PostID
|
||||
// Outgoing webhooks may omit root_id for thread replies.
|
||||
// Fetch the post to resolve the actual thread root.
|
||||
if actualRootID, err := a.client.GetPost(c.Request.Context(), payload.PostID); err == nil && actualRootID != "" {
|
||||
threadRoot = actualRootID
|
||||
} else {
|
||||
// Top-level message: use its own PostID as thread root.
|
||||
threadRoot = payload.PostID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +133,7 @@ func (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error) {
|
||||
ChatType: im.ChatTypeGroup,
|
||||
Content: strings.TrimSpace(payload.Text),
|
||||
MessageID: payload.PostID,
|
||||
ThreadID: threadRoot,
|
||||
Extra: map[string]string{
|
||||
extraKeyThreadRoot: threadRoot,
|
||||
extraKeyChannelID: payload.ChannelID,
|
||||
|
||||
Reference in New Issue
Block a user