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
f1308ddd
Commit
f1308ddd
authored
Jan 19, 2025
by
johnnyjoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: update part of resource identifier
parent
cda18a37
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
190 additions
and
178 deletions
+190
-178
memo_service.proto
proto/api/v1/memo_service.proto
+5
-3
reaction_service.proto
proto/api/v1/reaction_service.proto
+2
-0
memo_service.pb.go
proto/gen/api/v1/memo_service.pb.go
+158
-158
memo_service.pb.gw.go
proto/gen/api/v1/memo_service.pb.gw.go
+11
-11
reaction_service.pb.go
proto/gen/api/v1/reaction_service.pb.go
+3
-1
apidocs.swagger.yaml
proto/gen/apidocs.swagger.yaml
+8
-2
reaction_service.go
server/router/api/v1/reaction_service.go
+1
-1
ReactionSelector.tsx
web/src/components/ReactionSelector.tsx
+1
-1
ReactionView.tsx
web/src/components/ReactionView.tsx
+1
-1
No files found.
proto/api/v1/memo_service.proto
View file @
f1308ddd
...
...
@@ -116,8 +116,8 @@ service MemoService {
}
// DeleteMemoReaction deletes a reaction for a memo.
rpc
DeleteMemoReaction
(
DeleteMemoReactionRequest
)
returns
(
google.protobuf.Empty
)
{
option
(
google.api.http
)
=
{
delete
:
"/api/v1/reactions/{
reaction_
id}"
};
option
(
google.api.method_signature
)
=
"
reaction_
id"
;
option
(
google.api.http
)
=
{
delete
:
"/api/v1/reactions/{id}"
};
option
(
google.api.method_signature
)
=
"id"
;
}
}
...
...
@@ -336,5 +336,7 @@ message UpsertMemoReactionRequest {
}
message
DeleteMemoReactionRequest
{
int32
reaction_id
=
1
;
// The id of the reaction.
// Refer to the `Reaction.id`.
int32
id
=
1
;
}
proto/api/v1/reaction_service.proto
View file @
f1308ddd
...
...
@@ -11,6 +11,8 @@ message Reaction {
// Format: users/{user}
string
creator
=
2
;
// The content identifier.
// For memo, it should be the `Memo.name`.
string
content_id
=
3
;
string
reaction_type
=
4
;
...
...
proto/gen/api/v1/memo_service.pb.go
View file @
f1308ddd
This diff is collapsed.
Click to expand it.
proto/gen/api/v1/memo_service.pb.gw.go
View file @
f1308ddd
...
...
@@ -703,13 +703,13 @@ func request_MemoService_DeleteMemoReaction_0(ctx context.Context, marshaler run
metadata
runtime
.
ServerMetadata
err
error
)
val
,
ok
:=
pathParams
[
"
reaction_
id"
]
val
,
ok
:=
pathParams
[
"id"
]
if
!
ok
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing parameter %s"
,
"
reaction_
id"
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing parameter %s"
,
"id"
)
}
protoReq
.
Reaction
Id
,
err
=
runtime
.
Int32
(
val
)
protoReq
.
Id
,
err
=
runtime
.
Int32
(
val
)
if
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"type mismatch, parameter: %s, error: %v"
,
"
reaction_
id"
,
err
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"type mismatch, parameter: %s, error: %v"
,
"id"
,
err
)
}
msg
,
err
:=
client
.
DeleteMemoReaction
(
ctx
,
&
protoReq
,
grpc
.
Header
(
&
metadata
.
HeaderMD
),
grpc
.
Trailer
(
&
metadata
.
TrailerMD
))
return
msg
,
metadata
,
err
...
...
@@ -721,13 +721,13 @@ func local_request_MemoService_DeleteMemoReaction_0(ctx context.Context, marshal
metadata
runtime
.
ServerMetadata
err
error
)
val
,
ok
:=
pathParams
[
"
reaction_
id"
]
val
,
ok
:=
pathParams
[
"id"
]
if
!
ok
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing parameter %s"
,
"
reaction_
id"
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"missing parameter %s"
,
"id"
)
}
protoReq
.
Reaction
Id
,
err
=
runtime
.
Int32
(
val
)
protoReq
.
Id
,
err
=
runtime
.
Int32
(
val
)
if
err
!=
nil
{
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"type mismatch, parameter: %s, error: %v"
,
"
reaction_
id"
,
err
)
return
nil
,
metadata
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"type mismatch, parameter: %s, error: %v"
,
"id"
,
err
)
}
msg
,
err
:=
server
.
DeleteMemoReaction
(
ctx
,
&
protoReq
)
return
msg
,
metadata
,
err
...
...
@@ -1065,7 +1065,7 @@ func RegisterMemoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
var
stream
runtime
.
ServerTransportStream
ctx
=
grpc
.
NewContextWithServerTransportStream
(
ctx
,
&
stream
)
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
annotatedContext
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
,
"/memos.api.v1.MemoService/DeleteMemoReaction"
,
runtime
.
WithHTTPPathPattern
(
"/api/v1/reactions/{
reaction_
id}"
))
annotatedContext
,
err
:=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
,
"/memos.api.v1.MemoService/DeleteMemoReaction"
,
runtime
.
WithHTTPPathPattern
(
"/api/v1/reactions/{id}"
))
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
...
...
@@ -1395,7 +1395,7 @@ func RegisterMemoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
ctx
,
cancel
:=
context
.
WithCancel
(
req
.
Context
())
defer
cancel
()
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
annotatedContext
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
,
"/memos.api.v1.MemoService/DeleteMemoReaction"
,
runtime
.
WithHTTPPathPattern
(
"/api/v1/reactions/{
reaction_
id}"
))
annotatedContext
,
err
:=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
,
"/memos.api.v1.MemoService/DeleteMemoReaction"
,
runtime
.
WithHTTPPathPattern
(
"/api/v1/reactions/{id}"
))
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
...
...
@@ -1428,7 +1428,7 @@ var (
pattern_MemoService_ListMemoComments_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
,
1
,
0
,
4
,
2
,
5
,
3
,
2
,
4
},
[]
string
{
"api"
,
"v1"
,
"memos"
,
"name"
,
"comments"
},
""
))
pattern_MemoService_ListMemoReactions_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
,
1
,
0
,
4
,
2
,
5
,
3
,
2
,
4
},
[]
string
{
"api"
,
"v1"
,
"memos"
,
"name"
,
"reactions"
},
""
))
pattern_MemoService_UpsertMemoReaction_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
,
1
,
0
,
4
,
2
,
5
,
3
,
2
,
4
},
[]
string
{
"api"
,
"v1"
,
"memos"
,
"name"
,
"reactions"
},
""
))
pattern_MemoService_DeleteMemoReaction_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
,
1
,
0
,
4
,
1
,
5
,
3
},
[]
string
{
"api"
,
"v1"
,
"reactions"
,
"
reaction_
id"
},
""
))
pattern_MemoService_DeleteMemoReaction_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
,
1
,
0
,
4
,
1
,
5
,
3
},
[]
string
{
"api"
,
"v1"
,
"reactions"
,
"id"
},
""
))
)
var
(
...
...
proto/gen/api/v1/reaction_service.pb.go
View file @
f1308ddd
...
...
@@ -25,7 +25,9 @@ type Reaction struct {
Id
int32
`protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
// The name of the creator.
// Format: users/{user}
Creator
string
`protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"`
Creator
string
`protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"`
// The content identifier.
// For memo, it should be the `Memo.name`.
ContentId
string
`protobuf:"bytes,3,opt,name=content_id,json=contentId,proto3" json:"content_id,omitempty"`
ReactionType
string
`protobuf:"bytes,4,opt,name=reaction_type,json=reactionType,proto3" json:"reaction_type,omitempty"`
unknownFields
protoimpl
.
UnknownFields
...
...
proto/gen/apidocs.swagger.yaml
View file @
f1308ddd
...
...
@@ -367,7 +367,7 @@ paths:
type
:
string
tags
:
-
MemoService
/api/v1/reactions/{
reactionI
d}
:
/api/v1/reactions/{
i
d}
:
delete
:
summary
:
DeleteMemoReaction deletes a reaction for a memo.
operationId
:
MemoService_DeleteMemoReaction
...
...
@@ -382,7 +382,10 @@ paths:
schema
:
$ref
:
'
#/definitions/googlerpcStatus'
parameters
:
-
name
:
reactionId
-
name
:
id
description
:
|-
The id of the reaction.
Refer to the `Reaction.id`.
in: path
required: true
type: integer
...
...
@@ -2911,6 +2914,9 @@ definitions:
Format: users/{user}
contentId
:
type
:
string
description
:
|-
The content identifier.
For memo, it should be the `Memo.name`.
reactionType
:
type
:
string
v1ReferencedContentNode
:
...
...
server/router/api/v1/reaction_service.go
View file @
f1308ddd
...
...
@@ -56,7 +56,7 @@ func (s *APIV1Service) UpsertMemoReaction(ctx context.Context, request *v1pb.Ups
func
(
s
*
APIV1Service
)
DeleteMemoReaction
(
ctx
context
.
Context
,
request
*
v1pb
.
DeleteMemoReactionRequest
)
(
*
emptypb
.
Empty
,
error
)
{
if
err
:=
s
.
Store
.
DeleteReaction
(
ctx
,
&
store
.
DeleteReaction
{
ID
:
request
.
Reaction
Id
,
ID
:
request
.
Id
,
});
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to delete reaction"
)
}
...
...
web/src/components/ReactionSelector.tsx
View file @
f1308ddd
...
...
@@ -41,7 +41,7 @@ const ReactionSelector = (props: Props) => {
(
reaction
)
=>
reaction
.
reactionType
===
reactionType
&&
reaction
.
creator
===
currentUser
.
name
,
);
for
(
const
reaction
of
reactions
)
{
await
memoServiceClient
.
deleteMemoReaction
({
reactionI
d
:
reaction
.
id
});
await
memoServiceClient
.
deleteMemoReaction
({
i
d
:
reaction
.
id
});
}
}
else
{
await
memoServiceClient
.
upsertMemoReaction
({
...
...
web/src/components/ReactionView.tsx
View file @
f1308ddd
...
...
@@ -55,7 +55,7 @@ const ReactionView = (props: Props) => {
(
reaction
)
=>
reaction
.
reactionType
===
reactionType
&&
reaction
.
creator
===
currentUser
.
name
,
);
for
(
const
reaction
of
reactions
)
{
await
memoServiceClient
.
deleteMemoReaction
({
reactionI
d
:
reaction
.
id
});
await
memoServiceClient
.
deleteMemoReaction
({
i
d
:
reaction
.
id
});
}
}
}
catch
(
error
)
{
...
...
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