Commit 33eb77b7 authored by VeraLyu's avatar VeraLyu Committed by Joram Wilander

PLT-3711: Add websocket event for emoji addition (#6211)

* PLT-3711: Add websocket event for emoji addition

* (SA) updated as per review

This PR is edited directly to merge into master.

* (SA) updated as per review

This PR is edited directly to merge into master.
parent 4df36a50
......@@ -122,6 +122,10 @@ func createEmoji(c *Context, w http.ResponseWriter, r *http.Request) {
c.Err = result.Err
return
} else {
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_EMOJI_ADDED, "", "", "", nil)
message.Add("emoji", result.Data.(*model.Emoji).ToJson())
app.Publish(message)
w.Write([]byte(result.Data.(*model.Emoji).ToJson()))
}
}
......
......@@ -58,6 +58,10 @@ func CreateEmoji(sessionUserId string, emoji *model.Emoji, multiPartImageData *m
if result := <-Srv.Store.Emoji().Save(emoji); result.Err != nil {
return nil, result.Err
} else {
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_EMOJI_ADDED, "", "", "", nil)
message.Add("emoji", emoji.ToJson())
Publish(message)
return result.Data.(*model.Emoji), nil
}
}
......
......@@ -36,6 +36,7 @@ const (
WEBSOCKET_EVENT_REACTION_ADDED = "reaction_added"
WEBSOCKET_EVENT_REACTION_REMOVED = "reaction_removed"
WEBSOCKET_EVENT_RESPONSE = "response"
WEBSOCKET_EVENT_EMOJI_ADDED = "emoji_added"
)
type WebSocketMessage interface {
......
......@@ -230,6 +230,10 @@ function handleEvent(msg) {
handleReactionRemovedEvent(msg);
break;
case SocketEvents.EMOJI_ADDED:
handleAddEmoji(msg);
break;
default:
}
}
......@@ -438,6 +442,15 @@ function handleReactionAddedEvent(msg) {
});
}
function handleAddEmoji(msg) {
const data = JSON.parse(msg.data.emoji);
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_CUSTOM_EMOJI,
emoji: data
});
}
function handleReactionRemovedEvent(msg) {
const reaction = JSON.parse(msg.data.reaction);
......
......@@ -242,7 +242,8 @@ export const SocketEvents = {
HELLO: 'hello',
WEBRTC: 'webrtc',
REACTION_ADDED: 'reaction_added',
REACTION_REMOVED: 'reaction_removed'
REACTION_REMOVED: 'reaction_removed',
EMOJI_ADDED: 'emoji_added'
};
export const TutorialSteps = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment