aboutsummaryrefslogtreecommitdiff
path: root/mastodon/report.go
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2019-12-13 18:08:26 +0000
committerr <r@freesoftwareextremist.com>2019-12-13 18:26:24 +0000
commit5e4da01c3ae3ae2e870faba9085d9d9213c01c29 (patch)
tree39d6f1e76b901549f194ddbac3c6cb82e0abd019 /mastodon/report.go
downloadbloat-5e4da01c3ae3ae2e870faba9085d9d9213c01c29.tar.gz
bloat-5e4da01c3ae3ae2e870faba9085d9d9213c01c29.zip
Initial commit
Diffstat (limited to 'mastodon/report.go')
-rw-r--r--mastodon/report.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/mastodon/report.go b/mastodon/report.go
new file mode 100644
index 0000000..920614a
--- /dev/null
+++ b/mastodon/report.go
@@ -0,0 +1,39 @@
+package mastodon
+
+import (
+ "context"
+ "net/http"
+ "net/url"
+)
+
+// Report hold information for mastodon report.
+type Report struct {
+ ID int64 `json:"id"`
+ ActionTaken bool `json:"action_taken"`
+}
+
+// GetReports return report of the current user.
+func (c *Client) GetReports(ctx context.Context) ([]*Report, error) {
+ var reports []*Report
+ err := c.doAPI(ctx, http.MethodGet, "/api/v1/reports", nil, &reports, nil)
+ if err != nil {
+ return nil, err
+ }
+ return reports, nil
+}
+
+// Report reports the report
+func (c *Client) Report(ctx context.Context, accountID string, ids []string, comment string) (*Report, error) {
+ params := url.Values{}
+ params.Set("account_id", string(accountID))
+ for _, id := range ids {
+ params.Add("status_ids[]", string(id))
+ }
+ params.Set("comment", comment)
+ var report Report
+ err := c.doAPI(ctx, http.MethodPost, "/api/v1/reports", params, &report, nil)
+ if err != nil {
+ return nil, err
+ }
+ return &report, nil
+}