delay notification of change to avoid contention with other clients

This commit is contained in:
Roland Osborne 2023-01-27 10:08:02 -08:00
parent ed63b62b0a
commit f848cde5bb

View File

@ -5,6 +5,7 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"gorm.io/gorm" "gorm.io/gorm"
"net/http" "net/http"
"time"
) )
//AddChannelTopic adds a topic to a channel through either contact or agent query param //AddChannelTopic adds a topic to a channel through either contact or agent query param
@ -88,6 +89,10 @@ func AddChannelTopic(w http.ResponseWriter, r *http.Request) {
} }
} }
WriteResponse(w, getTopicModel(topicSlot))
go func() {
time.Sleep(25 * time.Millisecond);
SetStatus(act) SetStatus(act)
for _, card := range cards { for _, card := range cards {
SetContactChannelNotification(act, &card) SetContactChannelNotification(act, &card)
@ -98,6 +103,5 @@ func AddChannelTopic(w http.ResponseWriter, r *http.Request) {
if act.GUID != guid { if act.GUID != guid {
go SendPushEvent(*act, "content.addChannelTopic." + channelSlot.Channel.DataType) go SendPushEvent(*act, "content.addChannelTopic." + channelSlot.Channel.DataType)
} }
}()
WriteResponse(w, getTopicModel(topicSlot))
} }