Skip to content

Commit

Permalink
Add a specific error when inviting a remote cluster to a remote chann…
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdelacroix authored Sep 19, 2024
1 parent c27d536 commit 8a735f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion server/channels/api4/shared_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ func inviteRemoteClusterToChannel(c *Context, w http.ResponseWriter, r *http.Req
audit.AddEventParameter(auditRec, "user_id", c.AppContext.Session().UserId)

if err := c.App.InviteRemoteToChannel(c.Params.ChannelId, c.Params.RemoteId, c.AppContext.Session().UserId, true); err != nil {
c.Err = model.NewAppError("inviteRemoteClusterToChannel", "api.shared_channel.invite_remote_to_channel_error", nil, "", http.StatusInternalServerError).Wrap(err)
if appErr, ok := err.(*model.AppError); ok {
c.Err = appErr
} else {
c.Err = model.NewAppError("inviteRemoteClusterToChannel", "api.shared_channel.invite_remote_to_channel_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
return
}

Expand Down
2 changes: 1 addition & 1 deletion server/platform/services/sharedchannel/service_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (scs *Service) InviteRemoteToChannel(channelID, remoteID, userID string, sh
// (also blocks cyclic invitations)
if err = scs.CheckCanInviteToSharedChannel(channelID); err != nil {
if errors.Is(err, model.ErrChannelHomedOnRemote) {
return model.NewAppError("InviteRemoteToChannel", "api.command_share.channel_invite_not_home.error", nil, "", http.StatusInternalServerError)
return model.NewAppError("InviteRemoteToChannel", "api.command_share.channel_invite_not_home.error", nil, "", http.StatusBadRequest)
}
scs.server.Log().Debug("InviteRemoteToChannel failed to check if can-invite",
mlog.String("name", rc.Name),
Expand Down

0 comments on commit 8a735f1

Please sign in to comment.