added nsfw flag to search functions
This commit is contained in:
@@ -558,6 +558,8 @@ type ListSubredditOptions struct {
|
||||
ListOptions
|
||||
// One of: relevance, activity.
|
||||
Sort string `url:"sort,omitempty"`
|
||||
|
||||
IncludeNsfw bool `url:"include_over_18,omitempty"`
|
||||
}
|
||||
|
||||
// ListPostOptions defines possible options used when getting posts from a subreddit.
|
||||
@@ -572,6 +574,8 @@ type ListPostSearchOptions struct {
|
||||
ListPostOptions
|
||||
// One of: relevance, hot, top, new, comments.
|
||||
Sort string `url:"sort,omitempty"`
|
||||
|
||||
IncludeNsfw bool `url:"include_over_18,omitempty"`
|
||||
}
|
||||
|
||||
// ListUserOverviewOptions defines possible options used when getting a user's post and/or comments.
|
||||
|
||||
+2
-2
@@ -499,7 +499,7 @@ func (s *SubredditService) Unfavorite(ctx context.Context, subreddit string) (*R
|
||||
|
||||
// Search for subreddits.
|
||||
func (s *SubredditService) Search(ctx context.Context, query string, opts *ListSubredditOptions) ([]*Subreddit, *Response, error) {
|
||||
path := fmt.Sprintf("subreddits/search?q=%s&include_over_18=on", query)
|
||||
path := fmt.Sprintf("subreddits/search?q=%s", query)
|
||||
l, resp, err := s.client.getListing(ctx, path, opts)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
@@ -533,7 +533,7 @@ func (s *SubredditService) SearchPosts(ctx context.Context, query string, subred
|
||||
subreddit = "all"
|
||||
}
|
||||
|
||||
path := fmt.Sprintf("r/%s/search?include_over_18=on", subreddit)
|
||||
path := fmt.Sprintf("r/%s/search", subreddit)
|
||||
path, err := addOptions(path, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
Reference in New Issue
Block a user