mirror of
https://github.com/idanoo/go-mastodon-matrix-webhooks.git
synced 2024-11-22 08:25:17 +00:00
Add account approval webhooks
This commit is contained in:
parent
aeb8ce3a5c
commit
0ade039548
99
main.go
99
main.go
@ -71,17 +71,24 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if i.Event == "report.created" {
|
if i.Event == "report.created" {
|
||||||
err = sendWebhook(
|
// Build message
|
||||||
|
msg := fmt.Sprintf(
|
||||||
|
"[New Report](%s): **%s** has reported **%s**: %s",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"[New Report](%s): **%s** has reported **%s**: %s",
|
"https://mastodon.nz/admin/reports/%s",
|
||||||
fmt.Sprintf(
|
i.Object.ID,
|
||||||
"https://mastodon.nz/admin/reports/%s",
|
|
||||||
i.Object.ID,
|
|
||||||
),
|
|
||||||
i.Object.Account.Username,
|
|
||||||
i.Object.TargetAccount.Username,
|
|
||||||
i.Object.Comment,
|
|
||||||
),
|
),
|
||||||
|
i.Object.Account.Username,
|
||||||
|
i.Object.TargetAccount.Username,
|
||||||
|
i.Object.Comment,
|
||||||
|
)
|
||||||
|
|
||||||
|
// Log to stdout
|
||||||
|
log.Println(msg)
|
||||||
|
|
||||||
|
// Send to matrix
|
||||||
|
err = sendWebhook(
|
||||||
|
msg,
|
||||||
MATRIX_REPORT_CHANNEL,
|
MATRIX_REPORT_CHANNEL,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -89,22 +96,29 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else if i.Event == "account.created" {
|
} else if i.Event == "account.created" {
|
||||||
|
// Build message
|
||||||
country := ipLookup(i.Object.IP)
|
country := ipLookup(i.Object.IP)
|
||||||
err = sendWebhook(
|
msg := fmt.Sprintf(
|
||||||
|
"[New Signup](%s) %s: **%s** (%s). %s",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"[New Signup](%s) %s: **%s** (%s). %s",
|
"https://mastodon.nz/admin/accounts/%s",
|
||||||
fmt.Sprintf(
|
i.Object.ID,
|
||||||
"https://mastodon.nz/admin/accounts/%s",
|
|
||||||
i.Object.ID,
|
|
||||||
),
|
|
||||||
country,
|
|
||||||
i.Object.Username,
|
|
||||||
i.Object.Email,
|
|
||||||
fmt.Sprintf(
|
|
||||||
"Notes: %s",
|
|
||||||
i.Object.Notes,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
country,
|
||||||
|
i.Object.Username,
|
||||||
|
i.Object.Email,
|
||||||
|
fmt.Sprintf(
|
||||||
|
"Notes: %s",
|
||||||
|
i.Object.Notes,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
// Log to stdout
|
||||||
|
log.Println(msg)
|
||||||
|
|
||||||
|
// Send to matrix
|
||||||
|
err = sendWebhook(
|
||||||
|
msg,
|
||||||
MATRIX_ACCOUNT_CHANNEL,
|
MATRIX_ACCOUNT_CHANNEL,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -112,24 +126,29 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else if i.Event == "account.approved" {
|
} else if i.Event == "account.approved" {
|
||||||
log.Println(r.Body)
|
msg := fmt.Sprintf(
|
||||||
// err = sendWebhook(
|
"Account Approved [%s](%s)",
|
||||||
// fmt.Sprintf(
|
i.Object.Username,
|
||||||
// "[New Report](%s): **%s** has approved **%s**: %s",
|
fmt.Sprintf(
|
||||||
// fmt.Sprintf(
|
"https://mastodon.nz/admin/accounts/%s",
|
||||||
// "https://mastodon.nz/admin/reports/%s",
|
i.Object.ID,
|
||||||
// i.Object.ID,
|
),
|
||||||
// ),
|
)
|
||||||
// i.Object.Account.Username,
|
|
||||||
// i.Object.TargetAccount.Username,
|
// Log to stdout
|
||||||
// i.Object.Comment,
|
log.Println(msg)
|
||||||
// ),
|
|
||||||
// MATRIX_REPORT_CHANNEL,
|
// Send to Matrix
|
||||||
// )
|
err = sendWebhook(
|
||||||
// if err != nil {
|
msg,
|
||||||
// log.Println(err.Error())
|
MATRIX_ACCOUNT_CHANNEL,
|
||||||
// return
|
)
|
||||||
// }
|
if err != nil {
|
||||||
|
log.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Printf("Unknown event %s", i.Event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user