mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
Update paste report webhook request
This commit is contained in:
parent
e8f7fa239e
commit
6172ad463b
8
API.md
8
API.md
@ -180,5 +180,11 @@ POST /api/v2/pastes/{paste_id}/report
|
|||||||
|
|
||||||
**Notes:**
|
**Notes:**
|
||||||
* The endpoint is only available if the report system is enabled. Otherwise it will return a `404 Not Found` error.
|
* The endpoint is only available if the report system is enabled. Otherwise it will return a `404 Not Found` error.
|
||||||
* The request for this endpoint is the exact same that will reach the webhook.
|
* The request that will reach the report webhook looks like this:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"paste": "paste_id",
|
||||||
|
"reason": "reason"
|
||||||
|
}
|
||||||
|
```
|
||||||
* The response from this endpoint is the exact same that pasty expects from the webhook.
|
* The response from this endpoint is the exact same that pasty expects from the webhook.
|
@ -10,9 +10,8 @@ import (
|
|||||||
|
|
||||||
// ReportRequest represents a report request sent to the report webhook
|
// ReportRequest represents a report request sent to the report webhook
|
||||||
type ReportRequest struct {
|
type ReportRequest struct {
|
||||||
Paste string `json:"paste"`
|
Paste string `json:"paste"`
|
||||||
Reason string `json:"reason"`
|
Reason string `json:"reason"`
|
||||||
Timestamp int64 `json:"timestamp"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReportResponse represents a report response received from the report webhook
|
// ReportResponse represents a report response received from the report webhook
|
||||||
|
@ -255,9 +255,8 @@ func endpointReportPaste(ctx *fasthttp.RequestCtx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
request := &report.ReportRequest{
|
request := &report.ReportRequest{
|
||||||
Paste: ctx.UserValue("_paste").(*shared.Paste).ID,
|
Paste: ctx.UserValue("_paste").(*shared.Paste).ID,
|
||||||
Reason: payload.Reason,
|
Reason: payload.Reason,
|
||||||
Timestamp: time.Now().Unix(),
|
|
||||||
}
|
}
|
||||||
response, err := report.SendReport(request)
|
response, err := report.SendReport(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user