fix(slack): support multiple threads update (#115)
Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
committed by
GitHub
parent
dff678fc4e
commit
7b52b9c22d
@@ -497,10 +497,7 @@ func (t *Slack) handleMention(
|
|||||||
|
|
||||||
// Store the UUID->placeholder message mapping
|
// Store the UUID->placeholder message mapping
|
||||||
// We'll use the thread timestamp as our UUID
|
// We'll use the thread timestamp as our UUID
|
||||||
jobUUID := ts
|
jobUUID := msgTs
|
||||||
if jobUUID == "" {
|
|
||||||
jobUUID = ev.TimeStamp
|
|
||||||
}
|
|
||||||
|
|
||||||
t.placeholderMutex.Lock()
|
t.placeholderMutex.Lock()
|
||||||
t.placeholders[jobUUID] = msgTs
|
t.placeholders[jobUUID] = msgTs
|
||||||
@@ -687,19 +684,12 @@ func (t *Slack) handleMention(
|
|||||||
finalResponse := fmt.Sprintf("@%s %s", user.Name, res.Response)
|
finalResponse := fmt.Sprintf("@%s %s", user.Name, res.Response)
|
||||||
xlog.Debug("Send final response to slack", "response", finalResponse)
|
xlog.Debug("Send final response to slack", "response", finalResponse)
|
||||||
|
|
||||||
// Update the placeholder message with the final result
|
|
||||||
t.placeholderMutex.RLock()
|
|
||||||
msgTs, exists := t.placeholders[jobUUID]
|
|
||||||
t.placeholderMutex.RUnlock()
|
|
||||||
|
|
||||||
if exists && msgTs != "" {
|
|
||||||
replyToUpdateMessage(finalResponse, api, ev, msgTs, ts, res)
|
replyToUpdateMessage(finalResponse, api, ev, msgTs, ts, res)
|
||||||
|
|
||||||
// Clean up the placeholder map
|
// Clean up the placeholder map
|
||||||
t.placeholderMutex.Lock()
|
t.placeholderMutex.Lock()
|
||||||
delete(t.placeholders, jobUUID)
|
delete(t.placeholders, jobUUID)
|
||||||
t.placeholderMutex.Unlock()
|
t.placeholderMutex.Unlock()
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user