36 lines
750 B
Go
36 lines
750 B
Go
package mastodon
|
|
|
|
import (
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
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 (a *Account) Report(statuses []*Status, comment string) (*Report, error) {
|
|
params := url.Values{}
|
|
params.Set("account_id", a.GetID())
|
|
for _, status := range statuses {
|
|
params.Add("status_ids[]", status.GetID())
|
|
}
|
|
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
|
|
}
|