diff --git a/api4/channel.go b/api4/channel.go index c303d2d078..76f6c82570 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -992,7 +992,7 @@ func getChannelByName(c *Context, w http.ResponseWriter, r *http.Request) { } } else { if !c.App.SessionHasPermissionToChannel(c.App.Session, channel.Id, model.PERMISSION_READ_CHANNEL) { - c.SetPermissionError(model.PERMISSION_READ_CHANNEL) + c.Err = model.NewAppError("getChannelByName", store.MISSING_CHANNEL_ERROR, nil, "teamId="+channel.TeamId+", "+"name="+channel.Name+"", http.StatusNotFound) return } } @@ -1021,7 +1021,7 @@ func getChannelByNameForTeamName(c *Context, w http.ResponseWriter, r *http.Requ } if !c.App.SessionHasPermissionToChannel(c.App.Session, channel.Id, model.PERMISSION_READ_CHANNEL) { - c.SetPermissionError(model.PERMISSION_READ_CHANNEL) + c.Err = model.NewAppError("getChannelByNameForTeamName", store.MISSING_CHANNEL_ERROR, nil, "teamId="+channel.TeamId+", "+"name="+channel.Name+"", http.StatusNotFound) return } diff --git a/api4/channel_test.go b/api4/channel_test.go index 3422b36a26..c59b76d684 100644 --- a/api4/channel_test.go +++ b/api4/channel_test.go @@ -1500,7 +1500,7 @@ func TestGetChannelByName(t *testing.T) { Client.RemoveUserFromChannel(th.BasicPrivateChannel.Id, th.BasicUser.Id) _, resp = Client.GetChannelByName(th.BasicPrivateChannel.Name, th.BasicTeam.Id, "") - CheckForbiddenStatus(t, resp) + CheckNotFoundStatus(t, resp) _, resp = Client.GetChannelByName(GenerateTestChannelName(), th.BasicTeam.Id, "") CheckNotFoundStatus(t, resp) @@ -1553,7 +1553,7 @@ func TestGetChannelByNameForTeamName(t *testing.T) { user := th.CreateUser() Client.Login(user.Email, user.Password) _, resp = Client.GetChannelByNameForTeamName(th.BasicChannel.Name, th.BasicTeam.Name, "") - CheckForbiddenStatus(t, resp) + CheckNotFoundStatus(t, resp) } func TestGetChannelMembers(t *testing.T) { diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index 7d694eed29..f66ff0ebb0 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -1181,7 +1181,7 @@ func (s SqlChannelStore) getByName(teamId string, name string, includeDeleted bo if err := s.GetReplica().SelectOne(&channel, query, map[string]interface{}{"TeamId": teamId, "Name": name}); err != nil { if err == sql.ErrNoRows { - return nil, model.NewAppError("SqlChannelStore.GetByName", store.MISSING_CHANNEL_ERROR, nil, "teamId="+teamId+", "+"name="+name+", "+err.Error(), http.StatusNotFound) + return nil, model.NewAppError("SqlChannelStore.GetByName", store.MISSING_CHANNEL_ERROR, nil, "teamId="+teamId+", "+"name="+name+"", http.StatusNotFound) } return nil, model.NewAppError("SqlChannelStore.GetByName", "store.sql_channel.get_by_name.existing.app_error", nil, "teamId="+teamId+", "+"name="+name+", "+err.Error(), http.StatusInternalServerError) }