From 43e6cab6a6218b7568a63a9d4bc865ea813a0a5b Mon Sep 17 00:00:00 2001 From: idanoo Date: Sun, 20 Nov 2022 19:09:08 +1300 Subject: [PATCH] Add report stuff --- main.go | 16 +++++++++++++++- structs.go | 16 +++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 91ce3ed..fe64e49 100644 --- a/main.go +++ b/main.go @@ -65,7 +65,21 @@ func handler(w http.ResponseWriter, r *http.Request) { } if i.Event == "report.created" { - err = sendWebhook("New report!") + err = sendWebhook( + fmt.Sprintf( + "[New Report](%s): %s has reported %s for %s", + fmt.Sprintf( + "https://mastodon.nz/admin/reports/%s", + i.Object.ID, + ), + i.Object.Account.Username, + i.Object.TargetAccount.Username, + fmt.Sprintf( + "Comments: %s", + i.Object.Comment, + ), + ), + ) if err != nil { log.Println(err.Error()) return diff --git a/structs.go b/structs.go index 59e49c3..9d0d984 100644 --- a/structs.go +++ b/structs.go @@ -10,11 +10,17 @@ type MatrixWebhook struct { type MastodonEvent struct { Event string `json:"event"` Object struct { - ID string `json:"id"` - Username string `json:"username"` - Email string `json:"email"` - IP string `json:"ip"` - Notes string `json:"invite_request"` + ID string `json:"id"` + Username string `json:"username"` + Email string `json:"email"` + IP string `json:"ip"` + Notes string `json:"invite_request"` + Comment string `json:"comment"` + Account struct { + ID string `json:"id"` + Username string `json:"username"` + Domain interface{} `json:"domain"` + } `json:"account"` TargetAccount struct { ID string `json:"id"` Username string `json:"username"`