rethink needed
This commit is contained in:
@@ -3,7 +3,6 @@ package httpRequest
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"go-socket/packages/convertions"
|
||||
@@ -100,29 +99,13 @@ func getHubChannelIfValidWithResponseOnFail(ctx context.Context, response http.R
|
||||
}
|
||||
channel, ok := hub.Channels[channelUuid]
|
||||
if !ok {
|
||||
http.Error(response, "invalid channelid", http.StatusUnauthorized)
|
||||
http.Error(response, "invalid channelid", http.StatusBadRequest)
|
||||
return nil, errors.New("invalid channelid")
|
||||
}
|
||||
|
||||
group := hub.Groups[channel.ParentId]
|
||||
if group == nil {
|
||||
slog.Warn("hub channel has no parent group", "Hub", hub.Id, "Channel", channel.Id)
|
||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
||||
return nil, errors.New("internal server error")
|
||||
}
|
||||
|
||||
if !group.RolesCanView.HasSameId(hubUser.Roles) {
|
||||
http.Error(response, "invalid channelid", http.StatusUnauthorized)
|
||||
return nil, errors.New("invalid channelid")
|
||||
}
|
||||
|
||||
if !channel.RolesCanView.HasSameId(hubUser.Roles) {
|
||||
http.Error(response, "invalid channelid", http.StatusUnauthorized)
|
||||
if !haveUserPermissionsOnChannel(types.CachedUserCanView, hubUser, channel) {
|
||||
return nil, errors.New("invalid channelid")
|
||||
}
|
||||
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
// TODO cache on roles or channels needed for quick lookup
|
||||
func getHubChannelReadHistorayAndViewChannel(hub *types.Hub, channel *types.HubChannel) []*types.HubUser
|
||||
|
||||
Reference in New Issue
Block a user