1
0
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:
Lukas Schulte Pelkum 2021-07-24 17:03:40 +02:00
parent e8f7fa239e
commit 6172ad463b
No known key found for this signature in database
GPG Key ID: 408DA7CA81DB885C
3 changed files with 11 additions and 7 deletions

8
API.md
View File

@ -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.

View File

@ -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

View File

@ -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 {