Added category change broaadcast to cluster

This commit is contained in:
Harshil Sharma 2022-04-13 15:46:35 +05:30
parent 280e38604f
commit d744d69b43
2 changed files with 13 additions and 1 deletions

View file

@ -480,7 +480,18 @@ func (pa *PluginAdapter) BroadcastCategoryChange(category model.Category) {
Category: &category,
}
pa.sendUserMessageSkipCluster(websocketActionUpdateCategory, utils.StructToMap(message), category.UserID)
payload := utils.StructToMap(message)
go func() {
clusterMessage := &ClusterMessage{
Payload: payload,
EnsureUsers: []string{category.UserID},
}
pa.sendMessageToCluster("websocket_message", clusterMessage)
}()
pa.sendUserMessageSkipCluster(websocketActionUpdateCategory, payload, category.UserID)
}
func (pa *PluginAdapter) BroadcastCategoryBlockChange(teamID, userID string, blockCategory model.BlockCategoryWebsocketData) {

View file

@ -13,6 +13,7 @@ type ClusterMessage struct {
EnsureUsers []string
}
//nolint:unparam // the `id` param is to key this function generic and handle more than just websocket messages
func (pa *PluginAdapter) sendMessageToCluster(id string, clusterMessage *ClusterMessage) {
b, err := json.Marshal(clusterMessage)
if err != nil {