From f848cde5bba722a937ab1c5d9b18cb5231c7b611 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Fri, 27 Jan 2023 10:08:02 -0800 Subject: [PATCH] delay notification of change to avoid contention with other clients --- net/server/internal/api_addChannelTopic.go | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/net/server/internal/api_addChannelTopic.go b/net/server/internal/api_addChannelTopic.go index 7a608c58..417ff48f 100644 --- a/net/server/internal/api_addChannelTopic.go +++ b/net/server/internal/api_addChannelTopic.go @@ -5,6 +5,7 @@ import ( "github.com/google/uuid" "gorm.io/gorm" "net/http" + "time" ) //AddChannelTopic adds a topic to a channel through either contact or agent query param @@ -88,16 +89,19 @@ func AddChannelTopic(w http.ResponseWriter, r *http.Request) { } } - SetStatus(act) - for _, card := range cards { - SetContactChannelNotification(act, &card) - } - for _, card := range notify { - SetContactPushNotification(&card, "content.addChannelTopic." + channelSlot.Channel.DataType) - } - if act.GUID != guid { - go SendPushEvent(*act, "content.addChannelTopic." + channelSlot.Channel.DataType) - } - WriteResponse(w, getTopicModel(topicSlot)) + + go func() { + time.Sleep(25 * time.Millisecond); + SetStatus(act) + for _, card := range cards { + SetContactChannelNotification(act, &card) + } + for _, card := range notify { + SetContactPushNotification(&card, "content.addChannelTopic." + channelSlot.Channel.DataType) + } + if act.GUID != guid { + go SendPushEvent(*act, "content.addChannelTopic." + channelSlot.Channel.DataType) + } + }() }