inital commit

This commit is contained in:
2026-05-26 20:21:55 +02:00
parent 965f9d6ad4
commit 0ae20aa68d
21 changed files with 651 additions and 111 deletions

View File

@@ -24,26 +24,26 @@ type PostCommentOptions struct {
// URL with fields `action=reply`, `replyto=<parent>`, `reply=<body>`.
// There is no separate per-form CSRF key auth cookies + Cloudflare
// clearance are the only gates.
func (c *Client) PostSubmissionComment(ctx context.Context, id SubmissionID, body string, opts PostCommentOptions) error {
func (c *Client) PostSubmissionComment(ctx context.Context, id SubmissionID, body string, opts PostCommentOptions, reqOpts ...Option) error {
if id <= 0 {
return fmt.Errorf("fa: PostSubmissionComment: id must be > 0")
}
return c.postCommentForm(ctx, urls.Submission(int64(id)), body, opts)
return c.postCommentForm(ctx, urls.Submission(int64(id)), body, opts, reqOpts)
}
// PostJournalComment posts a comment on a journal. Same form shape as
// submissions; the form action just points at /journal/{id}/.
func (c *Client) PostJournalComment(ctx context.Context, id JournalID, body string, opts PostCommentOptions) error {
func (c *Client) PostJournalComment(ctx context.Context, id JournalID, body string, opts PostCommentOptions, reqOpts ...Option) error {
if id <= 0 {
return fmt.Errorf("fa: PostJournalComment: id must be > 0")
}
return c.postCommentForm(ctx, urls.Journal(int64(id)), body, opts)
return c.postCommentForm(ctx, urls.Journal(int64(id)), body, opts, reqOpts)
}
// postCommentForm builds the field set #add_comment_form sends. Shared
// between submission and journal comment posting because FA renders an
// identical form on both pages.
func (c *Client) postCommentForm(ctx context.Context, pageURL, body string, opts PostCommentOptions) error {
func (c *Client) postCommentForm(ctx context.Context, pageURL, body string, opts PostCommentOptions, reqOpts []Option) error {
if body == "" {
return fmt.Errorf("fa: PostComment: empty body")
}
@@ -57,6 +57,6 @@ func (c *Client) postCommentForm(ctx context.Context, pageURL, body string, opts
}
v.Set("reply", body)
v.Set("submit", "Post Comment")
_, err := c.postForm(ctx, pageURL, v)
_, err := c.postForm(ctx, pageURL, v, reqOpts...)
return err
}