go-mastodon/report.go

37 lines
794 B
Go

package mastodon
import (
"net/http"
"net/url"
)
// Report holds information for a mastodon report.
type Report struct {
ID int64 `json:"id"`
ActionTaken bool `json:"action_taken"`
}
func GetReports() ([]*Report, error) {
var reports []*Report
err := doAPI(http.MethodGet, "/api/v1/reports", nil, &reports, nil)
if err != nil {
return nil, err
}
return reports, nil
}
func ReportAccount(accountID ID, ids []ID, 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 := doAPI(http.MethodPost, "/api/v1/reports", params, &report, nil)
if err != nil {
return nil, err
}
return &report, nil
}