add message in hub

This commit is contained in:
2026-04-28 20:17:37 +02:00
parent 79219971d0
commit a49f9f4615
18 changed files with 2125 additions and 51 deletions
+19 -19
View File
@@ -90,22 +90,22 @@ func getHubUserIfValidWithResponseOnFail(ctx context.Context, response http.Resp
return user, hubUser, hub, nil
}
//func getHubChannelIfValidWithResponseOnFail(ctx context.Context, response http.ResponseWriter, hub *types.Hub, hubUser *types.HubUser, channelId string) (
// *types.HubChannel, error) {
// channelUuid, err := convertions.StringToUuid(channelId)
// if err != nil {
// http.Error(response, "invalid channelid", http.StatusBadRequest)
// return nil, errors.New("invalid channelid")
// }
// channel, ok := hub.Channels[channelUuid]
// if !ok {
// http.Error(response, "invalid channelid", http.StatusBadRequest)
// return nil, errors.New("invalid channelid")
// }
//
// if !haveHubUserPermissionsOnChannel(types.CachedUserCanView, hubUser, channel) {
// return nil, errors.New("invalid channelid")
// }
//
// return channel, nil
//}
func getHubChannelIfValidWithResponseOnFail(ctx context.Context, response http.ResponseWriter, hub *types.Hub, hubUser *types.HubUser, channelId string) (
*types.HubChannel, error) {
channelUuid, err := convertions.StringToUuid(channelId)
if err != nil {
http.Error(response, "invalid channelid", http.StatusBadRequest)
return nil, errors.New("invalid channelid")
}
channel, ok := hub.Channels[channelUuid]
if !ok {
http.Error(response, "invalid channelid", http.StatusBadRequest)
return nil, errors.New("invalid channelid")
}
if !haveHubUserPermissionsOnChannel(types.CachedUserCanView, hubUser, channel) {
return nil, errors.New("invalid channelid")
}
return channel, nil
}