Commit 9609a9b8 authored by George Goldberg's avatar George Goldberg Committed by Corey Hulen

PLT-6196: Websocket message when added to a team. (#5968)

parent adb22a8a
......@@ -436,11 +436,18 @@ func AddTeamMember(teamId, userId, siteURL string) (*model.TeamMember, *model.Ap
return nil, err
}
if teamMember, err := GetTeamMember(teamId, userId); err != nil {
var teamMember *model.TeamMember
var err *model.AppError
if teamMember, err = GetTeamMember(teamId, userId); err != nil {
return nil, err
} else {
return teamMember, nil
}
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_ADDED_TO_TEAM, "", "", userId, nil)
message.Add("team_id", teamId)
message.Add("user_id", userId)
Publish(message)
return teamMember, nil
}
func AddTeamMembers(teamId string, userIds []string, siteURL string) ([]*model.TeamMember, *model.AppError) {
......@@ -456,6 +463,11 @@ func AddTeamMembers(teamId string, userIds []string, siteURL string) ([]*model.T
} else {
members = append(members, teamMember)
}
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_ADDED_TO_TEAM, "", "", userId, nil)
message.Add("team_id", teamId)
message.Add("user_id", userId)
Publish(message)
}
return members, nil
......
......@@ -18,6 +18,7 @@ const (
WEBSOCKET_EVENT_DIRECT_ADDED = "direct_added"
WEBSOCKET_EVENT_GROUP_ADDED = "group_added"
WEBSOCKET_EVENT_NEW_USER = "new_user"
WEBSOCKET_EVENT_ADDED_TO_TEAM = "added_to_team"
WEBSOCKET_EVENT_LEAVE_TEAM = "leave_team"
WEBSOCKET_EVENT_UPDATE_TEAM = "update_team"
WEBSOCKET_EVENT_USER_ADDED = "user_added"
......
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