Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
9a2c4234
Commit
9a2c4234
authored
Apr 13, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update var-naming
parent
49f8cfd5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
14 additions
and
14 deletions
+14
-14
telegram.go
server/integration/telegram.go
+1
-1
memo_service.go
server/route/api/v2/memo_service.go
+1
-1
webhook_service.go
server/route/api/v2/webhook_service.go
+2
-2
webhook.go
store/db/mysql/webhook.go
+2
-2
webhook.go
store/db/postgres/webhook.go
+3
-3
webhook.go
store/db/sqlite/webhook.go
+3
-3
webhook.go
store/webhook.go
+1
-1
webhook_test.go
test/store/webhook_test.go
+1
-1
No files found.
server/integration/telegram.go
View file @
9a2c4234
...
...
@@ -282,7 +282,7 @@ func (t *TelegramHandler) dispatchMemoRelatedWebhook(ctx context.Context, memo s
for
_
,
hook
:=
range
webhooks
{
payload
:=
t
.
convertMemoToWebhookPayload
(
ctx
,
memo
)
payload
.
ActivityType
=
activityType
payload
.
URL
=
hook
.
U
rl
payload
.
URL
=
hook
.
U
RL
err
:=
webhook
.
Post
(
*
payload
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to post webhook"
)
...
...
server/route/api/v2/memo_service.go
View file @
9a2c4234
...
...
@@ -823,7 +823,7 @@ func (s *APIV2Service) dispatchMemoRelatedWebhook(ctx context.Context, memo *api
return
errors
.
Wrap
(
err
,
"failed to convert memo to webhook payload"
)
}
payload
.
ActivityType
=
activityType
payload
.
URL
=
hook
.
U
rl
payload
.
URL
=
hook
.
U
RL
if
err
:=
webhook
.
Post
(
*
payload
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to post webhook"
)
}
...
...
server/route/api/v2/webhook_service.go
View file @
9a2c4234
...
...
@@ -21,7 +21,7 @@ func (s *APIV2Service) CreateWebhook(ctx context.Context, request *apiv2pb.Creat
webhook
,
err
:=
s
.
Store
.
CreateWebhook
(
ctx
,
&
store
.
Webhook
{
CreatorID
:
currentUser
.
ID
,
Name
:
request
.
Name
,
U
rl
:
request
.
Url
,
U
RL
:
request
.
Url
,
})
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to create webhook, error: %+v"
,
err
)
...
...
@@ -114,6 +114,6 @@ func convertWebhookFromStore(webhook *store.Webhook) *apiv2pb.Webhook {
RowStatus
:
convertRowStatusFromStore
(
webhook
.
RowStatus
),
CreatorId
:
webhook
.
CreatorID
,
Name
:
webhook
.
Name
,
Url
:
webhook
.
U
rl
,
Url
:
webhook
.
U
RL
,
}
}
store/db/mysql/webhook.go
View file @
9a2c4234
...
...
@@ -10,7 +10,7 @@ import (
func
(
d
*
DB
)
CreateWebhook
(
ctx
context
.
Context
,
create
*
store
.
Webhook
)
(
*
store
.
Webhook
,
error
)
{
fields
:=
[]
string
{
"`name`"
,
"`url`"
,
"`creator_id`"
}
placeholder
:=
[]
string
{
"?"
,
"?"
,
"?"
}
args
:=
[]
any
{
create
.
Name
,
create
.
U
rl
,
create
.
CreatorID
}
args
:=
[]
any
{
create
.
Name
,
create
.
U
RL
,
create
.
CreatorID
}
stmt
:=
"INSERT INTO `webhook` ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
strings
.
Join
(
placeholder
,
", "
)
+
")"
result
,
err
:=
d
.
db
.
ExecContext
(
ctx
,
stmt
,
args
...
)
...
...
@@ -55,7 +55,7 @@ func (d *DB) ListWebhooks(ctx context.Context, find *store.FindWebhook) ([]*stor
&
rowStatus
,
&
webhook
.
CreatorID
,
&
webhook
.
Name
,
&
webhook
.
U
rl
,
&
webhook
.
U
RL
,
);
err
!=
nil
{
return
nil
,
err
}
...
...
store/db/postgres/webhook.go
View file @
9a2c4234
...
...
@@ -9,7 +9,7 @@ import (
func
(
d
*
DB
)
CreateWebhook
(
ctx
context
.
Context
,
create
*
store
.
Webhook
)
(
*
store
.
Webhook
,
error
)
{
fields
:=
[]
string
{
"name"
,
"url"
,
"creator_id"
}
args
:=
[]
any
{
create
.
Name
,
create
.
U
rl
,
create
.
CreatorID
}
args
:=
[]
any
{
create
.
Name
,
create
.
U
RL
,
create
.
CreatorID
}
stmt
:=
"INSERT INTO webhook ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
placeholders
(
len
(
args
))
+
") RETURNING id, created_ts, updated_ts, row_status"
var
rowStatus
string
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
args
...
)
.
Scan
(
...
...
@@ -65,7 +65,7 @@ func (d *DB) ListWebhooks(ctx context.Context, find *store.FindWebhook) ([]*stor
&
rowStatus
,
&
webhook
.
CreatorID
,
&
webhook
.
Name
,
&
webhook
.
U
rl
,
&
webhook
.
U
RL
,
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -103,7 +103,7 @@ func (d *DB) UpdateWebhook(ctx context.Context, update *store.UpdateWebhook) (*s
&
rowStatus
,
&
webhook
.
CreatorID
,
&
webhook
.
Name
,
&
webhook
.
U
rl
,
&
webhook
.
U
RL
,
);
err
!=
nil
{
return
nil
,
err
}
...
...
store/db/sqlite/webhook.go
View file @
9a2c4234
...
...
@@ -10,7 +10,7 @@ import (
func
(
d
*
DB
)
CreateWebhook
(
ctx
context
.
Context
,
create
*
store
.
Webhook
)
(
*
store
.
Webhook
,
error
)
{
fields
:=
[]
string
{
"`name`"
,
"`url`"
,
"`creator_id`"
}
placeholder
:=
[]
string
{
"?"
,
"?"
,
"?"
}
args
:=
[]
any
{
create
.
Name
,
create
.
U
rl
,
create
.
CreatorID
}
args
:=
[]
any
{
create
.
Name
,
create
.
U
RL
,
create
.
CreatorID
}
stmt
:=
"INSERT INTO `webhook` ("
+
strings
.
Join
(
fields
,
", "
)
+
") VALUES ("
+
strings
.
Join
(
placeholder
,
", "
)
+
") RETURNING `id`, `created_ts`, `updated_ts`, `row_status`"
var
rowStatus
string
if
err
:=
d
.
db
.
QueryRowContext
(
ctx
,
stmt
,
args
...
)
.
Scan
(
...
...
@@ -66,7 +66,7 @@ func (d *DB) ListWebhooks(ctx context.Context, find *store.FindWebhook) ([]*stor
&
rowStatus
,
&
webhook
.
CreatorID
,
&
webhook
.
Name
,
&
webhook
.
U
rl
,
&
webhook
.
U
RL
,
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -104,7 +104,7 @@ func (d *DB) UpdateWebhook(ctx context.Context, update *store.UpdateWebhook) (*s
&
rowStatus
,
&
webhook
.
CreatorID
,
&
webhook
.
Name
,
&
webhook
.
U
rl
,
&
webhook
.
U
RL
,
);
err
!=
nil
{
return
nil
,
err
}
...
...
store/webhook.go
View file @
9a2c4234
...
...
@@ -11,7 +11,7 @@ type Webhook struct {
CreatorID
int32
RowStatus
RowStatus
Name
string
U
rl
string
U
RL
string
}
type
FindWebhook
struct
{
...
...
test/store/webhook_test.go
View file @
9a2c4234
...
...
@@ -17,7 +17,7 @@ func TestWebhookStore(t *testing.T) {
webhook
,
err
:=
ts
.
CreateWebhook
(
ctx
,
&
store
.
Webhook
{
CreatorID
:
user
.
ID
,
Name
:
"test_webhook"
,
U
rl
:
"https://example.com"
,
U
RL
:
"https://example.com"
,
RowStatus
:
store
.
Normal
,
})
require
.
NoError
(
t
,
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment