@@ -8,23 +8,33 @@ import (
8
8
"time"
9
9
10
10
"github.com/pkg/errors"
11
-
12
- v1pb "github.com/usememos/memos/proto/gen/api/v1"
13
11
)
14
12
15
13
var (
16
14
// timeout is the timeout for webhook request. Default to 30 seconds.
17
15
timeout = 30 * time .Second
18
16
)
19
17
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
+
20
30
// WebhookPayload is the payload of webhook request.
21
31
// nolint
22
32
type 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"`
28
38
}
29
39
30
40
// WebhookResponse is the response of webhook request.
@@ -40,8 +50,8 @@ func Post(payload WebhookPayload) error {
40
50
if err != nil {
41
51
return errors .Wrapf (err , "failed to marshal webhook request to %s" , payload .URL )
42
52
}
43
- req , err := http . NewRequest ( "POST" ,
44
- payload .URL , bytes .NewBuffer (body ))
53
+
54
+ req , err := http . NewRequest ( "POST" , payload .URL , bytes .NewBuffer (body ))
45
55
if err != nil {
46
56
return errors .Wrapf (err , "failed to construct webhook request to %s" , payload .URL )
47
57
}
0 commit comments