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) }