rethink needed

This commit is contained in:
2026-04-26 21:56:00 +02:00
parent 472b4ea703
commit ca084a21fa
3 changed files with 33 additions and 23 deletions
+2 -19
View File
@@ -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