Edit comments

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian 2020-08-27 18:49:30 -04:00
parent a14cb3a3c8
commit 73945e9aae
11 changed files with 45 additions and 46 deletions

View file

@ -101,7 +101,7 @@ func (s *CollectionService) FromSubreddit(ctx context.Context, id string) ([]*Co
return collections, resp, nil
}
// Create creates a collection.
// Create a collection.
func (s *CollectionService) Create(ctx context.Context, createRequest *CollectionCreateRequest) (*Collection, *Response, error) {
if createRequest == nil {
return nil, nil, errors.New("createRequest: cannot be nil")
@ -128,7 +128,7 @@ func (s *CollectionService) Create(ctx context.Context, createRequest *Collectio
return collection, resp, nil
}
// Delete deletes a collection via its id.
// Delete a collection via its id.
func (s *CollectionService) Delete(ctx context.Context, id string) (*Response, error) {
path := "api/v1/collections/delete_collection"
@ -255,7 +255,7 @@ func (s *CollectionService) UpdateLayoutGallery(ctx context.Context, id string)
return s.client.Do(ctx, req, nil)
}
// Follow follows a collection.
// Follow a collection.
func (s *CollectionService) Follow(ctx context.Context, id string) (*Response, error) {
path := "api/v1/collections/follow_collection"
@ -271,7 +271,7 @@ func (s *CollectionService) Follow(ctx context.Context, id string) (*Response, e
return s.client.Do(ctx, req, nil)
}
// Unfollow unfollows a collection.
// Unfollow a collection.
func (s *CollectionService) Unfollow(ctx context.Context, id string) (*Response, error) {
path := "api/v1/collections/follow_collection"

View file

@ -17,7 +17,7 @@ type CommentService struct {
client *Client
}
// Submit submits a comment as a reply to a post, comment, or message.
// Submit a comment as a reply to a post, comment, or message.
// parentID is the full ID of the thing being replied to.
func (s *CommentService) Submit(ctx context.Context, parentID string, text string) (*Comment, *Response, error) {
path := "api/comment"
@ -42,7 +42,7 @@ func (s *CommentService) Submit(ctx context.Context, parentID string, text strin
return root, resp, nil
}
// Edit edits a comment.
// Edit a comment.
func (s *CommentService) Edit(ctx context.Context, id string, text string) (*Comment, *Response, error) {
path := "api/editusertext"

View file

@ -73,7 +73,7 @@ func (e *emojis) UnmarshalJSON(data []byte) (err error) {
return
}
// Get returns the default set of Reddit emojis, and those of the subreddit, respectively.
// Get the default set of Reddit emojis and those of the subreddit, respectively.
func (s *EmojiService) Get(ctx context.Context, subreddit string) ([]*Emoji, []*Emoji, *Response, error) {
path := fmt.Sprintf("api/v1/%s/emojis/all", subreddit)
@ -101,7 +101,7 @@ func (s *EmojiService) Get(ctx context.Context, subreddit string) ([]*Emoji, []*
return defaultEmojis, subredditEmojis, resp, nil
}
// Delete deletes the emoji from the subreddit.
// Delete the emoji from the subreddit.
func (s *EmojiService) Delete(ctx context.Context, subreddit string, emoji string) (*Response, error) {
path := fmt.Sprintf("api/v1/%s/emoji/%s", subreddit, emoji)
@ -199,7 +199,7 @@ func (s *EmojiService) upload(ctx context.Context, subreddit string, createReque
return s.client.Do(ctx, req, nil)
}
// Upload uploads an emoji to the subreddit.
// Upload an emoji to the subreddit.
func (s *EmojiService) Upload(ctx context.Context, subreddit string, createRequest *EmojiCreateOrUpdateRequest, imagePath string) (*Response, error) {
if createRequest == nil {
return nil, errors.New("createRequest: cannot be nil")

View file

@ -15,7 +15,7 @@ type ListingsService struct {
client *Client
}
// Get returns posts, comments, and subreddits from their full IDs.
// Get posts, comments, and subreddits from their full IDs.
func (s *ListingsService) Get(ctx context.Context, ids ...string) ([]*Post, []*Comment, []*Subreddit, *Response, error) {
path := fmt.Sprintf("api/info?id=%s", strings.Join(ids, ","))

View file

@ -171,8 +171,7 @@ func (s *MessageService) Unread(ctx context.Context, ids ...string) (*Response,
return s.client.Do(ctx, req, nil)
}
// Block blocks the author of a thing via the thing's full ID.
// The thing can be a post, comment or message.
// Block the author of a post, comment or message via its full ID.
func (s *MessageService) Block(ctx context.Context, id string) (*Response, error) {
path := "api/block"
@ -187,7 +186,7 @@ func (s *MessageService) Block(ctx context.Context, id string) (*Response, error
return s.client.Do(ctx, req, nil)
}
// Collapse collapses messages.
// Collapse messages.
func (s *MessageService) Collapse(ctx context.Context, ids ...string) (*Response, error) {
if len(ids) == 0 {
return nil, errors.New("must provide at least 1 id")
@ -206,7 +205,7 @@ func (s *MessageService) Collapse(ctx context.Context, ids ...string) (*Response
return s.client.Do(ctx, req, nil)
}
// Uncollapse uncollapses messages.
// Uncollapse messages.
func (s *MessageService) Uncollapse(ctx context.Context, ids ...string) (*Response, error) {
if len(ids) == 0 {
return nil, errors.New("must provide at least 1 id")
@ -225,7 +224,7 @@ func (s *MessageService) Uncollapse(ctx context.Context, ids ...string) (*Respon
return s.client.Do(ctx, req, nil)
}
// Delete deletes a message.
// Delete a message.
func (s *MessageService) Delete(ctx context.Context, id string) (*Response, error) {
path := "api/del_msg"
@ -240,7 +239,7 @@ func (s *MessageService) Delete(ctx context.Context, id string) (*Response, erro
return s.client.Do(ctx, req, nil)
}
// Send sends a message.
// Send a message.
func (s *MessageService) Send(ctx context.Context, sendRequest *SendMessageRequest) (*Response, error) {
if sendRequest == nil {
return nil, errors.New("sendRequest: cannot be nil")

View file

@ -84,7 +84,7 @@ func (s *ModerationService) AcceptInvite(ctx context.Context, subreddit string)
return s.client.Do(ctx, req, nil)
}
// Approve approves a post or comment via its full ID.
// Approve a post or comment via its full ID.
func (s *ModerationService) Approve(ctx context.Context, id string) (*Response, error) {
path := "api/approve"
@ -99,7 +99,7 @@ func (s *ModerationService) Approve(ctx context.Context, id string) (*Response,
return s.client.Do(ctx, req, nil)
}
// Remove removes a post, comment or modmail message via its full ID.
// Remove a post, comment or modmail message via its full ID.
func (s *ModerationService) Remove(ctx context.Context, id string) (*Response, error) {
path := "api/remove"
@ -340,7 +340,7 @@ func (s *ModerationService) Unban(ctx context.Context, subreddit string, usernam
return s.deleteRelationship(ctx, subreddit, username, "banned")
}
// BanWiki a user from contributing to the subreddit wiki.
// BanWiki bans a user from contributing to the subreddit wiki.
func (s *ModerationService) BanWiki(ctx context.Context, subreddit string, username string, config *BanConfig) (*Response, error) {
path := fmt.Sprintf("r/%s/api/friend", subreddit)
@ -361,7 +361,7 @@ func (s *ModerationService) BanWiki(ctx context.Context, subreddit string, usern
return s.client.Do(ctx, req, nil)
}
// UnbanWiki a user from contributing to the subreddit wiki.
// UnbanWiki unbans a user from contributing to the subreddit wiki.
func (s *ModerationService) UnbanWiki(ctx context.Context, subreddit string, username string) (*Response, error) {
return s.deleteRelationship(ctx, subreddit, username, "wikibanned")
}

View file

@ -119,7 +119,7 @@ type rootMultiDescription struct {
} `json:"data"`
}
// Get gets information about the multireddit from its url path.
// Get the multireddit from its url path.
func (s *MultiService) Get(ctx context.Context, multiPath string) (*Multi, *Response, error) {
path := fmt.Sprintf("api/multi/%s", multiPath)
@ -184,7 +184,7 @@ func (s *MultiService) Of(ctx context.Context, username string) ([]Multi, *Respo
return multis, resp, nil
}
// Copy copies a multireddit.
// Copy a multireddit.
func (s *MultiService) Copy(ctx context.Context, copyRequest *MultiCopyRequest) (*Multi, *Response, error) {
if copyRequest == nil {
return nil, nil, errors.New("copyRequest: cannot be nil")
@ -210,7 +210,7 @@ func (s *MultiService) Copy(ctx context.Context, copyRequest *MultiCopyRequest)
return root.Data, resp, nil
}
// Create creates a multireddit.
// Create a multireddit.
func (s *MultiService) Create(ctx context.Context, createRequest *MultiCreateOrUpdateRequest) (*Multi, *Response, error) {
if createRequest == nil {
return nil, nil, errors.New("createRequest: cannot be nil")
@ -232,7 +232,7 @@ func (s *MultiService) Create(ctx context.Context, createRequest *MultiCreateOrU
return root.Data, resp, nil
}
// Update updates a multireddit.
// Update a multireddit.
// If the multireddit does not exist, it will be created.
func (s *MultiService) Update(ctx context.Context, multiPath string, updateRequest *MultiCreateOrUpdateRequest) (*Multi, *Response, error) {
if updateRequest == nil {
@ -255,7 +255,7 @@ func (s *MultiService) Update(ctx context.Context, multiPath string, updateReque
return root.Data, resp, nil
}
// Delete deletes a multireddit.
// Delete a multireddit.
func (s *MultiService) Delete(ctx context.Context, multiPath string) (*Response, error) {
path := fmt.Sprintf("api/multi/%s", multiPath)

View file

@ -25,7 +25,7 @@ const (
upvote
)
// Delete deletes a post or comment via its full ID.
// Delete a post or comment via its full ID.
func (s *postAndCommentService) Delete(ctx context.Context, id string) (*Response, error) {
path := "api/del"
@ -40,7 +40,7 @@ func (s *postAndCommentService) Delete(ctx context.Context, id string) (*Respons
return s.client.Do(ctx, req, nil)
}
// Save saves a post or comment.
// Save a post or comment.
func (s *postAndCommentService) Save(ctx context.Context, id string) (*Response, error) {
path := "api/save"
@ -55,7 +55,7 @@ func (s *postAndCommentService) Save(ctx context.Context, id string) (*Response,
return s.client.Do(ctx, req, nil)
}
// Unsave unsaves a post or comment.
// Unsave a post or comment.
func (s *postAndCommentService) Unsave(ctx context.Context, id string) (*Response, error) {
path := "api/unsave"
@ -102,7 +102,7 @@ func (s *postAndCommentService) DisableReplies(ctx context.Context, id string) (
return s.client.Do(ctx, req, nil)
}
// Lock locks a post or comment, preventing it from receiving new comments.
// Lock a post or comment, preventing it from receiving new comments.
func (s *postAndCommentService) Lock(ctx context.Context, id string) (*Response, error) {
path := "api/lock"
@ -117,7 +117,7 @@ func (s *postAndCommentService) Lock(ctx context.Context, id string) (*Response,
return s.client.Do(ctx, req, nil)
}
// Unlock unlocks a post or comment, allowing it to receive new comments.
// Unlock a post or comment, allowing it to receive new comments.
func (s *postAndCommentService) Unlock(ctx context.Context, id string) (*Response, error) {
path := "api/unlock"
@ -148,12 +148,12 @@ func (s *postAndCommentService) vote(ctx context.Context, id string, vote vote)
return s.client.Do(ctx, req, nil)
}
// Upvote upvotes a post or a comment.
// Upvote a post or a comment.
func (s *postAndCommentService) Upvote(ctx context.Context, id string) (*Response, error) {
return s.vote(ctx, id, upvote)
}
// Downvote downvotes a post or a comment.
// Downvote a post or a comment.
func (s *postAndCommentService) Downvote(ctx context.Context, id string) (*Response, error) {
return s.vote(ctx, id, downvote)
}

View file

@ -62,7 +62,7 @@ type SubmitLinkOptions struct {
Spoiler bool `url:"spoiler,omitempty"`
}
// Get returns a post with its comments.
// Get a post with its comments.
// id is the ID36 of the post, not its full id.
// Example: instead of t3_abc123, use abc123.
func (s *PostService) Get(ctx context.Context, id string) (*PostAndComments, *Response, error) {
@ -149,7 +149,7 @@ func (s *PostService) SubmitLink(ctx context.Context, opts SubmitLinkOptions) (*
return s.submit(ctx, &submit{opts, "link"})
}
// Edit edits a post.
// Edit a post.
func (s *PostService) Edit(ctx context.Context, id string, text string) (*Post, *Response, error) {
path := "api/editusertext"
@ -173,7 +173,7 @@ func (s *PostService) Edit(ctx context.Context, id string, text string) (*Post,
return root, resp, nil
}
// Hide hides posts.
// Hide posts.
func (s *PostService) Hide(ctx context.Context, ids ...string) (*Response, error) {
if len(ids) == 0 {
return nil, errors.New("must provide at least 1 id")
@ -192,7 +192,7 @@ func (s *PostService) Hide(ctx context.Context, ids ...string) (*Response, error
return s.client.Do(ctx, req, nil)
}
// Unhide unhides posts.
// Unhide posts.
func (s *PostService) Unhide(ctx context.Context, ids ...string) (*Response, error) {
if len(ids) == 0 {
return nil, errors.New("must provide at least 1 id")
@ -271,7 +271,7 @@ func (s *PostService) Unspoiler(ctx context.Context, id string) (*Response, erro
return s.client.Do(ctx, req, nil)
}
// Sticky stickies a post in its subreddit.
// Sticky a post in its subreddit.
// When bottom is true, the post will be set as the bottom sticky (the 2nd one).
// If no top sticky exists, the post will become the top sticky regardless.
// When attempting to sticky a post that's already stickied, it will return a 409 Conflict error.

View file

@ -135,7 +135,7 @@ func (s *SubredditService) TopPosts(ctx context.Context, subreddit string, opts
return s.getPosts(ctx, "top", subreddit, opts)
}
// Get gets a subreddit by name.
// Get a subreddit by name.
func (s *SubredditService) Get(ctx context.Context, name string) (*Subreddit, *Response, error) {
if name == "" {
return nil, nil, errors.New("name: cannot be empty")
@ -245,7 +245,7 @@ func (s *SubredditService) UnsubscribeByID(ctx context.Context, ids ...string) (
return s.handleSubscription(ctx, form)
}
// Favorite favorites the subreddit.
// Favorite the subreddit.
func (s *SubredditService) Favorite(ctx context.Context, subreddit string) (*Response, error) {
path := "api/favorite"
@ -262,7 +262,7 @@ func (s *SubredditService) Favorite(ctx context.Context, subreddit string) (*Res
return s.client.Do(ctx, req, nil)
}
// Unfavorite unfavorites the subreddit.
// Unfavorite the subreddit.
func (s *SubredditService) Unfavorite(ctx context.Context, subreddit string) (*Response, error) {
path := "api/favorite"
@ -279,7 +279,7 @@ func (s *SubredditService) Unfavorite(ctx context.Context, subreddit string) (*R
return s.client.Do(ctx, req, nil)
}
// Search searches for subreddits.
// Search for subreddits.
func (s *SubredditService) Search(ctx context.Context, query string, opts *ListSubredditOptions) (*Subreddits, *Response, error) {
path := "subreddits/search"
path, err := addOptions(path, opts)

View file

@ -367,7 +367,7 @@ func (s *UserService) GetFriendship(ctx context.Context, username string) (*Rela
return root, resp, nil
}
// Friend friends a user.
// Friend a user.
func (s *UserService) Friend(ctx context.Context, username string) (*Relationship, *Response, error) {
type request struct {
Username string `json:"name"`
@ -390,7 +390,7 @@ func (s *UserService) Friend(ctx context.Context, username string) (*Relationshi
return root, resp, nil
}
// Unfriend unfriends a user.
// Unfriend a user.
func (s *UserService) Unfriend(ctx context.Context, username string) (*Response, error) {
path := fmt.Sprintf("api/v1/me/friends/%s", username)
req, err := s.client.NewRequest(http.MethodDelete, path, nil)
@ -400,7 +400,7 @@ func (s *UserService) Unfriend(ctx context.Context, username string) (*Response,
return s.client.Do(ctx, req, nil)
}
// Block blocks a user.
// Block a user.
func (s *UserService) Block(ctx context.Context, username string) (*Blocked, *Response, error) {
path := "api/block_user"
@ -442,7 +442,7 @@ func (s *UserService) BlockByID(ctx context.Context, id string) (*Blocked, *Resp
return root, resp, nil
}
// Unblock unblocks a user.
// Unblock a user.
func (s *UserService) Unblock(ctx context.Context, username string) (*Response, error) {
selfID, resp, err := s.client.id(ctx)
if err != nil {
@ -560,7 +560,7 @@ func (s *UserService) New(ctx context.Context, opts *ListUserOverviewOptions) (*
return root.getSubreddits(), resp, nil
}
// Search searches for users.
// Search for users.
// todo: maybe include the sort option? (relevance, activity)
func (s *UserService) Search(ctx context.Context, query string, opts *ListOptions) (*Users, *Response, error) {
path := "users/search"