report.go 959 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package mastodon
  2. import (
  3. "context"
  4. "net/http"
  5. "net/url"
  6. )
  7. // Report hold information for mastodon report.
  8. type Report struct {
  9. ID int64 `json:"id"`
  10. ActionTaken bool `json:"action_taken"`
  11. }
  12. // GetReports return report of the current user.
  13. func (c *Client) GetReports(ctx context.Context) ([]*Report, error) {
  14. var reports []*Report
  15. err := c.doAPI(ctx, http.MethodGet, "/api/v1/reports", nil, &reports, nil)
  16. if err != nil {
  17. return nil, err
  18. }
  19. return reports, nil
  20. }
  21. // Report reports the report
  22. func (c *Client) Report(ctx context.Context, accountID string, ids []string, comment string) (*Report, error) {
  23. params := url.Values{}
  24. params.Set("account_id", string(accountID))
  25. for _, id := range ids {
  26. params.Add("status_ids[]", string(id))
  27. }
  28. params.Set("comment", comment)
  29. var report Report
  30. err := c.doAPI(ctx, http.MethodPost, "/api/v1/reports", params, &report, nil)
  31. if err != nil {
  32. return nil, err
  33. }
  34. return &report, nil
  35. }