GraphQL API and utilities for the rpdata project
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package queries
import ( "context" "errors"
"git.aiterp.net/rpdata/api/internal/auth" "git.aiterp.net/rpdata/api/models" "git.aiterp.net/rpdata/api/models/stories" )
func (r *resolver) Story(ctx context.Context, id string) (models.Story, error) { return stories.FindID(id) }
func (r *resolver) Stories(ctx context.Context, filter *stories.Filter) ([]models.Story, error) { if filter != nil { if filter.Unlisted != nil && *filter.Unlisted == true { token := auth.TokenFromContext(ctx) if !token.Authenticated() { return nil, errors.New("You are not permitted to view unlisted stories") }
if !token.Permitted("story.unlisted") { filter.Author = &token.UserID } } }
return stories.List(filter) }
|