add hub function
This commit is contained in:
@@ -36,15 +36,15 @@ func getUserByToken(ctx context.Context, token string) (*types.User, error) {
|
||||
return getUserById(ctx, userId)
|
||||
}
|
||||
|
||||
func getConnectionWithResponseOnFail(response *http.ResponseWriter, request *http.Request, user *types.User) (*types.Connection, bool) {
|
||||
connectionId, err := convertions.StringToUuid(request.FormValue("connectionid"))
|
||||
func getConnectionWithResponseOnFail(response http.ResponseWriter, connectionIdStr string, user *types.User) (*types.Connection, bool) {
|
||||
connectionId, err := convertions.StringToUuid(connectionIdStr)
|
||||
if err != nil {
|
||||
http.Error(*response, "invalid connectionid", http.StatusBadRequest)
|
||||
http.Error(response, "invalid connectionid", http.StatusBadRequest)
|
||||
return nil, false
|
||||
}
|
||||
conn, ok := cache.GetConnection(user, connectionId)
|
||||
if !ok {
|
||||
http.Error(*response, "invalid connectionid", http.StatusBadRequest)
|
||||
http.Error(response, "invalid connectionid", http.StatusBadRequest)
|
||||
return nil, false
|
||||
}
|
||||
return conn, true
|
||||
@@ -104,7 +104,8 @@ func getHubChannelIfValidWithResponseOnFail(ctx context.Context, response http.R
|
||||
}
|
||||
|
||||
if !haveHubUserCachedPermissions(types.CachedUserCanView, hubUser, channel) {
|
||||
return nil, errors.New("invalid channelid")
|
||||
http.Error(response, "forbidden", http.StatusForbidden)
|
||||
return nil, errors.New("forbidden")
|
||||
}
|
||||
|
||||
return channel, nil
|
||||
|
||||
Reference in New Issue
Block a user