Commit 5f2d6b22 authored by Steven's avatar Steven

chore: tweak memo structure

parent 2dc8ed77
......@@ -26,28 +26,27 @@ service MemoService {
rpc ListMemos(ListMemosRequest) returns (ListMemosResponse) {
option (google.api.http) = {get: "/api/v2/memos"};
}
// GetMemo gets a memo by id.
rpc GetMemo(GetMemoRequest) returns (GetMemoResponse) {
option (google.api.http) = {get: "/api/v2/memos/{id}"};
option (google.api.method_signature) = "id";
// SearchMemosRequest searches memos.
rpc SearchMemos(SearchMemosRequest) returns (SearchMemosResponse) {
option (google.api.http) = {get: "/api/v2/memos:search"};
}
// GetMemoByName gets a memo by name.
rpc GetMemoByName(GetMemoByNameRequest) returns (GetMemoByNameResponse) {
option (google.api.http) = {get: "/api/v2/memos/name/{name}"};
// GetMemo gets a memo.
rpc GetMemo(GetMemoRequest) returns (GetMemoResponse) {
option (google.api.http) = {get: "/api/v2/{name=memos/*}"};
option (google.api.method_signature) = "name";
}
// UpdateMemo updates a memo.
rpc UpdateMemo(UpdateMemoRequest) returns (UpdateMemoResponse) {
option (google.api.http) = {
patch: "/api/v2/memos/{memo.id}"
patch: "/api/v2/{memo.name=memos/*}"
body: "memo"
};
option (google.api.method_signature) = "memo,update_mask";
}
// DeleteMemo deletes a memo by id.
// DeleteMemo deletes a memo.
rpc DeleteMemo(DeleteMemoRequest) returns (DeleteMemoResponse) {
option (google.api.http) = {delete: "/api/v2/memos/{id}"};
option (google.api.method_signature) = "id";
option (google.api.http) = {delete: "/api/v2/{name=memos/*}"};
option (google.api.method_signature) = "name";
}
// ExportMemos exports memos.
rpc ExportMemos(ExportMemosRequest) returns (ExportMemosResponse) {
......@@ -56,38 +55,38 @@ service MemoService {
// SetMemoResources sets resources for a memo.
rpc SetMemoResources(SetMemoResourcesRequest) returns (SetMemoResourcesResponse) {
option (google.api.http) = {
post: "/api/v2/memos/{id}/resources"
post: "/api/v2/{name=memos/*}/resources"
body: "*"
};
option (google.api.method_signature) = "id";
option (google.api.method_signature) = "name";
}
// ListMemoResources lists resources for a memo.
rpc ListMemoResources(ListMemoResourcesRequest) returns (ListMemoResourcesResponse) {
option (google.api.http) = {get: "/api/v2/memos/{id}/resources"};
option (google.api.method_signature) = "id";
option (google.api.http) = {get: "/api/v2/{name=memos/*}/resources"};
option (google.api.method_signature) = "name";
}
// SetMemoRelations sets relations for a memo.
rpc SetMemoRelations(SetMemoRelationsRequest) returns (SetMemoRelationsResponse) {
option (google.api.http) = {
post: "/api/v2/memos/{id}/relations"
post: "/api/v2/{name=memos/*}/relations"
body: "*"
};
option (google.api.method_signature) = "id";
option (google.api.method_signature) = "name";
}
// ListMemoRelations lists relations for a memo.
rpc ListMemoRelations(ListMemoRelationsRequest) returns (ListMemoRelationsResponse) {
option (google.api.http) = {get: "/api/v2/memos/{id}/relations"};
option (google.api.method_signature) = "id";
option (google.api.http) = {get: "/api/v2/{name=memos/*}/relations"};
option (google.api.method_signature) = "name";
}
// CreateMemoComment creates a comment for a memo.
rpc CreateMemoComment(CreateMemoCommentRequest) returns (CreateMemoCommentResponse) {
option (google.api.http) = {post: "/api/v2/memos/{id}/comments"};
option (google.api.method_signature) = "id";
option (google.api.http) = {post: "/api/v2/{name=memos/*}/comments"};
option (google.api.method_signature) = "name";
}
// ListMemoComments lists comments for a memo.
rpc ListMemoComments(ListMemoCommentsRequest) returns (ListMemoCommentsResponse) {
option (google.api.http) = {get: "/api/v2/memos/{id}/comments"};
option (google.api.method_signature) = "id";
option (google.api.http) = {get: "/api/v2/{name=memos/*}/comments"};
option (google.api.method_signature) = "name";
}
// GetUserMemosStats gets stats of memos for a user.
rpc GetUserMemosStats(GetUserMemosStatsRequest) returns (GetUserMemosStatsResponse) {
......@@ -96,18 +95,18 @@ service MemoService {
}
// ListMemoReactions lists reactions for a memo.
rpc ListMemoReactions(ListMemoReactionsRequest) returns (ListMemoReactionsResponse) {
option (google.api.http) = {get: "/api/v2/memos/{id}/reactions"};
option (google.api.method_signature) = "id";
option (google.api.http) = {get: "/api/v2/{name=memos/*}/reactions"};
option (google.api.method_signature) = "name";
}
// UpsertMemoReaction upserts a reaction for a memo.
rpc UpsertMemoReaction(UpsertMemoReactionRequest) returns (UpsertMemoReactionResponse) {
option (google.api.http) = {post: "/api/v2/memos/{id}/reactions"};
option (google.api.method_signature) = "id";
option (google.api.http) = {post: "/api/v2/{name=memos/*}/reactions"};
option (google.api.method_signature) = "name";
}
// DeleteMemoReaction deletes a reaction for a memo.
rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (DeleteMemoReactionResponse) {
option (google.api.http) = {delete: "/api/v2/memos/{id}/reactions/{reaction_id}"};
option (google.api.method_signature) = "id,reaction_id";
option (google.api.http) = {delete: "/api/v2/{name=memos/*}/reactions/{reaction_id}"};
option (google.api.method_signature) = "name,reaction_id";
}
}
......@@ -122,11 +121,11 @@ enum Visibility {
}
message Memo {
// id is the system generated unique identifier.
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
// name is the user provided name.
string name = 2;
string resource_id = 2;
RowStatus row_status = 3;
......@@ -186,19 +185,23 @@ message ListMemosResponse {
string next_page_token = 2;
}
message GetMemoRequest {
int32 id = 1;
message SearchMemosRequest {
// Filter is used to filter memos returned.
// Format: "creator == users/{uid} && visibilities == ['PUBLIC', 'PROTECTED']"
string filter = 1;
}
message GetMemoResponse {
Memo memo = 1;
message SearchMemosResponse {
repeated Memo memos = 1;
}
message GetMemoByNameRequest {
message GetMemoRequest {
// The name of the memo.
// Format: memos/{uid}
string name = 1;
}
message GetMemoByNameResponse {
message GetMemoResponse {
Memo memo = 1;
}
......@@ -213,7 +216,9 @@ message UpdateMemoResponse {
}
message DeleteMemoRequest {
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
}
message DeleteMemoResponse {}
......@@ -228,7 +233,9 @@ message ExportMemosResponse {
}
message SetMemoResourcesRequest {
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
repeated Resource resources = 2;
}
......@@ -236,7 +243,9 @@ message SetMemoResourcesRequest {
message SetMemoResourcesResponse {}
message ListMemoResourcesRequest {
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
}
message ListMemoResourcesResponse {
......@@ -244,7 +253,9 @@ message ListMemoResourcesResponse {
}
message SetMemoRelationsRequest {
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
repeated MemoRelation relations = 2;
}
......@@ -252,7 +263,9 @@ message SetMemoRelationsRequest {
message SetMemoRelationsResponse {}
message ListMemoRelationsRequest {
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
}
message ListMemoRelationsResponse {
......@@ -260,10 +273,11 @@ message ListMemoRelationsResponse {
}
message CreateMemoCommentRequest {
// id is the memo id to create comment for.
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
CreateMemoRequest create = 2;
CreateMemoRequest comment = 2;
}
message CreateMemoCommentResponse {
......@@ -271,7 +285,9 @@ message CreateMemoCommentResponse {
}
message ListMemoCommentsRequest {
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
}
message ListMemoCommentsResponse {
......@@ -280,7 +296,7 @@ message ListMemoCommentsResponse {
message GetUserMemosStatsRequest {
// name is the name of the user to get stats for.
// Format: users/{username}
// Format: users/{uid}
string name = 1;
// timezone location
......@@ -299,7 +315,9 @@ message GetUserMemosStatsResponse {
}
message ListMemoReactionsRequest {
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
}
message ListMemoReactionsResponse {
......@@ -307,7 +325,9 @@ message ListMemoReactionsResponse {
}
message UpsertMemoReactionRequest {
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
Reaction reaction = 2;
}
......@@ -317,7 +337,9 @@ message UpsertMemoReactionResponse {
}
message DeleteMemoReactionRequest {
int32 id = 1;
// The name of the memo.
// Format: memos/{uid}
string name = 1;
int32 reaction_id = 2;
}
......
......@@ -19,7 +19,7 @@ service UserService {
// SearchUsers searches users by filter.
rpc SearchUsers(SearchUsersRequest) returns (SearchUsersResponse) {
option (google.api.http) = {get: "/api/v2/users/search"};
option (google.api.http) = {get: "/api/v2/users:search"};
}
// GetUser gets a user by name.
......
......@@ -122,8 +122,6 @@
- [DeleteMemoResponse](#memos-api-v2-DeleteMemoResponse)
- [ExportMemosRequest](#memos-api-v2-ExportMemosRequest)
- [ExportMemosResponse](#memos-api-v2-ExportMemosResponse)
- [GetMemoByNameRequest](#memos-api-v2-GetMemoByNameRequest)
- [GetMemoByNameResponse](#memos-api-v2-GetMemoByNameResponse)
- [GetMemoRequest](#memos-api-v2-GetMemoRequest)
- [GetMemoResponse](#memos-api-v2-GetMemoResponse)
- [GetUserMemosStatsRequest](#memos-api-v2-GetUserMemosStatsRequest)
......@@ -140,6 +138,8 @@
- [ListMemosRequest](#memos-api-v2-ListMemosRequest)
- [ListMemosResponse](#memos-api-v2-ListMemosResponse)
- [Memo](#memos-api-v2-Memo)
- [SearchMemosRequest](#memos-api-v2-SearchMemosRequest)
- [SearchMemosResponse](#memos-api-v2-SearchMemosResponse)
- [SetMemoRelationsRequest](#memos-api-v2-SetMemoRelationsRequest)
- [SetMemoRelationsResponse](#memos-api-v2-SetMemoRelationsResponse)
- [SetMemoResourcesRequest](#memos-api-v2-SetMemoResourcesRequest)
......@@ -1556,8 +1556,8 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | id is the memo id to create comment for. |
| create | [CreateMemoRequest](#memos-api-v2-CreateMemoRequest) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
| comment | [CreateMemoRequest](#memos-api-v2-CreateMemoRequest) | | |
......@@ -1618,7 +1618,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
| reaction_id | [int32](#int32) | | |
......@@ -1644,7 +1644,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
......@@ -1691,36 +1691,6 @@ Used internally for obfuscating the page token.
<a name="memos-api-v2-GetMemoByNameRequest"></a>
### GetMemoByNameRequest
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| name | [string](#string) | | |
<a name="memos-api-v2-GetMemoByNameResponse"></a>
### GetMemoByNameResponse
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| memo | [Memo](#memos-api-v2-Memo) | | |
<a name="memos-api-v2-GetMemoRequest"></a>
### GetMemoRequest
......@@ -1729,7 +1699,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
......@@ -1759,7 +1729,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| name | [string](#string) | | name is the name of the user to get stats for. Format: users/{username} |
| name | [string](#string) | | name is the name of the user to get stats for. Format: users/{uid} |
| timezone | [string](#string) | | timezone location Format: uses tz identifier https://en.wikipedia.org/wiki/List_of_tz_database_time_zones |
| filter | [string](#string) | | Same as ListMemosRequest.filter |
......@@ -1807,7 +1777,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
......@@ -1837,7 +1807,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
......@@ -1867,7 +1837,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
......@@ -1897,7 +1867,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
......@@ -1960,8 +1930,8 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | id is the system generated unique identifier. |
| name | [string](#string) | | name is the user provided name. |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
| resource_id | [string](#string) | | |
| row_status | [RowStatus](#memos-api-v2-RowStatus) | | |
| creator | [string](#string) | | The name of the creator. Format: users/{uid} |
| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
......@@ -1980,6 +1950,36 @@ Used internally for obfuscating the page token.
<a name="memos-api-v2-SearchMemosRequest"></a>
### SearchMemosRequest
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| filter | [string](#string) | | Filter is used to filter memos returned. Format: &#34;creator == users/{uid} &amp;&amp; visibilities == [&#39;PUBLIC&#39;, &#39;PROTECTED&#39;]&#34; |
<a name="memos-api-v2-SearchMemosResponse"></a>
### SearchMemosResponse
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| memos | [Memo](#memos-api-v2-Memo) | repeated | |
<a name="memos-api-v2-SetMemoRelationsRequest"></a>
### SetMemoRelationsRequest
......@@ -1988,7 +1988,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
| relations | [MemoRelation](#memos-api-v2-MemoRelation) | repeated | |
......@@ -2014,7 +2014,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
| resources | [Resource](#memos-api-v2-Resource) | repeated | |
......@@ -2071,7 +2071,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} |
| reaction | [Reaction](#memos-api-v2-Reaction) | | |
......@@ -2123,10 +2123,10 @@ Used internally for obfuscating the page token.
| ----------- | ------------ | ------------- | ------------|
| CreateMemo | [CreateMemoRequest](#memos-api-v2-CreateMemoRequest) | [CreateMemoResponse](#memos-api-v2-CreateMemoResponse) | CreateMemo creates a memo. |
| ListMemos | [ListMemosRequest](#memos-api-v2-ListMemosRequest) | [ListMemosResponse](#memos-api-v2-ListMemosResponse) | ListMemos lists memos with pagination and filter. |
| GetMemo | [GetMemoRequest](#memos-api-v2-GetMemoRequest) | [GetMemoResponse](#memos-api-v2-GetMemoResponse) | GetMemo gets a memo by id. |
| GetMemoByName | [GetMemoByNameRequest](#memos-api-v2-GetMemoByNameRequest) | [GetMemoByNameResponse](#memos-api-v2-GetMemoByNameResponse) | GetMemoByName gets a memo by name. |
| SearchMemos | [SearchMemosRequest](#memos-api-v2-SearchMemosRequest) | [SearchMemosResponse](#memos-api-v2-SearchMemosResponse) | SearchMemosRequest searches memos. |
| GetMemo | [GetMemoRequest](#memos-api-v2-GetMemoRequest) | [GetMemoResponse](#memos-api-v2-GetMemoResponse) | GetMemo gets a memo. |
| UpdateMemo | [UpdateMemoRequest](#memos-api-v2-UpdateMemoRequest) | [UpdateMemoResponse](#memos-api-v2-UpdateMemoResponse) | UpdateMemo updates a memo. |
| DeleteMemo | [DeleteMemoRequest](#memos-api-v2-DeleteMemoRequest) | [DeleteMemoResponse](#memos-api-v2-DeleteMemoResponse) | DeleteMemo deletes a memo by id. |
| DeleteMemo | [DeleteMemoRequest](#memos-api-v2-DeleteMemoRequest) | [DeleteMemoResponse](#memos-api-v2-DeleteMemoResponse) | DeleteMemo deletes a memo. |
| ExportMemos | [ExportMemosRequest](#memos-api-v2-ExportMemosRequest) | [ExportMemosResponse](#memos-api-v2-ExportMemosResponse) | ExportMemos exports memos. |
| SetMemoResources | [SetMemoResourcesRequest](#memos-api-v2-SetMemoResourcesRequest) | [SetMemoResourcesResponse](#memos-api-v2-SetMemoResourcesResponse) | SetMemoResources sets resources for a memo. |
| ListMemoResources | [ListMemoResourcesRequest](#memos-api-v2-ListMemoResourcesRequest) | [ListMemoResourcesResponse](#memos-api-v2-ListMemoResourcesResponse) | ListMemoResources lists resources for a memo. |
......
This diff is collapsed.
This diff is collapsed.
......@@ -21,8 +21,8 @@ const _ = grpc.SupportPackageIsVersion7
const (
MemoService_CreateMemo_FullMethodName = "/memos.api.v2.MemoService/CreateMemo"
MemoService_ListMemos_FullMethodName = "/memos.api.v2.MemoService/ListMemos"
MemoService_SearchMemos_FullMethodName = "/memos.api.v2.MemoService/SearchMemos"
MemoService_GetMemo_FullMethodName = "/memos.api.v2.MemoService/GetMemo"
MemoService_GetMemoByName_FullMethodName = "/memos.api.v2.MemoService/GetMemoByName"
MemoService_UpdateMemo_FullMethodName = "/memos.api.v2.MemoService/UpdateMemo"
MemoService_DeleteMemo_FullMethodName = "/memos.api.v2.MemoService/DeleteMemo"
MemoService_ExportMemos_FullMethodName = "/memos.api.v2.MemoService/ExportMemos"
......@@ -46,13 +46,13 @@ type MemoServiceClient interface {
CreateMemo(ctx context.Context, in *CreateMemoRequest, opts ...grpc.CallOption) (*CreateMemoResponse, error)
// ListMemos lists memos with pagination and filter.
ListMemos(ctx context.Context, in *ListMemosRequest, opts ...grpc.CallOption) (*ListMemosResponse, error)
// GetMemo gets a memo by id.
// SearchMemosRequest searches memos.
SearchMemos(ctx context.Context, in *SearchMemosRequest, opts ...grpc.CallOption) (*SearchMemosResponse, error)
// GetMemo gets a memo.
GetMemo(ctx context.Context, in *GetMemoRequest, opts ...grpc.CallOption) (*GetMemoResponse, error)
// GetMemoByName gets a memo by name.
GetMemoByName(ctx context.Context, in *GetMemoByNameRequest, opts ...grpc.CallOption) (*GetMemoByNameResponse, error)
// UpdateMemo updates a memo.
UpdateMemo(ctx context.Context, in *UpdateMemoRequest, opts ...grpc.CallOption) (*UpdateMemoResponse, error)
// DeleteMemo deletes a memo by id.
// DeleteMemo deletes a memo.
DeleteMemo(ctx context.Context, in *DeleteMemoRequest, opts ...grpc.CallOption) (*DeleteMemoResponse, error)
// ExportMemos exports memos.
ExportMemos(ctx context.Context, in *ExportMemosRequest, opts ...grpc.CallOption) (*ExportMemosResponse, error)
......@@ -104,18 +104,18 @@ func (c *memoServiceClient) ListMemos(ctx context.Context, in *ListMemosRequest,
return out, nil
}
func (c *memoServiceClient) GetMemo(ctx context.Context, in *GetMemoRequest, opts ...grpc.CallOption) (*GetMemoResponse, error) {
out := new(GetMemoResponse)
err := c.cc.Invoke(ctx, MemoService_GetMemo_FullMethodName, in, out, opts...)
func (c *memoServiceClient) SearchMemos(ctx context.Context, in *SearchMemosRequest, opts ...grpc.CallOption) (*SearchMemosResponse, error) {
out := new(SearchMemosResponse)
err := c.cc.Invoke(ctx, MemoService_SearchMemos_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *memoServiceClient) GetMemoByName(ctx context.Context, in *GetMemoByNameRequest, opts ...grpc.CallOption) (*GetMemoByNameResponse, error) {
out := new(GetMemoByNameResponse)
err := c.cc.Invoke(ctx, MemoService_GetMemoByName_FullMethodName, in, out, opts...)
func (c *memoServiceClient) GetMemo(ctx context.Context, in *GetMemoRequest, opts ...grpc.CallOption) (*GetMemoResponse, error) {
out := new(GetMemoResponse)
err := c.cc.Invoke(ctx, MemoService_GetMemo_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
......@@ -247,13 +247,13 @@ type MemoServiceServer interface {
CreateMemo(context.Context, *CreateMemoRequest) (*CreateMemoResponse, error)
// ListMemos lists memos with pagination and filter.
ListMemos(context.Context, *ListMemosRequest) (*ListMemosResponse, error)
// GetMemo gets a memo by id.
// SearchMemosRequest searches memos.
SearchMemos(context.Context, *SearchMemosRequest) (*SearchMemosResponse, error)
// GetMemo gets a memo.
GetMemo(context.Context, *GetMemoRequest) (*GetMemoResponse, error)
// GetMemoByName gets a memo by name.
GetMemoByName(context.Context, *GetMemoByNameRequest) (*GetMemoByNameResponse, error)
// UpdateMemo updates a memo.
UpdateMemo(context.Context, *UpdateMemoRequest) (*UpdateMemoResponse, error)
// DeleteMemo deletes a memo by id.
// DeleteMemo deletes a memo.
DeleteMemo(context.Context, *DeleteMemoRequest) (*DeleteMemoResponse, error)
// ExportMemos exports memos.
ExportMemos(context.Context, *ExportMemosRequest) (*ExportMemosResponse, error)
......@@ -290,12 +290,12 @@ func (UnimplementedMemoServiceServer) CreateMemo(context.Context, *CreateMemoReq
func (UnimplementedMemoServiceServer) ListMemos(context.Context, *ListMemosRequest) (*ListMemosResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListMemos not implemented")
}
func (UnimplementedMemoServiceServer) SearchMemos(context.Context, *SearchMemosRequest) (*SearchMemosResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SearchMemos not implemented")
}
func (UnimplementedMemoServiceServer) GetMemo(context.Context, *GetMemoRequest) (*GetMemoResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetMemo not implemented")
}
func (UnimplementedMemoServiceServer) GetMemoByName(context.Context, *GetMemoByNameRequest) (*GetMemoByNameResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetMemoByName not implemented")
}
func (UnimplementedMemoServiceServer) UpdateMemo(context.Context, *UpdateMemoRequest) (*UpdateMemoResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateMemo not implemented")
}
......@@ -384,38 +384,38 @@ func _MemoService_ListMemos_Handler(srv interface{}, ctx context.Context, dec fu
return interceptor(ctx, in, info, handler)
}
func _MemoService_GetMemo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetMemoRequest)
func _MemoService_SearchMemos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SearchMemosRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MemoServiceServer).GetMemo(ctx, in)
return srv.(MemoServiceServer).SearchMemos(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: MemoService_GetMemo_FullMethodName,
FullMethod: MemoService_SearchMemos_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MemoServiceServer).GetMemo(ctx, req.(*GetMemoRequest))
return srv.(MemoServiceServer).SearchMemos(ctx, req.(*SearchMemosRequest))
}
return interceptor(ctx, in, info, handler)
}
func _MemoService_GetMemoByName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetMemoByNameRequest)
func _MemoService_GetMemo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetMemoRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MemoServiceServer).GetMemoByName(ctx, in)
return srv.(MemoServiceServer).GetMemo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: MemoService_GetMemoByName_FullMethodName,
FullMethod: MemoService_GetMemo_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MemoServiceServer).GetMemoByName(ctx, req.(*GetMemoByNameRequest))
return srv.(MemoServiceServer).GetMemo(ctx, req.(*GetMemoRequest))
}
return interceptor(ctx, in, info, handler)
}
......@@ -670,12 +670,12 @@ var MemoService_ServiceDesc = grpc.ServiceDesc{
Handler: _MemoService_ListMemos_Handler,
},
{
MethodName: "GetMemo",
Handler: _MemoService_GetMemo_Handler,
MethodName: "SearchMemos",
Handler: _MemoService_SearchMemos_Handler,
},
{
MethodName: "GetMemoByName",
Handler: _MemoService_GetMemoByName_Handler,
MethodName: "GetMemo",
Handler: _MemoService_GetMemo_Handler,
},
{
MethodName: "UpdateMemo",
......
......@@ -1612,7 +1612,7 @@ var file_api_v2_user_service_proto_rawDesc = []byte{
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73,
0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4,
0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x75, 0x73, 0x65,
0x72, 0x73, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x6d, 0x0a, 0x07, 0x47, 0x65, 0x74,
0x72, 0x73, 0x3a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x6d, 0x0a, 0x07, 0x47, 0x65, 0x74,
0x55, 0x73, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69,
0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76,
......
......@@ -706,7 +706,7 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.UserService/SearchUsers", runtime.WithHTTPPathPattern("/api/v2/users/search"))
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.UserService/SearchUsers", runtime.WithHTTPPathPattern("/api/v2/users:search"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
......@@ -1017,7 +1017,7 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.UserService/SearchUsers", runtime.WithHTTPPathPattern("/api/v2/users/search"))
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.UserService/SearchUsers", runtime.WithHTTPPathPattern("/api/v2/users:search"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
......@@ -1237,7 +1237,7 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
var (
pattern_UserService_ListUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "users"}, ""))
pattern_UserService_SearchUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v2", "users", "search"}, ""))
pattern_UserService_SearchUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "users"}, "search"))
pattern_UserService_GetUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v2", "users", "name"}, ""))
......
This diff is collapsed.
This diff is collapsed.
......@@ -11,10 +11,14 @@ import (
)
func (s *APIV2Service) SetMemoRelations(ctx context.Context, request *apiv2pb.SetMemoRelationsRequest) (*apiv2pb.SetMemoRelationsResponse, error) {
id, err := ExtractMemoIDFromName(request.Name)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid memo name: %v", err)
}
referenceType := store.MemoRelationReference
// Delete all reference relations first.
if err := s.Store.DeleteMemoRelation(ctx, &store.DeleteMemoRelation{
MemoID: &request.Id,
MemoID: &id,
Type: &referenceType,
}); err != nil {
return nil, status.Errorf(codes.Internal, "failed to delete memo relation")
......@@ -22,7 +26,7 @@ func (s *APIV2Service) SetMemoRelations(ctx context.Context, request *apiv2pb.Se
for _, relation := range request.Relations {
// Ignore reflexive relations.
if request.Id == relation.RelatedMemoId {
if id == relation.RelatedMemoId {
continue
}
// Ignore comment relations as there's no need to update a comment's relation.
......@@ -31,7 +35,7 @@ func (s *APIV2Service) SetMemoRelations(ctx context.Context, request *apiv2pb.Se
continue
}
if _, err := s.Store.UpsertMemoRelation(ctx, &store.MemoRelation{
MemoID: request.Id,
MemoID: id,
RelatedMemoID: relation.RelatedMemoId,
Type: convertMemoRelationTypeToStore(relation.Type),
}); err != nil {
......@@ -43,9 +47,13 @@ func (s *APIV2Service) SetMemoRelations(ctx context.Context, request *apiv2pb.Se
}
func (s *APIV2Service) ListMemoRelations(ctx context.Context, request *apiv2pb.ListMemoRelationsRequest) (*apiv2pb.ListMemoRelationsResponse, error) {
id, err := ExtractMemoIDFromName(request.Name)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid memo name: %v", err)
}
relationList := []*apiv2pb.MemoRelation{}
tempList, err := s.Store.ListMemoRelations(ctx, &store.FindMemoRelation{
MemoID: &request.Id,
MemoID: &id,
})
if err != nil {
return nil, err
......@@ -54,7 +62,7 @@ func (s *APIV2Service) ListMemoRelations(ctx context.Context, request *apiv2pb.L
relationList = append(relationList, convertMemoRelationFromStore(relation))
}
tempList, err = s.Store.ListMemoRelations(ctx, &store.FindMemoRelation{
RelatedMemoID: &request.Id,
RelatedMemoID: &id,
})
if err != nil {
return nil, err
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -244,7 +244,7 @@ func (s *APIV2Service) convertTagFromStore(ctx context.Context, tag *store.Tag)
}
return &apiv2pb.Tag{
Name: tag.Name,
Creator: fmt.Sprintf("%s%s", UserNamePrefix, user.Username),
Creator: fmt.Sprintf("%s%d", UserNamePrefix, user.ID),
}, nil
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment