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
5ff8ab9a
Commit
5ff8ab9a
authored
Jan 10, 2025
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: polish creator definition
parent
8b7e9f54
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
234 additions
and
210 deletions
+234
-210
activity_service.proto
proto/api/v1/activity_service.proto
+3
-2
webhook_service.proto
proto/api/v1/webhook_service.proto
+9
-3
activity_service.pb.go
proto/gen/api/v1/activity_service.pb.go
+63
-63
webhook_service.pb.go
proto/gen/api/v1/webhook_service.pb.go
+125
-120
apidocs.swagger.yaml
proto/gen/apidocs.swagger.yaml
+20
-13
activity_service.go
server/router/api/v1/activity_service.go
+1
-1
memo_service.go
server/router/api/v1/memo_service.go
+1
-1
webhook_service.go
server/router/api/v1/webhook_service.go
+8
-2
WebhookSection.tsx
web/src/components/Settings/WebhookSection.tsx
+4
-5
No files found.
proto/api/v1/activity_service.proto
View file @
5ff8ab9a
...
...
@@ -21,8 +21,9 @@ message Activity {
// The name of the activity.
// Format: activities/{id}
string
name
=
1
;
// The uid of the user who created the activity.
int32
creator_id
=
2
;
// The name of the creator.
// Format: users/{user}
string
creator
=
2
;
// The type of the activity.
string
type
=
3
;
// The level of the activity.
...
...
proto/api/v1/webhook_service.proto
View file @
5ff8ab9a
...
...
@@ -46,7 +46,9 @@ service WebhookService {
message
Webhook
{
int32
id
=
1
;
int32
creator_id
=
2
;
// The name of the creator.
// Format: users/{user}
string
creator
=
2
;
google.protobuf.Timestamp
create_time
=
3
;
...
...
@@ -68,7 +70,9 @@ message GetWebhookRequest {
}
message
ListWebhooksRequest
{
int32
creator_id
=
1
;
// The name of the creator.
// Format: users/{user}
string
creator
=
2
;
}
message
ListWebhooksResponse
{
...
...
@@ -90,7 +94,9 @@ message WebhookRequestPayload {
string
activity_type
=
2
;
int32
creator_id
=
3
;
// The name of the creator.
// Format: users/{user}
string
creator
=
3
;
google.protobuf.Timestamp
create_time
=
4
;
...
...
proto/gen/api/v1/activity_service.pb.go
View file @
5ff8ab9a
This diff is collapsed.
Click to expand it.
proto/gen/api/v1/webhook_service.pb.go
View file @
5ff8ab9a
This diff is collapsed.
Click to expand it.
proto/gen/apidocs.swagger.yaml
View file @
5ff8ab9a
...
...
@@ -531,11 +531,13 @@ paths:
schema
:
$ref
:
'
#/definitions/googlerpcStatus'
parameters
:
-
name
:
creatorId
-
name
:
creator
description
:
|-
The name of the creator.
Format: users/{user}
in: query
required: false
type
:
integer
format
:
int32
type: string
tags
:
-
WebhookService
post
:
...
...
@@ -625,9 +627,11 @@ paths:
schema
:
type
:
object
properties
:
creatorId
:
type
:
integer
format
:
int32
creator
:
type
:
string
title
:
|-
The name of the creator.
Format: users/{user}
createTime
:
type
:
string
format
:
date-time
...
...
@@ -2335,10 +2339,11 @@ definitions:
title
:
|-
The name of the activity.
Format: activities/{id}
creatorId
:
type
:
integer
format
:
int32
description
:
The uid of the user who created the activity.
creator
:
type
:
string
title
:
|-
The name of the creator.
Format: users/{user}
type
:
type
:
string
description
:
The type of the activity.
...
...
@@ -3083,9 +3088,11 @@ definitions:
id
:
type
:
integer
format
:
int32
creatorId
:
type
:
integer
format
:
int32
creator
:
type
:
string
title
:
|-
The name of the creator.
Format: users/{user}
createTime
:
type
:
string
format
:
date-time
...
...
server/router/api/v1/activity_service.go
View file @
5ff8ab9a
...
...
@@ -36,7 +36,7 @@ func (s *APIV1Service) GetActivity(ctx context.Context, request *v1pb.GetActivit
func
(
*
APIV1Service
)
convertActivityFromStore
(
_
context
.
Context
,
activity
*
store
.
Activity
)
(
*
v1pb
.
Activity
,
error
)
{
return
&
v1pb
.
Activity
{
Name
:
fmt
.
Sprintf
(
"%s%d"
,
ActivityNamePrefix
,
activity
.
ID
),
Creator
Id
:
activity
.
CreatorID
,
Creator
:
fmt
.
Sprintf
(
"%s%d"
,
UserNamePrefix
,
activity
.
CreatorID
)
,
Type
:
activity
.
Type
.
String
(),
Level
:
activity
.
Level
.
String
(),
CreateTime
:
timestamppb
.
New
(
time
.
Unix
(
activity
.
CreatedTs
,
0
)),
...
...
server/router/api/v1/memo_service.go
View file @
5ff8ab9a
...
...
@@ -670,7 +670,7 @@ func convertMemoToWebhookPayload(memo *v1pb.Memo) (*v1pb.WebhookRequestPayload,
return
nil
,
errors
.
Wrap
(
err
,
"invalid memo creator"
)
}
return
&
v1pb
.
WebhookRequestPayload
{
Creator
Id
:
creatorID
,
Creator
:
fmt
.
Sprintf
(
"%s%d"
,
UserNamePrefix
,
creatorID
)
,
CreateTime
:
timestamppb
.
New
(
time
.
Now
()),
Memo
:
memo
,
},
nil
...
...
server/router/api/v1/webhook_service.go
View file @
5ff8ab9a
...
...
@@ -2,6 +2,7 @@ package v1
import
(
"context"
"fmt"
"time"
"google.golang.org/grpc/codes"
...
...
@@ -31,8 +32,13 @@ func (s *APIV1Service) CreateWebhook(ctx context.Context, request *v1pb.CreateWe
}
func
(
s
*
APIV1Service
)
ListWebhooks
(
ctx
context
.
Context
,
request
*
v1pb
.
ListWebhooksRequest
)
(
*
v1pb
.
ListWebhooksResponse
,
error
)
{
creatorID
,
err
:=
ExtractUserIDFromName
(
request
.
Creator
)
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"invalid creator name: %v"
,
err
)
}
webhooks
,
err
:=
s
.
Store
.
ListWebhooks
(
ctx
,
&
store
.
FindWebhook
{
CreatorID
:
&
request
.
CreatorId
,
CreatorID
:
&
creatorID
,
})
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to list webhooks, error: %+v"
,
err
)
...
...
@@ -103,7 +109,7 @@ func convertWebhookFromStore(webhook *store.Webhook) *v1pb.Webhook {
Id
:
webhook
.
ID
,
CreateTime
:
timestamppb
.
New
(
time
.
Unix
(
webhook
.
CreatedTs
,
0
)),
UpdateTime
:
timestamppb
.
New
(
time
.
Unix
(
webhook
.
UpdatedTs
,
0
)),
Creator
Id
:
webhook
.
CreatorID
,
Creator
:
fmt
.
Sprintf
(
"%s%d"
,
UserNamePrefix
,
webhook
.
CreatorID
)
,
Name
:
webhook
.
Name
,
Url
:
webhook
.
URL
,
}
...
...
web/src/components/Settings/WebhookSection.tsx
View file @
5ff8ab9a
...
...
@@ -4,14 +4,13 @@ import { useEffect, useState } from "react";
import
{
Link
}
from
"react-router-dom"
;
import
{
webhookServiceClient
}
from
"@/grpcweb"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
{
extractUserIdFromName
}
from
"@/store/v1"
;
import
{
Webhook
}
from
"@/types/proto/api/v1/webhook_service"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
showCreateWebhookDialog
from
"../CreateWebhookDialog"
;
const
listWebhooks
=
async
(
user
Id
:
number
)
=>
{
const
listWebhooks
=
async
(
user
:
string
)
=>
{
const
{
webhooks
}
=
await
webhookServiceClient
.
listWebhooks
({
creator
Id
:
userId
,
creator
:
user
,
});
return
webhooks
;
};
...
...
@@ -22,13 +21,13 @@ const WebhookSection = () => {
const
[
webhooks
,
setWebhooks
]
=
useState
<
Webhook
[]
>
([]);
useEffect
(()
=>
{
listWebhooks
(
extractUserIdFromName
(
currentUser
.
name
)
).
then
((
webhooks
)
=>
{
listWebhooks
(
currentUser
.
name
).
then
((
webhooks
)
=>
{
setWebhooks
(
webhooks
);
});
},
[]);
const
handleCreateAccessTokenDialogConfirm
=
async
()
=>
{
const
webhooks
=
await
listWebhooks
(
extractUserIdFromName
(
currentUser
.
name
)
);
const
webhooks
=
await
listWebhooks
(
currentUser
.
name
);
setWebhooks
(
webhooks
);
};
...
...
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