@@ -8,23 +8,33 @@ import (
88 "time"
99
1010 "github.com/pkg/errors"
11-
12- v1pb "github.com/usememos/memos/proto/gen/api/v1"
1311)
1412
1513var (
1614 // timeout is the timeout for webhook request. Default to 30 seconds.
1715 timeout = 30 * time .Second
1816)
1917
18+ type Memo struct {
19+ // The name of the memo.
20+ // Format: memos/{id}
21+ // id is the system generated id.
22+ Name string
23+ // The name of the creator.
24+ // Format: users/{id}
25+ Creator string
26+ // The raw content.
27+ Content string
28+ }
29+
2030// WebhookPayload is the payload of webhook request.
2131// nolint
2232type WebhookPayload struct {
23- URL string `json:"url"`
24- ActivityType string `json:"activityType"`
25- CreatorID int32 `json:"creatorId"`
26- CreatedTs int64 `json:"createdTs"`
27- Memo * v1pb. Memo `json:"memo"`
33+ URL string `json:"url"`
34+ ActivityType string `json:"activityType"`
35+ CreatorID int32 `json:"creatorId"`
36+ CreatedTs int64 `json:"createdTs"`
37+ Memo * Memo `json:"memo"`
2838}
2939
3040// WebhookResponse is the response of webhook request.
@@ -40,8 +50,8 @@ func Post(payload WebhookPayload) error {
4050 if err != nil {
4151 return errors .Wrapf (err , "failed to marshal webhook request to %s" , payload .URL )
4252 }
43- req , err := http . NewRequest ( "POST" ,
44- payload .URL , bytes .NewBuffer (body ))
53+
54+ req , err := http . NewRequest ( "POST" , payload .URL , bytes .NewBuffer (body ))
4555 if err != nil {
4656 return errors .Wrapf (err , "failed to construct webhook request to %s" , payload .URL )
4757 }
0 commit comments