|
@ -5,6 +5,7 @@ import ( |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
"git.aiterp.net/rpdata/api/graphql/resolver/types" |
|
|
"git.aiterp.net/rpdata/api/graphql/resolver/types" |
|
|
|
|
|
"git.aiterp.net/rpdata/api/internal/session" |
|
|
"git.aiterp.net/rpdata/api/model/story" |
|
|
"git.aiterp.net/rpdata/api/model/story" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@ -19,6 +20,8 @@ type StoriesArg struct { |
|
|
EarliestFictionalDate *string |
|
|
EarliestFictionalDate *string |
|
|
LatestFictionalDate *string |
|
|
LatestFictionalDate *string |
|
|
Limit *int32 |
|
|
Limit *int32 |
|
|
|
|
|
Open *bool |
|
|
|
|
|
Unlisted *bool |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -58,12 +61,28 @@ func (r *QueryResolver) Stories(ctx context.Context, args *StoriesArg) ([]*types |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unlisted := filter.Unlisted != nil && *filter.Unlisted == true |
|
|
|
|
|
if unlisted { |
|
|
|
|
|
user := session.FromContext(ctx).User() |
|
|
|
|
|
if user == nil { |
|
|
|
|
|
return nil, ErrUnauthorized |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if author != "" && author != user.ID && !user.Permitted("story.unlisted") { |
|
|
|
|
|
return nil, ErrPermissionDenied |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
author = user.ID |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
open := filter.Open |
|
|
|
|
|
|
|
|
limit := 30 |
|
|
limit := 30 |
|
|
if filter != nil && filter.Limit != nil { |
|
|
if filter != nil && filter.Limit != nil { |
|
|
limit = int(*filter.Limit) |
|
|
limit = int(*filter.Limit) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
stories, err := story.List(author, tags, earliest, latest, limit) |
|
|
|
|
|
|
|
|
stories, err := story.List(author, tags, earliest, latest, unlisted, open, limit) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|