2017-04-16 21:51:16 +02:00
|
|
|
package mastodon
|
|
|
|
|
2017-04-17 05:36:27 +02:00
|
|
|
import (
|
|
|
|
"net/http"
|
2017-04-19 11:09:43 +02:00
|
|
|
"net/url"
|
2017-04-17 05:36:27 +02:00
|
|
|
)
|
2017-04-16 21:51:16 +02:00
|
|
|
|
2022-11-13 22:14:40 +01:00
|
|
|
// Report holds information for a mastodon report.
|
2017-04-16 21:51:16 +02:00
|
|
|
type Report struct {
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
ActionTaken bool `json:"action_taken"`
|
|
|
|
}
|
|
|
|
|
2022-11-13 22:14:40 +01:00
|
|
|
// GetReports returns report of the current user.
|
2022-11-20 18:03:36 +01:00
|
|
|
func (c *Client) GetReports() ([]*Report, error) {
|
2017-04-17 05:39:41 +02:00
|
|
|
var reports []*Report
|
2022-11-20 18:03:36 +01:00
|
|
|
err := c.doAPI(http.MethodGet, "/api/v1/reports", nil, &reports, nil)
|
2017-04-16 21:51:16 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-04-17 05:39:41 +02:00
|
|
|
return reports, nil
|
2017-04-16 21:51:16 +02:00
|
|
|
}
|
|
|
|
|
2017-04-20 14:20:40 +02:00
|
|
|
// Report reports the report
|
2022-11-20 18:03:36 +01:00
|
|
|
func (c *Client) Report(accountID ID, ids []ID, comment string) (*Report, error) {
|
2017-04-19 11:09:43 +02:00
|
|
|
params := url.Values{}
|
2017-10-25 08:22:17 +02:00
|
|
|
params.Set("account_id", string(accountID))
|
2017-04-19 11:09:43 +02:00
|
|
|
for _, id := range ids {
|
2017-10-25 08:22:17 +02:00
|
|
|
params.Add("status_ids[]", string(id))
|
2017-04-19 11:09:43 +02:00
|
|
|
}
|
|
|
|
params.Set("comment", comment)
|
2017-04-16 21:51:16 +02:00
|
|
|
var report Report
|
2022-11-20 18:03:36 +01:00
|
|
|
err := c.doAPI(http.MethodPost, "/api/v1/reports", params, &report, nil)
|
2017-04-16 21:51:16 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-04-17 05:36:27 +02:00
|
|
|
return &report, nil
|
2017-04-16 21:51:16 +02:00
|
|
|
}
|