diff --git a/server/channels/api4/shared_channel.go b/server/channels/api4/shared_channel.go index d051b252cbe..8fd1c0859f6 100644 --- a/server/channels/api4/shared_channel.go +++ b/server/channels/api4/shared_channel.go @@ -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 } diff --git a/server/platform/services/sharedchannel/service_api.go b/server/platform/services/sharedchannel/service_api.go index 971bdc0a33a..b1d1804e061 100644 --- a/server/platform/services/sharedchannel/service_api.go +++ b/server/platform/services/sharedchannel/service_api.go @@ -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),