Commit 7cc8b951 authored by Steven's avatar Steven

refactor: update resource id naming

parent a3a4e37c
...@@ -3,5 +3,5 @@ package util ...@@ -3,5 +3,5 @@ package util
import "regexp" import "regexp"
var ( var (
ResourceNameMatcher = regexp.MustCompile("^[a-zA-Z0-9]([a-zA-Z0-9-]{1,30}[a-zA-Z0-9])$") UIDMatcher = regexp.MustCompile("^[a-zA-Z0-9]([a-zA-Z0-9-]{1,30}[a-zA-Z0-9])$")
) )
...@@ -122,15 +122,17 @@ enum Visibility { ...@@ -122,15 +122,17 @@ enum Visibility {
message Memo { message Memo {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
// id is the system generated id.
string name = 1; string name = 1;
string resource_id = 2; // The user defined id of the memo.
string uid = 2;
RowStatus row_status = 3; RowStatus row_status = 3;
// The name of the creator. // The name of the creator.
// Format: users/{uid} // Format: users/{id}
string creator = 4; string creator = 4;
google.protobuf.Timestamp create_time = 5; google.protobuf.Timestamp create_time = 5;
...@@ -197,7 +199,7 @@ message SearchMemosResponse { ...@@ -197,7 +199,7 @@ message SearchMemosResponse {
message GetMemoRequest { message GetMemoRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
} }
...@@ -217,7 +219,7 @@ message UpdateMemoResponse { ...@@ -217,7 +219,7 @@ message UpdateMemoResponse {
message DeleteMemoRequest { message DeleteMemoRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
} }
...@@ -234,7 +236,7 @@ message ExportMemosResponse { ...@@ -234,7 +236,7 @@ message ExportMemosResponse {
message SetMemoResourcesRequest { message SetMemoResourcesRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
repeated Resource resources = 2; repeated Resource resources = 2;
...@@ -244,7 +246,7 @@ message SetMemoResourcesResponse {} ...@@ -244,7 +246,7 @@ message SetMemoResourcesResponse {}
message ListMemoResourcesRequest { message ListMemoResourcesRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
} }
...@@ -254,7 +256,7 @@ message ListMemoResourcesResponse { ...@@ -254,7 +256,7 @@ message ListMemoResourcesResponse {
message SetMemoRelationsRequest { message SetMemoRelationsRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
repeated MemoRelation relations = 2; repeated MemoRelation relations = 2;
...@@ -264,7 +266,7 @@ message SetMemoRelationsResponse {} ...@@ -264,7 +266,7 @@ message SetMemoRelationsResponse {}
message ListMemoRelationsRequest { message ListMemoRelationsRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
} }
...@@ -274,7 +276,7 @@ message ListMemoRelationsResponse { ...@@ -274,7 +276,7 @@ message ListMemoRelationsResponse {
message CreateMemoCommentRequest { message CreateMemoCommentRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
CreateMemoRequest comment = 2; CreateMemoRequest comment = 2;
...@@ -286,7 +288,7 @@ message CreateMemoCommentResponse { ...@@ -286,7 +288,7 @@ message CreateMemoCommentResponse {
message ListMemoCommentsRequest { message ListMemoCommentsRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
} }
...@@ -296,7 +298,7 @@ message ListMemoCommentsResponse { ...@@ -296,7 +298,7 @@ message ListMemoCommentsResponse {
message GetUserMemosStatsRequest { message GetUserMemosStatsRequest {
// name is the name of the user to get stats for. // name is the name of the user to get stats for.
// Format: users/{uid} // Format: users/{id}
string name = 1; string name = 1;
// timezone location // timezone location
...@@ -316,7 +318,7 @@ message GetUserMemosStatsResponse { ...@@ -316,7 +318,7 @@ message GetUserMemosStatsResponse {
message ListMemoReactionsRequest { message ListMemoReactionsRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
} }
...@@ -326,7 +328,7 @@ message ListMemoReactionsResponse { ...@@ -326,7 +328,7 @@ message ListMemoReactionsResponse {
message UpsertMemoReactionRequest { message UpsertMemoReactionRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
Reaction reaction = 2; Reaction reaction = 2;
...@@ -338,7 +340,7 @@ message UpsertMemoReactionResponse { ...@@ -338,7 +340,7 @@ message UpsertMemoReactionResponse {
message DeleteMemoReactionRequest { message DeleteMemoReactionRequest {
// The name of the memo. // The name of the memo.
// Format: memos/{uid} // Format: memos/{id}
string name = 1; string name = 1;
int32 reaction_id = 2; int32 reaction_id = 2;
......
...@@ -8,7 +8,7 @@ message Reaction { ...@@ -8,7 +8,7 @@ message Reaction {
int32 id = 1; int32 id = 1;
// The name of the creator. // The name of the creator.
// Format: users/{uid} // Format: users/{id}
string creator = 2; string creator = 2;
string content_id = 3; string content_id = 3;
......
...@@ -37,7 +37,7 @@ service TagService { ...@@ -37,7 +37,7 @@ service TagService {
message Tag { message Tag {
string name = 1; string name = 1;
// The creator of tags. // The creator of tags.
// Format: users/{uid} // Format: users/{id}
string creator = 2; string creator = 2;
} }
...@@ -57,7 +57,7 @@ message BatchUpsertTagResponse {} ...@@ -57,7 +57,7 @@ message BatchUpsertTagResponse {}
message ListTagsRequest { message ListTagsRequest {
// The creator of tags. // The creator of tags.
// Format: users/{uid} // Format: users/{id}
string user = 1; string user = 1;
} }
...@@ -67,7 +67,7 @@ message ListTagsResponse { ...@@ -67,7 +67,7 @@ message ListTagsResponse {
message RenameTagRequest { message RenameTagRequest {
// The creator of tags. // The creator of tags.
// Format: users/{uid} // Format: users/{id}
string user = 1; string user = 1;
string old_name = 2; string old_name = 2;
string new_name = 3; string new_name = 3;
...@@ -85,7 +85,7 @@ message DeleteTagResponse {} ...@@ -85,7 +85,7 @@ message DeleteTagResponse {}
message GetTagSuggestionsRequest { message GetTagSuggestionsRequest {
// The creator of tags. // The creator of tags.
// Format: users/{uid} // Format: users/{id}
string user = 1; string user = 1;
} }
......
...@@ -91,7 +91,7 @@ service UserService { ...@@ -91,7 +91,7 @@ service UserService {
message User { message User {
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
string name = 1; string name = 1;
// The system generated uid of the user. // The system generated uid of the user.
...@@ -140,7 +140,7 @@ message SearchUsersResponse { ...@@ -140,7 +140,7 @@ message SearchUsersResponse {
message GetUserRequest { message GetUserRequest {
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
string name = 1; string name = 1;
} }
...@@ -168,7 +168,7 @@ message UpdateUserResponse { ...@@ -168,7 +168,7 @@ message UpdateUserResponse {
message DeleteUserRequest { message DeleteUserRequest {
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
string name = 1; string name = 1;
} }
...@@ -176,7 +176,7 @@ message DeleteUserResponse {} ...@@ -176,7 +176,7 @@ message DeleteUserResponse {}
message UserSetting { message UserSetting {
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
string name = 1; string name = 1;
// The preferred locale of the user. // The preferred locale of the user.
string locale = 2; string locale = 2;
...@@ -190,7 +190,7 @@ message UserSetting { ...@@ -190,7 +190,7 @@ message UserSetting {
message GetUserSettingRequest { message GetUserSettingRequest {
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
string name = 1; string name = 1;
} }
...@@ -217,7 +217,7 @@ message UserAccessToken { ...@@ -217,7 +217,7 @@ message UserAccessToken {
message ListUserAccessTokensRequest { message ListUserAccessTokensRequest {
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
string name = 1; string name = 1;
} }
...@@ -227,7 +227,7 @@ message ListUserAccessTokensResponse { ...@@ -227,7 +227,7 @@ message ListUserAccessTokensResponse {
message CreateUserAccessTokenRequest { message CreateUserAccessTokenRequest {
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
string name = 1; string name = 1;
string description = 2; string description = 2;
...@@ -241,7 +241,7 @@ message CreateUserAccessTokenResponse { ...@@ -241,7 +241,7 @@ message CreateUserAccessTokenResponse {
message DeleteUserAccessTokenRequest { message DeleteUserAccessTokenRequest {
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
string name = 1; string name = 1;
// access_token is the access token to delete. // access_token is the access token to delete.
string access_token = 2; string access_token = 2;
......
...@@ -389,7 +389,7 @@ Used internally for obfuscating the page token. ...@@ -389,7 +389,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the user. Format: users/{uid} | | name | [string](#string) | | The name of the user. Format: users/{id} |
| description | [string](#string) | | | | description | [string](#string) | | |
| expires_at | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | optional | | | expires_at | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | optional | |
...@@ -451,7 +451,7 @@ Used internally for obfuscating the page token. ...@@ -451,7 +451,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the user. Format: users/{uid} | | name | [string](#string) | | The name of the user. Format: users/{id} |
| access_token | [string](#string) | | access_token is the access token to delete. | | access_token | [string](#string) | | access_token is the access token to delete. |
...@@ -477,7 +477,7 @@ Used internally for obfuscating the page token. ...@@ -477,7 +477,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the user. Format: users/{uid} | | name | [string](#string) | | The name of the user. Format: users/{id} |
...@@ -502,7 +502,7 @@ Used internally for obfuscating the page token. ...@@ -502,7 +502,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the user. Format: users/{uid} | | name | [string](#string) | | The name of the user. Format: users/{id} |
...@@ -532,7 +532,7 @@ Used internally for obfuscating the page token. ...@@ -532,7 +532,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the user. Format: users/{uid} | | name | [string](#string) | | The name of the user. Format: users/{id} |
...@@ -562,7 +562,7 @@ Used internally for obfuscating the page token. ...@@ -562,7 +562,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the user. Format: users/{uid} | | name | [string](#string) | | The name of the user. Format: users/{id} |
...@@ -709,7 +709,7 @@ Used internally for obfuscating the page token. ...@@ -709,7 +709,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the user. Format: users/{uid} | | name | [string](#string) | | The name of the user. Format: users/{id} |
| id | [int32](#int32) | | The system generated uid of the user. | | id | [int32](#int32) | | The system generated uid of the user. |
| role | [User.Role](#memos-api-v2-User-Role) | | | | role | [User.Role](#memos-api-v2-User-Role) | | |
| username | [string](#string) | | | | username | [string](#string) | | |
...@@ -753,7 +753,7 @@ Used internally for obfuscating the page token. ...@@ -753,7 +753,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the user. Format: users/{uid} | | name | [string](#string) | | The name of the user. Format: users/{id} |
| locale | [string](#string) | | The preferred locale of the user. | | locale | [string](#string) | | The preferred locale of the user. |
| appearance | [string](#string) | | The preferred appearance of the user. | | appearance | [string](#string) | | The preferred appearance of the user. |
| memo_visibility | [string](#string) | | The default visibility of the memo. | | memo_visibility | [string](#string) | | The default visibility of the memo. |
...@@ -1273,7 +1273,7 @@ Used internally for obfuscating the page token. ...@@ -1273,7 +1273,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| id | [int32](#int32) | | | | id | [int32](#int32) | | |
| creator | [string](#string) | | The name of the creator. Format: users/{uid} | | creator | [string](#string) | | The name of the creator. Format: users/{id} |
| content_id | [string](#string) | | | | content_id | [string](#string) | | |
| reaction_type | [Reaction.Type](#memos-api-v2-Reaction-Type) | | | | reaction_type | [Reaction.Type](#memos-api-v2-Reaction-Type) | | |
...@@ -1556,7 +1556,7 @@ Used internally for obfuscating the page token. ...@@ -1556,7 +1556,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
| comment | [CreateMemoRequest](#memos-api-v2-CreateMemoRequest) | | | | comment | [CreateMemoRequest](#memos-api-v2-CreateMemoRequest) | | |
...@@ -1618,7 +1618,7 @@ Used internally for obfuscating the page token. ...@@ -1618,7 +1618,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
| reaction_id | [int32](#int32) | | | | reaction_id | [int32](#int32) | | |
...@@ -1644,7 +1644,7 @@ Used internally for obfuscating the page token. ...@@ -1644,7 +1644,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
...@@ -1699,7 +1699,7 @@ Used internally for obfuscating the page token. ...@@ -1699,7 +1699,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
...@@ -1729,7 +1729,7 @@ Used internally for obfuscating the page token. ...@@ -1729,7 +1729,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | name is the name of the user to get stats for. Format: users/{uid} | | name | [string](#string) | | name is the name of the user to get stats for. Format: users/{id} |
| timezone | [string](#string) | | timezone location Format: uses tz identifier https://en.wikipedia.org/wiki/List_of_tz_database_time_zones | | 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 | | filter | [string](#string) | | Same as ListMemosRequest.filter |
...@@ -1777,7 +1777,7 @@ Used internally for obfuscating the page token. ...@@ -1777,7 +1777,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
...@@ -1807,7 +1807,7 @@ Used internally for obfuscating the page token. ...@@ -1807,7 +1807,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
...@@ -1837,7 +1837,7 @@ Used internally for obfuscating the page token. ...@@ -1837,7 +1837,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
...@@ -1867,7 +1867,7 @@ Used internally for obfuscating the page token. ...@@ -1867,7 +1867,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
...@@ -1930,10 +1930,10 @@ Used internally for obfuscating the page token. ...@@ -1930,10 +1930,10 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} id is the system generated id. |
| resource_id | [string](#string) | | | | uid | [string](#string) | | The user defined id of the memo. |
| row_status | [RowStatus](#memos-api-v2-RowStatus) | | | | row_status | [RowStatus](#memos-api-v2-RowStatus) | | |
| creator | [string](#string) | | The name of the creator. Format: users/{uid} | | creator | [string](#string) | | The name of the creator. Format: users/{id} |
| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | | | create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| update_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | | | update_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| display_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | | | display_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
...@@ -1988,7 +1988,7 @@ Used internally for obfuscating the page token. ...@@ -1988,7 +1988,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
| relations | [MemoRelation](#memos-api-v2-MemoRelation) | repeated | | | relations | [MemoRelation](#memos-api-v2-MemoRelation) | repeated | |
...@@ -2014,7 +2014,7 @@ Used internally for obfuscating the page token. ...@@ -2014,7 +2014,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
| resources | [Resource](#memos-api-v2-Resource) | repeated | | | resources | [Resource](#memos-api-v2-Resource) | repeated | |
...@@ -2071,7 +2071,7 @@ Used internally for obfuscating the page token. ...@@ -2071,7 +2071,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | The name of the memo. Format: memos/{uid} | | name | [string](#string) | | The name of the memo. Format: memos/{id} |
| reaction | [Reaction](#memos-api-v2-Reaction) | | | | reaction | [Reaction](#memos-api-v2-Reaction) | | |
...@@ -2208,7 +2208,7 @@ Used internally for obfuscating the page token. ...@@ -2208,7 +2208,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| user | [string](#string) | | The creator of tags. Format: users/{uid} | | user | [string](#string) | | The creator of tags. Format: users/{id} |
...@@ -2238,7 +2238,7 @@ Used internally for obfuscating the page token. ...@@ -2238,7 +2238,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| user | [string](#string) | | The creator of tags. Format: users/{uid} | | user | [string](#string) | | The creator of tags. Format: users/{id} |
...@@ -2268,7 +2268,7 @@ Used internally for obfuscating the page token. ...@@ -2268,7 +2268,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| user | [string](#string) | | The creator of tags. Format: users/{uid} | | user | [string](#string) | | The creator of tags. Format: users/{id} |
| old_name | [string](#string) | | | | old_name | [string](#string) | | |
| new_name | [string](#string) | | | | new_name | [string](#string) | | |
...@@ -2301,7 +2301,7 @@ Used internally for obfuscating the page token. ...@@ -2301,7 +2301,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| name | [string](#string) | | | | name | [string](#string) | | |
| creator | [string](#string) | | The creator of tags. Format: users/{uid} | | creator | [string](#string) | | The creator of tags. Format: users/{id} |
......
This diff is collapsed.
...@@ -106,7 +106,7 @@ type Reaction struct { ...@@ -106,7 +106,7 @@ type Reaction struct {
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
// The name of the creator. // The name of the creator.
// Format: users/{uid} // Format: users/{id}
Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"` Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"`
ContentId string `protobuf:"bytes,3,opt,name=content_id,json=contentId,proto3" json:"content_id,omitempty"` ContentId string `protobuf:"bytes,3,opt,name=content_id,json=contentId,proto3" json:"content_id,omitempty"`
ReactionType Reaction_Type `protobuf:"varint,4,opt,name=reaction_type,json=reactionType,proto3,enum=memos.api.v2.Reaction_Type" json:"reaction_type,omitempty"` ReactionType Reaction_Type `protobuf:"varint,4,opt,name=reaction_type,json=reactionType,proto3,enum=memos.api.v2.Reaction_Type" json:"reaction_type,omitempty"`
......
...@@ -28,7 +28,7 @@ type Tag struct { ...@@ -28,7 +28,7 @@ type Tag struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// The creator of tags. // The creator of tags.
// Format: users/{uid} // Format: users/{id}
Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"` Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"`
} }
...@@ -263,7 +263,7 @@ type ListTagsRequest struct { ...@@ -263,7 +263,7 @@ type ListTagsRequest struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The creator of tags. // The creator of tags.
// Format: users/{uid} // Format: users/{id}
User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
} }
...@@ -359,7 +359,7 @@ type RenameTagRequest struct { ...@@ -359,7 +359,7 @@ type RenameTagRequest struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The creator of tags. // The creator of tags.
// Format: users/{uid} // Format: users/{id}
User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
OldName string `protobuf:"bytes,2,opt,name=old_name,json=oldName,proto3" json:"old_name,omitempty"` OldName string `protobuf:"bytes,2,opt,name=old_name,json=oldName,proto3" json:"old_name,omitempty"`
NewName string `protobuf:"bytes,3,opt,name=new_name,json=newName,proto3" json:"new_name,omitempty"` NewName string `protobuf:"bytes,3,opt,name=new_name,json=newName,proto3" json:"new_name,omitempty"`
...@@ -556,7 +556,7 @@ type GetTagSuggestionsRequest struct { ...@@ -556,7 +556,7 @@ type GetTagSuggestionsRequest struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The creator of tags. // The creator of tags.
// Format: users/{uid} // Format: users/{id}
User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
} }
......
...@@ -81,7 +81,7 @@ type User struct { ...@@ -81,7 +81,7 @@ type User struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// The system generated uid of the user. // The system generated uid of the user.
Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"`
...@@ -398,7 +398,7 @@ type GetUserRequest struct { ...@@ -398,7 +398,7 @@ type GetUserRequest struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
} }
...@@ -690,7 +690,7 @@ type DeleteUserRequest struct { ...@@ -690,7 +690,7 @@ type DeleteUserRequest struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
} }
...@@ -777,7 +777,7 @@ type UserSetting struct { ...@@ -777,7 +777,7 @@ type UserSetting struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// The preferred locale of the user. // The preferred locale of the user.
Locale string `protobuf:"bytes,2,opt,name=locale,proto3" json:"locale,omitempty"` Locale string `protobuf:"bytes,2,opt,name=locale,proto3" json:"locale,omitempty"`
...@@ -862,7 +862,7 @@ type GetUserSettingRequest struct { ...@@ -862,7 +862,7 @@ type GetUserSettingRequest struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
} }
...@@ -1131,7 +1131,7 @@ type ListUserAccessTokensRequest struct { ...@@ -1131,7 +1131,7 @@ type ListUserAccessTokensRequest struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
} }
...@@ -1227,7 +1227,7 @@ type CreateUserAccessTokenRequest struct { ...@@ -1227,7 +1227,7 @@ type CreateUserAccessTokenRequest struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=expires_at,json=expiresAt,proto3,oneof" json:"expires_at,omitempty"` ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=expires_at,json=expiresAt,proto3,oneof" json:"expires_at,omitempty"`
...@@ -1339,7 +1339,7 @@ type DeleteUserAccessTokenRequest struct { ...@@ -1339,7 +1339,7 @@ type DeleteUserAccessTokenRequest struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The name of the user. // The name of the user.
// Format: users/{uid} // Format: users/{id}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// access_token is the access token to delete. // access_token is the access token to delete.
AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
......
...@@ -74,9 +74,9 @@ func (t *TelegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot, ...@@ -74,9 +74,9 @@ func (t *TelegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot,
} }
create := &store.Memo{ create := &store.Memo{
ResourceName: shortuuid.New(), UID: shortuuid.New(),
CreatorID: creatorID, CreatorID: creatorID,
Visibility: store.Private, Visibility: store.Private,
} }
if message.Text != nil { if message.Text != nil {
create.Content = convertToMarkdown(*message.Text, message.Entities) create.Content = convertToMarkdown(*message.Text, message.Entities)
...@@ -121,12 +121,12 @@ func (t *TelegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot, ...@@ -121,12 +121,12 @@ func (t *TelegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot,
for _, attachment := range attachments { for _, attachment := range attachments {
// Fill the common field of create // Fill the common field of create
create := store.Resource{ create := store.Resource{
ResourceName: shortuuid.New(), UID: shortuuid.New(),
CreatorID: creatorID, CreatorID: creatorID,
Filename: filepath.Base(attachment.FileName), Filename: filepath.Base(attachment.FileName),
Type: attachment.GetMimeType(), Type: attachment.GetMimeType(),
Size: attachment.FileSize, Size: attachment.FileSize,
MemoID: &memoMessage.ID, MemoID: &memoMessage.ID,
} }
err := apiv1.SaveResourceBlob(ctx, t.store, &create, bytes.NewReader(attachment.Data)) err := apiv1.SaveResourceBlob(ctx, t.store, &create, bytes.NewReader(attachment.Data))
......
...@@ -269,7 +269,7 @@ func (s *APIV1Service) SignUp(c echo.Context) error { ...@@ -269,7 +269,7 @@ func (s *APIV1Service) SignUp(c echo.Context) error {
if err != nil { if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Failed to find users").SetInternal(err) return echo.NewHTTPError(http.StatusBadRequest, "Failed to find users").SetInternal(err)
} }
if !util.ResourceNameMatcher.MatchString(strings.ToLower(signup.Username)) { if !util.UIDMatcher.MatchString(strings.ToLower(signup.Username)) {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid username %s", signup.Username)).SetInternal(err) return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid username %s", signup.Username)).SetInternal(err)
} }
......
...@@ -827,7 +827,7 @@ func (s *APIV1Service) UpdateMemo(c echo.Context) error { ...@@ -827,7 +827,7 @@ func (s *APIV1Service) UpdateMemo(c echo.Context) error {
func (s *APIV1Service) convertMemoFromStore(ctx context.Context, memo *store.Memo) (*Memo, error) { func (s *APIV1Service) convertMemoFromStore(ctx context.Context, memo *store.Memo) (*Memo, error) {
memoMessage := &Memo{ memoMessage := &Memo{
ID: memo.ID, ID: memo.ID,
Name: memo.ResourceName, Name: memo.UID,
RowStatus: RowStatus(memo.RowStatus.String()), RowStatus: RowStatus(memo.RowStatus.String()),
CreatorID: memo.CreatorID, CreatorID: memo.CreatorID,
CreatedTs: memo.CreatedTs, CreatedTs: memo.CreatedTs,
...@@ -921,11 +921,11 @@ func convertCreateMemoRequestToMemoMessage(memoCreate *CreateMemoRequest) *store ...@@ -921,11 +921,11 @@ func convertCreateMemoRequestToMemoMessage(memoCreate *CreateMemoRequest) *store
createdTs = *memoCreate.CreatedTs createdTs = *memoCreate.CreatedTs
} }
return &store.Memo{ return &store.Memo{
ResourceName: shortuuid.New(), UID: shortuuid.New(),
CreatorID: memoCreate.CreatorID, CreatorID: memoCreate.CreatorID,
CreatedTs: createdTs, CreatedTs: createdTs,
Content: memoCreate.Content, Content: memoCreate.Content,
Visibility: store.Visibility(memoCreate.Visibility), Visibility: store.Visibility(memoCreate.Visibility),
} }
} }
......
...@@ -138,7 +138,7 @@ func (s *APIV1Service) CreateResource(c echo.Context) error { ...@@ -138,7 +138,7 @@ func (s *APIV1Service) CreateResource(c echo.Context) error {
} }
create := &store.Resource{ create := &store.Resource{
ResourceName: shortuuid.New(), UID: shortuuid.New(),
CreatorID: userID, CreatorID: userID,
Filename: request.Filename, Filename: request.Filename,
ExternalLink: request.ExternalLink, ExternalLink: request.ExternalLink,
...@@ -220,11 +220,11 @@ func (s *APIV1Service) UploadResource(c echo.Context) error { ...@@ -220,11 +220,11 @@ func (s *APIV1Service) UploadResource(c echo.Context) error {
defer sourceFile.Close() defer sourceFile.Close()
create := &store.Resource{ create := &store.Resource{
ResourceName: shortuuid.New(), UID: shortuuid.New(),
CreatorID: userID, CreatorID: userID,
Filename: file.Filename, Filename: file.Filename,
Type: file.Header.Get("Content-Type"), Type: file.Header.Get("Content-Type"),
Size: file.Size, Size: file.Size,
} }
err = SaveResourceBlob(ctx, s.Store, create, sourceFile) err = SaveResourceBlob(ctx, s.Store, create, sourceFile)
if err != nil { if err != nil {
...@@ -371,7 +371,7 @@ func replacePathTemplate(path, filename string) string { ...@@ -371,7 +371,7 @@ func replacePathTemplate(path, filename string) string {
func convertResourceFromStore(resource *store.Resource) *Resource { func convertResourceFromStore(resource *store.Resource) *Resource {
return &Resource{ return &Resource{
ID: resource.ID, ID: resource.ID,
Name: resource.ResourceName, Name: resource.UID,
CreatorID: resource.CreatorID, CreatorID: resource.CreatorID,
CreatedTs: resource.CreatedTs, CreatedTs: resource.CreatedTs,
UpdatedTs: resource.UpdatedTs, UpdatedTs: resource.UpdatedTs,
......
...@@ -157,7 +157,7 @@ func (s *APIV1Service) CreateUser(c echo.Context) error { ...@@ -157,7 +157,7 @@ func (s *APIV1Service) CreateUser(c echo.Context) error {
if err := userCreate.Validate(); err != nil { if err := userCreate.Validate(); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid user create format").SetInternal(err) return echo.NewHTTPError(http.StatusBadRequest, "Invalid user create format").SetInternal(err)
} }
if !util.ResourceNameMatcher.MatchString(strings.ToLower(userCreate.Username)) { if !util.UIDMatcher.MatchString(strings.ToLower(userCreate.Username)) {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid username %s", userCreate.Username)).SetInternal(err) return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid username %s", userCreate.Username)).SetInternal(err)
} }
// Disallow host user to be created. // Disallow host user to be created.
...@@ -377,7 +377,7 @@ func (s *APIV1Service) UpdateUser(c echo.Context) error { ...@@ -377,7 +377,7 @@ func (s *APIV1Service) UpdateUser(c echo.Context) error {
} }
} }
if request.Username != nil { if request.Username != nil {
if !util.ResourceNameMatcher.MatchString(strings.ToLower(*request.Username)) { if !util.UIDMatcher.MatchString(strings.ToLower(*request.Username)) {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid username %s", *request.Username)).SetInternal(err) return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid username %s", *request.Username)).SetInternal(err)
} }
userUpdate.Username = request.Username userUpdate.Username = request.Username
......
This diff is collapsed.
...@@ -243,7 +243,7 @@ paths: ...@@ -243,7 +243,7 @@ paths:
- name: name - name: name
description: |- description: |-
name is the name of the user to get stats for. name is the name of the user to get stats for.
Format: users/{uid} Format: users/{id}
in: query in: query
required: false required: false
type: string type: string
...@@ -477,7 +477,7 @@ paths: ...@@ -477,7 +477,7 @@ paths:
- name: user - name: user
description: |- description: |-
The creator of tags. The creator of tags.
Format: users/{uid} Format: users/{id}
in: query in: query
required: false required: false
type: string type: string
...@@ -503,7 +503,7 @@ paths: ...@@ -503,7 +503,7 @@ paths:
- name: tag.creator - name: tag.creator
description: |- description: |-
The creator of tags. The creator of tags.
Format: users/{uid} Format: users/{id}
in: query in: query
required: false required: false
type: string type: string
...@@ -545,7 +545,7 @@ paths: ...@@ -545,7 +545,7 @@ paths:
- name: user - name: user
description: |- description: |-
The creator of tags. The creator of tags.
Format: users/{uid} Format: users/{id}
in: query in: query
required: false required: false
type: string type: string
...@@ -585,7 +585,7 @@ paths: ...@@ -585,7 +585,7 @@ paths:
- name: user - name: user
description: |- description: |-
The creator of tags. The creator of tags.
Format: users/{uid} Format: users/{id}
in: query in: query
required: false required: false
type: string type: string
...@@ -915,7 +915,8 @@ paths: ...@@ -915,7 +915,8 @@ paths:
- name: memo.name - name: memo.name
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
id is the system generated id.
in: path in: path
required: true required: true
type: string type: string
...@@ -926,15 +927,16 @@ paths: ...@@ -926,15 +927,16 @@ paths:
schema: schema:
type: object type: object
properties: properties:
resourceId: uid:
type: string type: string
description: The user defined id of the memo.
rowStatus: rowStatus:
$ref: '#/definitions/apiv2RowStatus' $ref: '#/definitions/apiv2RowStatus'
creator: creator:
type: string type: string
title: |- title: |-
The name of the creator. The name of the creator.
Format: users/{uid} Format: users/{id}
createTime: createTime:
type: string type: string
format: date-time format: date-time
...@@ -991,7 +993,7 @@ paths: ...@@ -991,7 +993,7 @@ paths:
- name: name_1 - name: name_1
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1038,7 +1040,7 @@ paths: ...@@ -1038,7 +1040,7 @@ paths:
- name: name_2 - name: name_2
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1062,7 +1064,7 @@ paths: ...@@ -1062,7 +1064,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the user. The name of the user.
Format: users/{uid} Format: users/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1085,7 +1087,7 @@ paths: ...@@ -1085,7 +1087,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the user. The name of the user.
Format: users/{uid} Format: users/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1109,7 +1111,7 @@ paths: ...@@ -1109,7 +1111,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the user. The name of the user.
Format: users/{uid} Format: users/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1132,7 +1134,7 @@ paths: ...@@ -1132,7 +1134,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the user. The name of the user.
Format: users/{uid} Format: users/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1161,7 +1163,7 @@ paths: ...@@ -1161,7 +1163,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the user. The name of the user.
Format: users/{uid} Format: users/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1190,7 +1192,7 @@ paths: ...@@ -1190,7 +1192,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1213,7 +1215,7 @@ paths: ...@@ -1213,7 +1215,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1251,7 +1253,7 @@ paths: ...@@ -1251,7 +1253,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1274,7 +1276,7 @@ paths: ...@@ -1274,7 +1276,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1287,7 +1289,7 @@ paths: ...@@ -1287,7 +1289,7 @@ paths:
- name: reaction.creator - name: reaction.creator
description: |- description: |-
The name of the creator. The name of the creator.
Format: users/{uid} Format: users/{id}
in: query in: query
required: false required: false
type: string type: string
...@@ -1333,7 +1335,7 @@ paths: ...@@ -1333,7 +1335,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1362,7 +1364,7 @@ paths: ...@@ -1362,7 +1364,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1385,7 +1387,7 @@ paths: ...@@ -1385,7 +1387,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1414,7 +1416,7 @@ paths: ...@@ -1414,7 +1416,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1437,7 +1439,7 @@ paths: ...@@ -1437,7 +1439,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1466,7 +1468,7 @@ paths: ...@@ -1466,7 +1468,7 @@ paths:
- name: name - name: name
description: |- description: |-
The name of the user. The name of the user.
Format: users/{uid} Format: users/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1490,7 +1492,7 @@ paths: ...@@ -1490,7 +1492,7 @@ paths:
- name: setting.name - name: setting.name
description: |- description: |-
The name of the user. The name of the user.
Format: users/{uid} Format: users/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1532,7 +1534,7 @@ paths: ...@@ -1532,7 +1534,7 @@ paths:
- name: user.name - name: user.name
description: |- description: |-
The name of the user. The name of the user.
Format: users/{uid} Format: users/{id}
in: path in: path
required: true required: true
type: string type: string
...@@ -1656,7 +1658,7 @@ definitions: ...@@ -1656,7 +1658,7 @@ definitions:
type: string type: string
title: |- title: |-
The name of the creator. The name of the creator.
Format: users/{uid} Format: users/{id}
contentId: contentId:
type: string type: string
reactionType: reactionType:
...@@ -1692,7 +1694,7 @@ definitions: ...@@ -1692,7 +1694,7 @@ definitions:
type: string type: string
title: |- title: |-
The name of the user. The name of the user.
Format: users/{uid} Format: users/{id}
locale: locale:
type: string type: string
description: The preferred locale of the user. description: The preferred locale of the user.
...@@ -2078,18 +2080,20 @@ definitions: ...@@ -2078,18 +2080,20 @@ definitions:
properties: properties:
name: name:
type: string type: string
title: |- description: |-
The name of the memo. The name of the memo.
Format: memos/{uid} Format: memos/{id}
resourceId: id is the system generated id.
uid:
type: string type: string
description: The user defined id of the memo.
rowStatus: rowStatus:
$ref: '#/definitions/apiv2RowStatus' $ref: '#/definitions/apiv2RowStatus'
creator: creator:
type: string type: string
title: |- title: |-
The name of the creator. The name of the creator.
Format: users/{uid} Format: users/{id}
createTime: createTime:
type: string type: string
format: date-time format: date-time
...@@ -2230,7 +2234,7 @@ definitions: ...@@ -2230,7 +2234,7 @@ definitions:
type: string type: string
title: |- title: |-
The creator of tags. The creator of tags.
Format: users/{uid} Format: users/{id}
v2UpdateInboxResponse: v2UpdateInboxResponse:
type: object type: object
properties: properties:
...@@ -2283,7 +2287,7 @@ definitions: ...@@ -2283,7 +2287,7 @@ definitions:
type: string type: string
title: |- title: |-
The name of the user. The name of the user.
Format: users/{uid} Format: users/{id}
id: id:
type: integer type: integer
format: int32 format: int32
......
...@@ -189,7 +189,7 @@ func (s *APIV2Service) SignUp(ctx context.Context, request *apiv2pb.SignUpReques ...@@ -189,7 +189,7 @@ func (s *APIV2Service) SignUp(ctx context.Context, request *apiv2pb.SignUpReques
Nickname: request.Username, Nickname: request.Username,
PasswordHash: string(passwordHash), PasswordHash: string(passwordHash),
} }
if !util.ResourceNameMatcher.MatchString(strings.ToLower(create.Username)) { if !util.UIDMatcher.MatchString(strings.ToLower(create.Username)) {
return nil, status.Errorf(codes.InvalidArgument, "invalid username: %s", create.Username) return nil, status.Errorf(codes.InvalidArgument, "invalid username: %s", create.Username)
} }
......
...@@ -44,10 +44,10 @@ func (s *APIV2Service) CreateMemo(ctx context.Context, request *apiv2pb.CreateMe ...@@ -44,10 +44,10 @@ func (s *APIV2Service) CreateMemo(ctx context.Context, request *apiv2pb.CreateMe
} }
create := &store.Memo{ create := &store.Memo{
ResourceName: shortuuid.New(), UID: shortuuid.New(),
CreatorID: user.ID, CreatorID: user.ID,
Content: request.Content, Content: request.Content,
Visibility: convertVisibilityToStore(request.Visibility), Visibility: convertVisibilityToStore(request.Visibility),
} }
// Find disable public memos system setting. // Find disable public memos system setting.
disablePublicMemosSystem, err := s.getDisablePublicMemosSystemSettingValue(ctx) disablePublicMemosSystem, err := s.getDisablePublicMemosSystemSettingValue(ctx)
...@@ -231,9 +231,9 @@ func (s *APIV2Service) UpdateMemo(ctx context.Context, request *apiv2pb.UpdateMe ...@@ -231,9 +231,9 @@ func (s *APIV2Service) UpdateMemo(ctx context.Context, request *apiv2pb.UpdateMe
for _, path := range request.UpdateMask.Paths { for _, path := range request.UpdateMask.Paths {
if path == "content" { if path == "content" {
update.Content = &request.Memo.Content update.Content = &request.Memo.Content
} else if path == "resource_name" { } else if path == "uid" {
update.ResourceName = &request.Memo.Name update.UID = &request.Memo.Name
if !util.ResourceNameMatcher.MatchString(*update.ResourceName) { if !util.UIDMatcher.MatchString(*update.UID) {
return nil, status.Errorf(codes.InvalidArgument, "invalid resource name") return nil, status.Errorf(codes.InvalidArgument, "invalid resource name")
} }
} else if path == "visibility" { } else if path == "visibility" {
...@@ -555,7 +555,7 @@ func (s *APIV2Service) convertMemoFromStore(ctx context.Context, memo *store.Mem ...@@ -555,7 +555,7 @@ func (s *APIV2Service) convertMemoFromStore(ctx context.Context, memo *store.Mem
return &apiv2pb.Memo{ return &apiv2pb.Memo{
Name: name, Name: name,
ResourceId: memo.ResourceName, Uid: memo.UID,
RowStatus: convertRowStatusFromStore(memo.RowStatus), RowStatus: convertRowStatusFromStore(memo.RowStatus),
Creator: fmt.Sprintf("%s%d", UserNamePrefix, creator.ID), Creator: fmt.Sprintf("%s%d", UserNamePrefix, creator.ID),
CreateTime: timestamppb.New(time.Unix(memo.CreatedTs, 0)), CreateTime: timestamppb.New(time.Unix(memo.CreatedTs, 0)),
...@@ -690,8 +690,8 @@ func (s *APIV2Service) buildMemoFindWithFilter(ctx context.Context, find *store. ...@@ -690,8 +690,8 @@ func (s *APIV2Service) buildMemoFindWithFilter(ctx context.Context, find *store.
} }
find.CreatorID = &user.ID find.CreatorID = &user.ID
} }
if filter.ResourceName != nil { if filter.UID != nil {
find.ResourceName = filter.ResourceName find.UID = filter.UID
} }
if filter.RowStatus != nil { if filter.RowStatus != nil {
find.RowStatus = filter.RowStatus find.RowStatus = filter.RowStatus
...@@ -728,7 +728,7 @@ var SearchMemosFilterCELAttributes = []cel.EnvOption{ ...@@ -728,7 +728,7 @@ var SearchMemosFilterCELAttributes = []cel.EnvOption{
cel.Variable("display_time_before", cel.IntType), cel.Variable("display_time_before", cel.IntType),
cel.Variable("display_time_after", cel.IntType), cel.Variable("display_time_after", cel.IntType),
cel.Variable("creator", cel.StringType), cel.Variable("creator", cel.StringType),
cel.Variable("resource_name", cel.StringType), cel.Variable("uid", cel.StringType),
cel.Variable("row_status", cel.StringType), cel.Variable("row_status", cel.StringType),
} }
...@@ -739,7 +739,7 @@ type SearchMemosFilter struct { ...@@ -739,7 +739,7 @@ type SearchMemosFilter struct {
DisplayTimeBefore *int64 DisplayTimeBefore *int64
DisplayTimeAfter *int64 DisplayTimeAfter *int64
Creator *string Creator *string
ResourceName *string UID *string
RowStatus *store.RowStatus RowStatus *store.RowStatus
} }
...@@ -792,9 +792,9 @@ func findSearchMemosField(callExpr *expr.Expr_Call, filter *SearchMemosFilter) { ...@@ -792,9 +792,9 @@ func findSearchMemosField(callExpr *expr.Expr_Call, filter *SearchMemosFilter) {
} else if idExpr.Name == "creator" { } else if idExpr.Name == "creator" {
creator := callExpr.Args[1].GetConstExpr().GetStringValue() creator := callExpr.Args[1].GetConstExpr().GetStringValue()
filter.Creator = &creator filter.Creator = &creator
} else if idExpr.Name == "resource_name" { } else if idExpr.Name == "uid" {
resourceName := callExpr.Args[1].GetConstExpr().GetStringValue() uid := callExpr.Args[1].GetConstExpr().GetStringValue()
filter.ResourceName = &resourceName filter.UID = &uid
} else if idExpr.Name == "row_status" { } else if idExpr.Name == "row_status" {
rowStatus := store.RowStatus(callExpr.Args[1].GetConstExpr().GetStringValue()) rowStatus := store.RowStatus(callExpr.Args[1].GetConstExpr().GetStringValue())
filter.RowStatus = &rowStatus filter.RowStatus = &rowStatus
......
...@@ -31,7 +31,7 @@ func (s *APIV2Service) CreateResource(ctx context.Context, request *apiv2pb.Crea ...@@ -31,7 +31,7 @@ func (s *APIV2Service) CreateResource(ctx context.Context, request *apiv2pb.Crea
} }
create := &store.Resource{ create := &store.Resource{
ResourceName: shortuuid.New(), UID: shortuuid.New(),
CreatorID: user.ID, CreatorID: user.ID,
Filename: request.Filename, Filename: request.Filename,
ExternalLink: request.ExternalLink, ExternalLink: request.ExternalLink,
...@@ -87,7 +87,7 @@ func (s *APIV2Service) GetResource(ctx context.Context, request *apiv2pb.GetReso ...@@ -87,7 +87,7 @@ func (s *APIV2Service) GetResource(ctx context.Context, request *apiv2pb.GetReso
func (s *APIV2Service) GetResourceByName(ctx context.Context, request *apiv2pb.GetResourceByNameRequest) (*apiv2pb.GetResourceByNameResponse, error) { func (s *APIV2Service) GetResourceByName(ctx context.Context, request *apiv2pb.GetResourceByNameRequest) (*apiv2pb.GetResourceByNameResponse, error) {
resource, err := s.Store.GetResource(ctx, &store.FindResource{ resource, err := s.Store.GetResource(ctx, &store.FindResource{
ResourceName: &request.Name, UID: &request.Name,
}) })
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get resource: %v", err) return nil, status.Errorf(codes.Internal, "failed to get resource: %v", err)
...@@ -165,7 +165,7 @@ func (s *APIV2Service) convertResourceFromStore(ctx context.Context, resource *s ...@@ -165,7 +165,7 @@ func (s *APIV2Service) convertResourceFromStore(ctx context.Context, resource *s
return &apiv2pb.Resource{ return &apiv2pb.Resource{
Id: resource.ID, Id: resource.ID,
Name: resource.ResourceName, Name: resource.UID,
CreateTime: timestamppb.New(time.Unix(resource.CreatedTs, 0)), CreateTime: timestamppb.New(time.Unix(resource.CreatedTs, 0)),
Filename: resource.Filename, Filename: resource.Filename,
ExternalLink: resource.ExternalLink, ExternalLink: resource.ExternalLink,
......
...@@ -105,7 +105,7 @@ func (s *APIV2Service) CreateUser(ctx context.Context, request *apiv2pb.CreateUs ...@@ -105,7 +105,7 @@ func (s *APIV2Service) CreateUser(ctx context.Context, request *apiv2pb.CreateUs
if currentUser.Role != store.RoleHost { if currentUser.Role != store.RoleHost {
return nil, status.Errorf(codes.PermissionDenied, "permission denied") return nil, status.Errorf(codes.PermissionDenied, "permission denied")
} }
if !util.ResourceNameMatcher.MatchString(strings.ToLower(request.User.Username)) { if !util.UIDMatcher.MatchString(strings.ToLower(request.User.Username)) {
return nil, status.Errorf(codes.InvalidArgument, "invalid username: %s", request.User.Username) return nil, status.Errorf(codes.InvalidArgument, "invalid username: %s", request.User.Username)
} }
passwordHash, err := bcrypt.GenerateFromPassword([]byte(request.User.Password), bcrypt.DefaultCost) passwordHash, err := bcrypt.GenerateFromPassword([]byte(request.User.Password), bcrypt.DefaultCost)
...@@ -161,7 +161,7 @@ func (s *APIV2Service) UpdateUser(ctx context.Context, request *apiv2pb.UpdateUs ...@@ -161,7 +161,7 @@ func (s *APIV2Service) UpdateUser(ctx context.Context, request *apiv2pb.UpdateUs
} }
for _, field := range request.UpdateMask.Paths { for _, field := range request.UpdateMask.Paths {
if field == "username" { if field == "username" {
if !util.ResourceNameMatcher.MatchString(strings.ToLower(request.User.Username)) { if !util.UIDMatcher.MatchString(strings.ToLower(request.User.Username)) {
return nil, status.Errorf(codes.InvalidArgument, "invalid username: %s", request.User.Username) return nil, status.Errorf(codes.InvalidArgument, "invalid username: %s", request.User.Username)
} }
update.Username = &request.User.Username update.Username = &request.User.Username
......
...@@ -53,11 +53,11 @@ func (s *FrontendService) Serve(ctx context.Context, e *echo.Echo) { ...@@ -53,11 +53,11 @@ func (s *FrontendService) Serve(ctx context.Context, e *echo.Echo) {
func (s *FrontendService) registerRoutes(e *echo.Echo) { func (s *FrontendService) registerRoutes(e *echo.Echo) {
rawIndexHTML := getRawIndexHTML() rawIndexHTML := getRawIndexHTML()
e.GET("/m/:name", func(c echo.Context) error { e.GET("/m/:uid", func(c echo.Context) error {
ctx := c.Request().Context() ctx := c.Request().Context()
resourceName := c.Param("name") uid := c.Param("uid")
memo, err := s.Store.GetMemo(ctx, &store.FindMemo{ memo, err := s.Store.GetMemo(ctx, &store.FindMemo{
ResourceName: &resourceName, UID: &uid,
}) })
if err != nil { if err != nil {
return c.HTML(http.StatusOK, rawIndexHTML) return c.HTML(http.StatusOK, rawIndexHTML)
...@@ -108,7 +108,7 @@ Sitemap: %s/sitemap.xml`, instanceURL, instanceURL) ...@@ -108,7 +108,7 @@ Sitemap: %s/sitemap.xml`, instanceURL, instanceURL)
return err return err
} }
for _, memo := range memoList { for _, memo := range memoList {
urlsets = append(urlsets, fmt.Sprintf(`<url><loc>%s</loc></url>`, fmt.Sprintf("%s/m/%s", instanceURL, memo.ResourceName))) urlsets = append(urlsets, fmt.Sprintf(`<url><loc>%s</loc></url>`, fmt.Sprintf("%s/m/%s", instanceURL, memo.UID)))
} }
sitemap := fmt.Sprintf(`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">%s</urlset>`, strings.Join(urlsets, "\n")) sitemap := fmt.Sprintf(`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">%s</urlset>`, strings.Join(urlsets, "\n"))
return c.XMLBlob(http.StatusOK, []byte(sitemap)) return c.XMLBlob(http.StatusOK, []byte(sitemap))
......
...@@ -42,22 +42,22 @@ func NewResourceService(profile *profile.Profile, store *store.Store) *ResourceS ...@@ -42,22 +42,22 @@ func NewResourceService(profile *profile.Profile, store *store.Store) *ResourceS
} }
func (s *ResourceService) RegisterRoutes(g *echo.Group) { func (s *ResourceService) RegisterRoutes(g *echo.Group) {
g.GET("/r/:resourceName", s.streamResource) g.GET("/r/:uid", s.streamResource)
g.GET("/r/:resourceName/*", s.streamResource) g.GET("/r/:uid/*", s.streamResource)
} }
func (s *ResourceService) streamResource(c echo.Context) error { func (s *ResourceService) streamResource(c echo.Context) error {
ctx := c.Request().Context() ctx := c.Request().Context()
resourceName := c.Param("resourceName") uid := c.Param("uid")
resource, err := s.Store.GetResource(ctx, &store.FindResource{ resource, err := s.Store.GetResource(ctx, &store.FindResource{
ResourceName: &resourceName, UID: &uid,
GetBlob: true, GetBlob: true,
}) })
if err != nil { if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to find resource by id: %s", resourceName)).SetInternal(err) return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to find resource by uid: %s", uid)).SetInternal(err)
} }
if resource == nil { if resource == nil {
return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Resource not found: %s", resourceName)) return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Resource not found: %s", uid))
} }
// Check the related memo visibility. // Check the related memo visibility.
if resource.MemoID != nil { if resource.MemoID != nil {
......
...@@ -112,7 +112,7 @@ func (s *RSSService) generateRSSFromMemoList(ctx context.Context, memoList []*st ...@@ -112,7 +112,7 @@ func (s *RSSService) generateRSSFromMemoList(ctx context.Context, memoList []*st
} }
feed.Items[i] = &feeds.Item{ feed.Items[i] = &feeds.Item{
Title: getRSSItemTitle(memo.Content), Title: getRSSItemTitle(memo.Content),
Link: &feeds.Link{Href: baseURL + "/m/" + memo.ResourceName}, Link: &feeds.Link{Href: baseURL + "/m/" + memo.UID},
Description: description, Description: description,
Created: time.Unix(memo.CreatedTs, 0), Created: time.Unix(memo.CreatedTs, 0),
} }
...@@ -128,7 +128,7 @@ func (s *RSSService) generateRSSFromMemoList(ctx context.Context, memoList []*st ...@@ -128,7 +128,7 @@ func (s *RSSService) generateRSSFromMemoList(ctx context.Context, memoList []*st
if resource.ExternalLink != "" { if resource.ExternalLink != "" {
enclosure.Url = resource.ExternalLink enclosure.Url = resource.ExternalLink
} else { } else {
enclosure.Url = baseURL + "/o/r/" + resource.ResourceName enclosure.Url = baseURL + "/o/r/" + resource.UID
} }
enclosure.Length = strconv.Itoa(int(resource.Size)) enclosure.Length = strconv.Itoa(int(resource.Size))
enclosure.Type = resource.Type enclosure.Type = resource.Type
......
...@@ -12,9 +12,9 @@ import ( ...@@ -12,9 +12,9 @@ import (
) )
func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, error) { func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, error) {
fields := []string{"`resource_name`", "`creator_id`", "`content`", "`visibility`"} fields := []string{"`uid`", "`creator_id`", "`content`", "`visibility`"}
placeholder := []string{"?", "?", "?", "?"} placeholder := []string{"?", "?", "?", "?"}
args := []any{create.ResourceName, create.CreatorID, create.Content, create.Visibility} args := []any{create.UID, create.CreatorID, create.Content, create.Visibility}
stmt := "INSERT INTO `memo` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ")" stmt := "INSERT INTO `memo` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ")"
result, err := d.db.ExecContext(ctx, stmt, args...) result, err := d.db.ExecContext(ctx, stmt, args...)
...@@ -43,8 +43,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo ...@@ -43,8 +43,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if v := find.ID; v != nil { if v := find.ID; v != nil {
where, args = append(where, "`memo`.`id` = ?"), append(args, *v) where, args = append(where, "`memo`.`id` = ?"), append(args, *v)
} }
if v := find.ResourceName; v != nil { if v := find.UID; v != nil {
where, args = append(where, "`memo`.`resource_name` = ?"), append(args, *v) where, args = append(where, "`memo`.`uid` = ?"), append(args, *v)
} }
if v := find.CreatorID; v != nil { if v := find.CreatorID; v != nil {
where, args = append(where, "`memo`.`creator_id` = ?"), append(args, *v) where, args = append(where, "`memo`.`creator_id` = ?"), append(args, *v)
...@@ -94,7 +94,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo ...@@ -94,7 +94,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
fields := []string{ fields := []string{
"`memo`.`id` AS `id`", "`memo`.`id` AS `id`",
"`memo`.`resource_name` AS `resource_name`", "`memo`.`uid` AS `uid`",
"`memo`.`creator_id` AS `creator_id`", "`memo`.`creator_id` AS `creator_id`",
"UNIX_TIMESTAMP(`memo`.`created_ts`) AS `created_ts`", "UNIX_TIMESTAMP(`memo`.`created_ts`) AS `created_ts`",
"UNIX_TIMESTAMP(`memo`.`updated_ts`) AS `updated_ts`", "UNIX_TIMESTAMP(`memo`.`updated_ts`) AS `updated_ts`",
...@@ -126,7 +126,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo ...@@ -126,7 +126,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
var memo store.Memo var memo store.Memo
dests := []any{ dests := []any{
&memo.ID, &memo.ID,
&memo.ResourceName, &memo.UID,
&memo.CreatorID, &memo.CreatorID,
&memo.CreatedTs, &memo.CreatedTs,
&memo.UpdatedTs, &memo.UpdatedTs,
...@@ -166,8 +166,8 @@ func (d *DB) GetMemo(ctx context.Context, find *store.FindMemo) (*store.Memo, er ...@@ -166,8 +166,8 @@ func (d *DB) GetMemo(ctx context.Context, find *store.FindMemo) (*store.Memo, er
func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error { func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error {
set, args := []string{}, []any{} set, args := []string{}, []any{}
if v := update.ResourceName; v != nil { if v := update.UID; v != nil {
set, args = append(set, "`resource_name` = ?"), append(args, *v) set, args = append(set, "`uid` = ?"), append(args, *v)
} }
if v := update.CreatedTs; v != nil { if v := update.CreatedTs; v != nil {
set, args = append(set, "`created_ts` = FROM_UNIXTIME(?)"), append(args, *v) set, args = append(set, "`created_ts` = FROM_UNIXTIME(?)"), append(args, *v)
......
...@@ -37,7 +37,7 @@ CREATE TABLE `user_setting` ( ...@@ -37,7 +37,7 @@ CREATE TABLE `user_setting` (
-- memo -- memo
CREATE TABLE `memo` ( CREATE TABLE `memo` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`resource_name` VARCHAR(256) NOT NULL UNIQUE, `uid` VARCHAR(256) NOT NULL UNIQUE,
`creator_id` INT NOT NULL, `creator_id` INT NOT NULL,
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
...@@ -65,7 +65,7 @@ CREATE TABLE `memo_relation` ( ...@@ -65,7 +65,7 @@ CREATE TABLE `memo_relation` (
-- resource -- resource
CREATE TABLE `resource` ( CREATE TABLE `resource` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`resource_name` VARCHAR(256) NOT NULL UNIQUE, `uid` VARCHAR(256) NOT NULL UNIQUE,
`creator_id` INT NOT NULL, `creator_id` INT NOT NULL,
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
......
...@@ -10,9 +10,9 @@ import ( ...@@ -10,9 +10,9 @@ import (
) )
func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store.Resource, error) { func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store.Resource, error) {
fields := []string{"`resource_name`", "`filename`", "`blob`", "`external_link`", "`type`", "`size`", "`creator_id`", "`internal_path`", "`memo_id`"} fields := []string{"`uid`", "`filename`", "`blob`", "`external_link`", "`type`", "`size`", "`creator_id`", "`internal_path`", "`memo_id`"}
placeholder := []string{"?", "?", "?", "?", "?", "?", "?", "?", "?"} placeholder := []string{"?", "?", "?", "?", "?", "?", "?", "?", "?"}
args := []any{create.ResourceName, create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID} args := []any{create.UID, create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID}
stmt := "INSERT INTO `resource` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ")" stmt := "INSERT INTO `resource` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ")"
result, err := d.db.ExecContext(ctx, stmt, args...) result, err := d.db.ExecContext(ctx, stmt, args...)
...@@ -35,8 +35,8 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -35,8 +35,8 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
if v := find.ID; v != nil { if v := find.ID; v != nil {
where, args = append(where, "`id` = ?"), append(args, *v) where, args = append(where, "`id` = ?"), append(args, *v)
} }
if v := find.ResourceName; v != nil { if v := find.UID; v != nil {
where, args = append(where, "`resource_name` = ?"), append(args, *v) where, args = append(where, "`uid` = ?"), append(args, *v)
} }
if v := find.CreatorID; v != nil { if v := find.CreatorID; v != nil {
where, args = append(where, "`creator_id` = ?"), append(args, *v) where, args = append(where, "`creator_id` = ?"), append(args, *v)
...@@ -51,7 +51,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -51,7 +51,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
where = append(where, "`memo_id` IS NOT NULL") where = append(where, "`memo_id` IS NOT NULL")
} }
fields := []string{"`id`", "`resource_name`", "`filename`", "`external_link`", "`type`", "`size`", "`creator_id`", "UNIX_TIMESTAMP(`created_ts`)", "UNIX_TIMESTAMP(`updated_ts`)", "`internal_path`", "`memo_id`"} fields := []string{"`id`", "`uid`", "`filename`", "`external_link`", "`type`", "`size`", "`creator_id`", "UNIX_TIMESTAMP(`created_ts`)", "UNIX_TIMESTAMP(`updated_ts`)", "`internal_path`", "`memo_id`"}
if find.GetBlob { if find.GetBlob {
fields = append(fields, "`blob`") fields = append(fields, "`blob`")
} }
...@@ -76,7 +76,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -76,7 +76,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
var memoID sql.NullInt32 var memoID sql.NullInt32
dests := []any{ dests := []any{
&resource.ID, &resource.ID,
&resource.ResourceName, &resource.UID,
&resource.Filename, &resource.Filename,
&resource.ExternalLink, &resource.ExternalLink,
&resource.Type, &resource.Type,
...@@ -121,8 +121,8 @@ func (d *DB) GetResource(ctx context.Context, find *store.FindResource) (*store. ...@@ -121,8 +121,8 @@ func (d *DB) GetResource(ctx context.Context, find *store.FindResource) (*store.
func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (*store.Resource, error) { func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (*store.Resource, error) {
set, args := []string{}, []any{} set, args := []string{}, []any{}
if v := update.ResourceName; v != nil { if v := update.UID; v != nil {
set, args = append(set, "`resource_name` = ?"), append(args, *v) set, args = append(set, "`uid` = ?"), append(args, *v)
} }
if v := update.UpdatedTs; v != nil { if v := update.UpdatedTs; v != nil {
set, args = append(set, "`updated_ts` = FROM_UNIXTIME(?)"), append(args, *v) set, args = append(set, "`updated_ts` = FROM_UNIXTIME(?)"), append(args, *v)
......
...@@ -12,8 +12,8 @@ import ( ...@@ -12,8 +12,8 @@ import (
) )
func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, error) { func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, error) {
fields := []string{"resource_name", "creator_id", "content", "visibility"} fields := []string{"uid", "creator_id", "content", "visibility"}
args := []any{create.ResourceName, create.CreatorID, create.Content, create.Visibility} args := []any{create.UID, create.CreatorID, create.Content, create.Visibility}
stmt := "INSERT INTO memo (" + strings.Join(fields, ", ") + ") VALUES (" + placeholders(len(args)) + ") RETURNING id, created_ts, updated_ts, row_status" stmt := "INSERT INTO memo (" + strings.Join(fields, ", ") + ") VALUES (" + placeholders(len(args)) + ") RETURNING id, created_ts, updated_ts, row_status"
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan( if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
...@@ -34,8 +34,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo ...@@ -34,8 +34,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if v := find.ID; v != nil { if v := find.ID; v != nil {
where, args = append(where, "memo.id = "+placeholder(len(args)+1)), append(args, *v) where, args = append(where, "memo.id = "+placeholder(len(args)+1)), append(args, *v)
} }
if v := find.ResourceName; v != nil { if v := find.UID; v != nil {
where, args = append(where, "memo.resource_name = "+placeholder(len(args)+1)), append(args, *v) where, args = append(where, "memo.uid = "+placeholder(len(args)+1)), append(args, *v)
} }
if v := find.CreatorID; v != nil { if v := find.CreatorID; v != nil {
where, args = append(where, "memo.creator_id = "+placeholder(len(args)+1)), append(args, *v) where, args = append(where, "memo.creator_id = "+placeholder(len(args)+1)), append(args, *v)
...@@ -85,7 +85,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo ...@@ -85,7 +85,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
fields := []string{ fields := []string{
`memo.id AS id`, `memo.id AS id`,
`memo.resource_name AS resource_name`, `memo.uid AS uid`,
`memo.creator_id AS creator_id`, `memo.creator_id AS creator_id`,
`memo.created_ts AS created_ts`, `memo.created_ts AS created_ts`,
`memo.updated_ts AS updated_ts`, `memo.updated_ts AS updated_ts`,
...@@ -122,7 +122,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo ...@@ -122,7 +122,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
var memo store.Memo var memo store.Memo
dests := []any{ dests := []any{
&memo.ID, &memo.ID,
&memo.ResourceName, &memo.UID,
&memo.CreatorID, &memo.CreatorID,
&memo.CreatedTs, &memo.CreatedTs,
&memo.UpdatedTs, &memo.UpdatedTs,
...@@ -162,8 +162,8 @@ func (d *DB) GetMemo(ctx context.Context, find *store.FindMemo) (*store.Memo, er ...@@ -162,8 +162,8 @@ func (d *DB) GetMemo(ctx context.Context, find *store.FindMemo) (*store.Memo, er
func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error { func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error {
set, args := []string{}, []any{} set, args := []string{}, []any{}
if v := update.ResourceName; v != nil { if v := update.UID; v != nil {
set, args = append(set, "resource_name = "+placeholder(len(args)+1)), append(args, *v) set, args = append(set, "uid = "+placeholder(len(args)+1)), append(args, *v)
} }
if v := update.CreatedTs; v != nil { if v := update.CreatedTs; v != nil {
set, args = append(set, "created_ts = "+placeholder(len(args)+1)), append(args, *v) set, args = append(set, "created_ts = "+placeholder(len(args)+1)), append(args, *v)
......
...@@ -37,7 +37,7 @@ CREATE TABLE user_setting ( ...@@ -37,7 +37,7 @@ CREATE TABLE user_setting (
-- memo -- memo
CREATE TABLE memo ( CREATE TABLE memo (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
resource_name TEXT NOT NULL UNIQUE, uid TEXT NOT NULL UNIQUE,
creator_id INTEGER NOT NULL, creator_id INTEGER NOT NULL,
created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
...@@ -65,7 +65,7 @@ CREATE TABLE memo_relation ( ...@@ -65,7 +65,7 @@ CREATE TABLE memo_relation (
-- resource -- resource
CREATE TABLE resource ( CREATE TABLE resource (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
resource_name TEXT NOT NULL UNIQUE, uid TEXT NOT NULL UNIQUE,
creator_id INTEGER NOT NULL, creator_id INTEGER NOT NULL,
created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
......
...@@ -10,8 +10,8 @@ import ( ...@@ -10,8 +10,8 @@ import (
) )
func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store.Resource, error) { func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store.Resource, error) {
fields := []string{"resource_name", "filename", "blob", "external_link", "type", "size", "creator_id", "internal_path", "memo_id"} fields := []string{"uid", "filename", "blob", "external_link", "type", "size", "creator_id", "internal_path", "memo_id"}
args := []any{create.ResourceName, create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID} args := []any{create.UID, create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID}
stmt := "INSERT INTO resource (" + strings.Join(fields, ", ") + ") VALUES (" + placeholders(len(args)) + ") RETURNING id, created_ts, updated_ts" stmt := "INSERT INTO resource (" + strings.Join(fields, ", ") + ") VALUES (" + placeholders(len(args)) + ") RETURNING id, created_ts, updated_ts"
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(&create.ID, &create.CreatedTs, &create.UpdatedTs); err != nil { if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(&create.ID, &create.CreatedTs, &create.UpdatedTs); err != nil {
...@@ -26,8 +26,8 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -26,8 +26,8 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
if v := find.ID; v != nil { if v := find.ID; v != nil {
where, args = append(where, "id = "+placeholder(len(args)+1)), append(args, *v) where, args = append(where, "id = "+placeholder(len(args)+1)), append(args, *v)
} }
if v := find.ResourceName; v != nil { if v := find.UID; v != nil {
where, args = append(where, "resource_name = "+placeholder(len(args)+1)), append(args, *v) where, args = append(where, "uid = "+placeholder(len(args)+1)), append(args, *v)
} }
if v := find.CreatorID; v != nil { if v := find.CreatorID; v != nil {
where, args = append(where, "creator_id = "+placeholder(len(args)+1)), append(args, *v) where, args = append(where, "creator_id = "+placeholder(len(args)+1)), append(args, *v)
...@@ -42,7 +42,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -42,7 +42,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
where = append(where, "memo_id IS NOT NULL") where = append(where, "memo_id IS NOT NULL")
} }
fields := []string{"id", "resource_name", "filename", "external_link", "type", "size", "creator_id", "created_ts", "updated_ts", "internal_path", "memo_id"} fields := []string{"id", "uid", "filename", "external_link", "type", "size", "creator_id", "created_ts", "updated_ts", "internal_path", "memo_id"}
if find.GetBlob { if find.GetBlob {
fields = append(fields, "blob") fields = append(fields, "blob")
} }
...@@ -73,7 +73,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -73,7 +73,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
var memoID sql.NullInt32 var memoID sql.NullInt32
dests := []any{ dests := []any{
&resource.ID, &resource.ID,
&resource.ResourceName, &resource.UID,
&resource.Filename, &resource.Filename,
&resource.ExternalLink, &resource.ExternalLink,
&resource.Type, &resource.Type,
...@@ -106,8 +106,8 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -106,8 +106,8 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (*store.Resource, error) { func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (*store.Resource, error) {
set, args := []string{}, []any{} set, args := []string{}, []any{}
if v := update.ResourceName; v != nil { if v := update.UID; v != nil {
set, args = append(set, "resource_name = "+placeholder(len(args)+1)), append(args, *v) set, args = append(set, "uid = "+placeholder(len(args)+1)), append(args, *v)
} }
if v := update.UpdatedTs; v != nil { if v := update.UpdatedTs; v != nil {
set, args = append(set, "updated_ts = "+placeholder(len(args)+1)), append(args, *v) set, args = append(set, "updated_ts = "+placeholder(len(args)+1)), append(args, *v)
...@@ -128,13 +128,13 @@ func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) ( ...@@ -128,13 +128,13 @@ func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (
set, args = append(set, "blob = "+placeholder(len(args)+1)), append(args, v) set, args = append(set, "blob = "+placeholder(len(args)+1)), append(args, v)
} }
fields := []string{"id", "resource_name", "filename", "external_link", "type", "size", "creator_id", "created_ts", "updated_ts", "internal_path"} fields := []string{"id", "uid", "filename", "external_link", "type", "size", "creator_id", "created_ts", "updated_ts", "internal_path"}
stmt := `UPDATE resource SET ` + strings.Join(set, ", ") + ` WHERE id = ` + placeholder(len(args)+1) + ` RETURNING ` + strings.Join(fields, ", ") stmt := `UPDATE resource SET ` + strings.Join(set, ", ") + ` WHERE id = ` + placeholder(len(args)+1) + ` RETURNING ` + strings.Join(fields, ", ")
args = append(args, update.ID) args = append(args, update.ID)
resource := store.Resource{} resource := store.Resource{}
dests := []any{ dests := []any{
&resource.ID, &resource.ID,
&resource.ResourceName, &resource.UID,
&resource.Filename, &resource.Filename,
&resource.ExternalLink, &resource.ExternalLink,
&resource.Type, &resource.Type,
......
...@@ -10,9 +10,9 @@ import ( ...@@ -10,9 +10,9 @@ import (
) )
func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, error) { func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, error) {
fields := []string{"`resource_name`", "`creator_id`", "`content`", "`visibility`"} fields := []string{"`uid`", "`creator_id`", "`content`", "`visibility`"}
placeholder := []string{"?", "?", "?", "?"} placeholder := []string{"?", "?", "?", "?"}
args := []any{create.ResourceName, create.CreatorID, create.Content, create.Visibility} args := []any{create.UID, create.CreatorID, create.Content, create.Visibility}
stmt := "INSERT INTO `memo` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING `id`, `created_ts`, `updated_ts`, `row_status`" stmt := "INSERT INTO `memo` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING `id`, `created_ts`, `updated_ts`, `row_status`"
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan( if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(
...@@ -33,8 +33,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo ...@@ -33,8 +33,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if v := find.ID; v != nil { if v := find.ID; v != nil {
where, args = append(where, "`memo`.`id` = ?"), append(args, *v) where, args = append(where, "`memo`.`id` = ?"), append(args, *v)
} }
if v := find.ResourceName; v != nil { if v := find.UID; v != nil {
where, args = append(where, "`memo`.`resource_name` = ?"), append(args, *v) where, args = append(where, "`memo`.`uid` = ?"), append(args, *v)
} }
if v := find.CreatorID; v != nil { if v := find.CreatorID; v != nil {
where, args = append(where, "`memo`.`creator_id` = ?"), append(args, *v) where, args = append(where, "`memo`.`creator_id` = ?"), append(args, *v)
...@@ -84,7 +84,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo ...@@ -84,7 +84,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
fields := []string{ fields := []string{
"`memo`.`id` AS `id`", "`memo`.`id` AS `id`",
"`memo`.`resource_name` AS `resource_name`", "`memo`.`uid` AS `uid`",
"`memo`.`creator_id` AS `creator_id`", "`memo`.`creator_id` AS `creator_id`",
"`memo`.`created_ts` AS `created_ts`", "`memo`.`created_ts` AS `created_ts`",
"`memo`.`updated_ts` AS `updated_ts`", "`memo`.`updated_ts` AS `updated_ts`",
...@@ -120,7 +120,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo ...@@ -120,7 +120,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
var memo store.Memo var memo store.Memo
dests := []any{ dests := []any{
&memo.ID, &memo.ID,
&memo.ResourceName, &memo.UID,
&memo.CreatorID, &memo.CreatorID,
&memo.CreatedTs, &memo.CreatedTs,
&memo.UpdatedTs, &memo.UpdatedTs,
...@@ -147,8 +147,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo ...@@ -147,8 +147,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error { func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error {
set, args := []string{}, []any{} set, args := []string{}, []any{}
if v := update.ResourceName; v != nil { if v := update.UID; v != nil {
set, args = append(set, "`resource_name` = ?"), append(args, *v) set, args = append(set, "`uid` = ?"), append(args, *v)
} }
if v := update.CreatedTs; v != nil { if v := update.CreatedTs; v != nil {
set, args = append(set, "`created_ts` = ?"), append(args, *v) set, args = append(set, "`created_ts` = ?"), append(args, *v)
......
...@@ -40,7 +40,7 @@ CREATE TABLE user_setting ( ...@@ -40,7 +40,7 @@ CREATE TABLE user_setting (
-- memo -- memo
CREATE TABLE memo ( CREATE TABLE memo (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
resource_name TEXT NOT NULL UNIQUE, uid TEXT NOT NULL UNIQUE,
creator_id INTEGER NOT NULL, creator_id INTEGER NOT NULL,
created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
...@@ -72,7 +72,7 @@ CREATE TABLE memo_relation ( ...@@ -72,7 +72,7 @@ CREATE TABLE memo_relation (
-- resource -- resource
CREATE TABLE resource ( CREATE TABLE resource (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
resource_name TEXT NOT NULL UNIQUE, uid TEXT NOT NULL UNIQUE,
creator_id INTEGER NOT NULL, creator_id INTEGER NOT NULL,
created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
......
...@@ -10,9 +10,9 @@ import ( ...@@ -10,9 +10,9 @@ import (
) )
func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store.Resource, error) { func (d *DB) CreateResource(ctx context.Context, create *store.Resource) (*store.Resource, error) {
fields := []string{"`resource_name`", "`filename`", "`blob`", "`external_link`", "`type`", "`size`", "`creator_id`", "`internal_path`", "`memo_id`"} fields := []string{"`uid`", "`filename`", "`blob`", "`external_link`", "`type`", "`size`", "`creator_id`", "`internal_path`", "`memo_id`"}
placeholder := []string{"?", "?", "?", "?", "?", "?", "?", "?", "?"} placeholder := []string{"?", "?", "?", "?", "?", "?", "?", "?", "?"}
args := []any{create.ResourceName, create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID} args := []any{create.UID, create.Filename, create.Blob, create.ExternalLink, create.Type, create.Size, create.CreatorID, create.InternalPath, create.MemoID}
stmt := "INSERT INTO `resource` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING `id`, `created_ts`, `updated_ts`" stmt := "INSERT INTO `resource` (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(placeholder, ", ") + ") RETURNING `id`, `created_ts`, `updated_ts`"
if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(&create.ID, &create.CreatedTs, &create.UpdatedTs); err != nil { if err := d.db.QueryRowContext(ctx, stmt, args...).Scan(&create.ID, &create.CreatedTs, &create.UpdatedTs); err != nil {
...@@ -28,8 +28,8 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -28,8 +28,8 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
if v := find.ID; v != nil { if v := find.ID; v != nil {
where, args = append(where, "`id` = ?"), append(args, *v) where, args = append(where, "`id` = ?"), append(args, *v)
} }
if v := find.ResourceName; v != nil { if v := find.UID; v != nil {
where, args = append(where, "`resource_name` = ?"), append(args, *v) where, args = append(where, "`uid` = ?"), append(args, *v)
} }
if v := find.CreatorID; v != nil { if v := find.CreatorID; v != nil {
where, args = append(where, "`creator_id` = ?"), append(args, *v) where, args = append(where, "`creator_id` = ?"), append(args, *v)
...@@ -44,7 +44,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -44,7 +44,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
where = append(where, "`memo_id` IS NOT NULL") where = append(where, "`memo_id` IS NOT NULL")
} }
fields := []string{"`id`", "`resource_name`", "`filename`", "`external_link`", "`type`", "`size`", "`creator_id`", "`created_ts`", "`updated_ts`", "`internal_path`", "`memo_id`"} fields := []string{"`id`", "`uid`", "`filename`", "`external_link`", "`type`", "`size`", "`creator_id`", "`created_ts`", "`updated_ts`", "`internal_path`", "`memo_id`"}
if find.GetBlob { if find.GetBlob {
fields = append(fields, "`blob`") fields = append(fields, "`blob`")
} }
...@@ -69,7 +69,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -69,7 +69,7 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
var memoID sql.NullInt32 var memoID sql.NullInt32
dests := []any{ dests := []any{
&resource.ID, &resource.ID,
&resource.ResourceName, &resource.UID,
&resource.Filename, &resource.Filename,
&resource.ExternalLink, &resource.ExternalLink,
&resource.Type, &resource.Type,
...@@ -102,8 +102,8 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st ...@@ -102,8 +102,8 @@ func (d *DB) ListResources(ctx context.Context, find *store.FindResource) ([]*st
func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (*store.Resource, error) { func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (*store.Resource, error) {
set, args := []string{}, []any{} set, args := []string{}, []any{}
if v := update.ResourceName; v != nil { if v := update.UID; v != nil {
set, args = append(set, "`resource_name` = ?"), append(args, *v) set, args = append(set, "`uid` = ?"), append(args, *v)
} }
if v := update.UpdatedTs; v != nil { if v := update.UpdatedTs; v != nil {
set, args = append(set, "`updated_ts` = ?"), append(args, *v) set, args = append(set, "`updated_ts` = ?"), append(args, *v)
...@@ -125,12 +125,12 @@ func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) ( ...@@ -125,12 +125,12 @@ func (d *DB) UpdateResource(ctx context.Context, update *store.UpdateResource) (
} }
args = append(args, update.ID) args = append(args, update.ID)
fields := []string{"`id`", "`resource_name`", "`filename`", "`external_link`", "`type`", "`size`", "`creator_id`", "`created_ts`", "`updated_ts`", "`internal_path`"} fields := []string{"`id`", "`uid`", "`filename`", "`external_link`", "`type`", "`size`", "`creator_id`", "`created_ts`", "`updated_ts`", "`internal_path`"}
stmt := "UPDATE `resource` SET " + strings.Join(set, ", ") + " WHERE `id` = ? RETURNING " + strings.Join(fields, ", ") stmt := "UPDATE `resource` SET " + strings.Join(set, ", ") + " WHERE `id` = ? RETURNING " + strings.Join(fields, ", ")
resource := store.Resource{} resource := store.Resource{}
dests := []any{ dests := []any{
&resource.ID, &resource.ID,
&resource.ResourceName, &resource.UID,
&resource.Filename, &resource.Filename,
&resource.ExternalLink, &resource.ExternalLink,
&resource.Type, &resource.Type,
......
INSERT INTO INSERT INTO
memo ( memo (
`id`, `id`,
`resource_name`, `uid`,
`content`, `content`,
`creator_id` `creator_id`
) )
...@@ -16,7 +16,7 @@ VALUES ...@@ -16,7 +16,7 @@ VALUES
INSERT INTO INSERT INTO
memo ( memo (
`id`, `id`,
`resource_name`, `uid`,
`content`, `content`,
`creator_id`, `creator_id`,
`visibility` `visibility`
...@@ -36,7 +36,7 @@ VALUES ...@@ -36,7 +36,7 @@ VALUES
INSERT INTO INSERT INTO
memo ( memo (
`id`, `id`,
`resource_name`, `uid`,
`content`, `content`,
`creator_id`, `creator_id`,
`visibility` `visibility`
...@@ -54,7 +54,7 @@ VALUES ...@@ -54,7 +54,7 @@ VALUES
INSERT INTO INSERT INTO
memo ( memo (
`id`, `id`,
`resource_name`, `uid`,
`content`, `content`,
`creator_id`, `creator_id`,
`visibility` `visibility`
...@@ -74,7 +74,7 @@ VALUES ...@@ -74,7 +74,7 @@ VALUES
INSERT INTO INSERT INTO
memo ( memo (
`id`, `id`,
`resource_name`, `uid`,
`content`, `content`,
`creator_id`, `creator_id`,
`visibility` `visibility`
......
INSERT INTO INSERT INTO
resource (`resource_name`, `creator_id`, `filename`, `external_link`, `type`, `memo_id`) resource (`uid`, `creator_id`, `filename`, `external_link`, `type`, `memo_id`)
VALUES VALUES
("Pw2awZvxxLK4sPRtHmYuS7", 101, 'slash-demo.png', 'https://github.com/yourselfhosted/slash/blob/main/docs/assets/demo.png?raw=true', 'image/png', 3); ("Pw2awZvxxLK4sPRtHmYuS7", 101, 'slash-demo.png', 'https://github.com/yourselfhosted/slash/blob/main/docs/assets/demo.png?raw=true', 'image/png', 3);
...@@ -32,8 +32,10 @@ func (v Visibility) String() string { ...@@ -32,8 +32,10 @@ func (v Visibility) String() string {
} }
type Memo struct { type Memo struct {
ID int32 // ID is the system generated unique identifier for the memo.
ResourceName string ID int32
// UID is the user defined unique identifier for the memo.
UID string
// Standard fields // Standard fields
RowStatus RowStatus RowStatus RowStatus
...@@ -51,8 +53,8 @@ type Memo struct { ...@@ -51,8 +53,8 @@ type Memo struct {
} }
type FindMemo struct { type FindMemo struct {
ID *int32 ID *int32
ResourceName *string UID *string
// Standard fields // Standard fields
RowStatus *RowStatus RowStatus *RowStatus
...@@ -76,13 +78,13 @@ type FindMemo struct { ...@@ -76,13 +78,13 @@ type FindMemo struct {
} }
type UpdateMemo struct { type UpdateMemo struct {
ID int32 ID int32
ResourceName *string UID *string
CreatedTs *int64 CreatedTs *int64
UpdatedTs *int64 UpdatedTs *int64
RowStatus *RowStatus RowStatus *RowStatus
Content *string Content *string
Visibility *Visibility Visibility *Visibility
} }
type DeleteMemo struct { type DeleteMemo struct {
...@@ -90,8 +92,8 @@ type DeleteMemo struct { ...@@ -90,8 +92,8 @@ type DeleteMemo struct {
} }
func (s *Store) CreateMemo(ctx context.Context, create *Memo) (*Memo, error) { func (s *Store) CreateMemo(ctx context.Context, create *Memo) (*Memo, error) {
if !util.ResourceNameMatcher.MatchString(create.ResourceName) { if !util.UIDMatcher.MatchString(create.UID) {
return nil, errors.New("resource name is invalid") return nil, errors.New("invalid uid")
} }
return s.driver.CreateMemo(ctx, create) return s.driver.CreateMemo(ctx, create)
} }
...@@ -114,8 +116,8 @@ func (s *Store) GetMemo(ctx context.Context, find *FindMemo) (*Memo, error) { ...@@ -114,8 +116,8 @@ func (s *Store) GetMemo(ctx context.Context, find *FindMemo) (*Memo, error) {
} }
func (s *Store) UpdateMemo(ctx context.Context, update *UpdateMemo) error { func (s *Store) UpdateMemo(ctx context.Context, update *UpdateMemo) error {
if update.ResourceName != nil && !util.ResourceNameMatcher.MatchString(*update.ResourceName) { if update.UID != nil && !util.UIDMatcher.MatchString(*update.UID) {
return errors.New("resource name is invalid") return errors.New("invalid uid")
} }
return s.driver.UpdateMemo(ctx, update) return s.driver.UpdateMemo(ctx, update)
} }
......
...@@ -17,8 +17,10 @@ const ( ...@@ -17,8 +17,10 @@ const (
) )
type Resource struct { type Resource struct {
ID int32 // ID is the system generated unique identifier for the resource.
ResourceName string ID int32
// UID is the user defined unique identifier for the resource.
UID string
// Standard fields // Standard fields
CreatorID int32 CreatorID int32
...@@ -38,7 +40,7 @@ type Resource struct { ...@@ -38,7 +40,7 @@ type Resource struct {
type FindResource struct { type FindResource struct {
GetBlob bool GetBlob bool
ID *int32 ID *int32
ResourceName *string UID *string
CreatorID *int32 CreatorID *int32
Filename *string Filename *string
MemoID *int32 MemoID *int32
...@@ -49,7 +51,7 @@ type FindResource struct { ...@@ -49,7 +51,7 @@ type FindResource struct {
type UpdateResource struct { type UpdateResource struct {
ID int32 ID int32
ResourceName *string UID *string
UpdatedTs *int64 UpdatedTs *int64
Filename *string Filename *string
InternalPath *string InternalPath *string
...@@ -64,8 +66,8 @@ type DeleteResource struct { ...@@ -64,8 +66,8 @@ type DeleteResource struct {
} }
func (s *Store) CreateResource(ctx context.Context, create *Resource) (*Resource, error) { func (s *Store) CreateResource(ctx context.Context, create *Resource) (*Resource, error) {
if !util.ResourceNameMatcher.MatchString(create.ResourceName) { if !util.UIDMatcher.MatchString(create.UID) {
return nil, errors.New("invalid resource name") return nil, errors.New("invalid uid")
} }
return s.driver.CreateResource(ctx, create) return s.driver.CreateResource(ctx, create)
} }
...@@ -88,8 +90,8 @@ func (s *Store) GetResource(ctx context.Context, find *FindResource) (*Resource, ...@@ -88,8 +90,8 @@ func (s *Store) GetResource(ctx context.Context, find *FindResource) (*Resource,
} }
func (s *Store) UpdateResource(ctx context.Context, update *UpdateResource) (*Resource, error) { func (s *Store) UpdateResource(ctx context.Context, update *UpdateResource) (*Resource, error) {
if update.ResourceName != nil && !util.ResourceNameMatcher.MatchString(*update.ResourceName) { if update.UID != nil && !util.UIDMatcher.MatchString(*update.UID) {
return nil, errors.New("invalid resource name") return nil, errors.New("invalid uid")
} }
return s.driver.UpdateResource(ctx, update) return s.driver.UpdateResource(ctx, update)
} }
......
...@@ -15,10 +15,10 @@ func TestMemoOrganizerStore(t *testing.T) { ...@@ -15,10 +15,10 @@ func TestMemoOrganizerStore(t *testing.T) {
user, err := createTestingHostUser(ctx, ts) user, err := createTestingHostUser(ctx, ts)
require.NoError(t, err) require.NoError(t, err)
memoCreate := &store.Memo{ memoCreate := &store.Memo{
ResourceName: "main-memo", UID: "main-memo",
CreatorID: user.ID, CreatorID: user.ID,
Content: "main memo content", Content: "main memo content",
Visibility: store.Public, Visibility: store.Public,
} }
memo, err := ts.CreateMemo(ctx, memoCreate) memo, err := ts.CreateMemo(ctx, memoCreate)
require.NoError(t, err) require.NoError(t, err)
......
...@@ -15,28 +15,28 @@ func TestMemoRelationStore(t *testing.T) { ...@@ -15,28 +15,28 @@ func TestMemoRelationStore(t *testing.T) {
user, err := createTestingHostUser(ctx, ts) user, err := createTestingHostUser(ctx, ts)
require.NoError(t, err) require.NoError(t, err)
memoCreate := &store.Memo{ memoCreate := &store.Memo{
ResourceName: "main-memo", UID: "main-memo",
CreatorID: user.ID, CreatorID: user.ID,
Content: "main memo content", Content: "main memo content",
Visibility: store.Public, Visibility: store.Public,
} }
memo, err := ts.CreateMemo(ctx, memoCreate) memo, err := ts.CreateMemo(ctx, memoCreate)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, memoCreate.Content, memo.Content) require.Equal(t, memoCreate.Content, memo.Content)
relatedMemoCreate := &store.Memo{ relatedMemoCreate := &store.Memo{
ResourceName: "related-memo", UID: "related-memo",
CreatorID: user.ID, CreatorID: user.ID,
Content: "related memo content", Content: "related memo content",
Visibility: store.Public, Visibility: store.Public,
} }
relatedMemo, err := ts.CreateMemo(ctx, relatedMemoCreate) relatedMemo, err := ts.CreateMemo(ctx, relatedMemoCreate)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, relatedMemoCreate.Content, relatedMemo.Content) require.Equal(t, relatedMemoCreate.Content, relatedMemo.Content)
commentMemoCreate := &store.Memo{ commentMemoCreate := &store.Memo{
ResourceName: "comment-memo", UID: "comment-memo",
CreatorID: user.ID, CreatorID: user.ID,
Content: "comment memo content", Content: "comment memo content",
Visibility: store.Public, Visibility: store.Public,
} }
commentMemo, err := ts.CreateMemo(ctx, commentMemoCreate) commentMemo, err := ts.CreateMemo(ctx, commentMemoCreate)
require.NoError(t, err) require.NoError(t, err)
......
...@@ -15,10 +15,10 @@ func TestMemoStore(t *testing.T) { ...@@ -15,10 +15,10 @@ func TestMemoStore(t *testing.T) {
user, err := createTestingHostUser(ctx, ts) user, err := createTestingHostUser(ctx, ts)
require.NoError(t, err) require.NoError(t, err)
memoCreate := &store.Memo{ memoCreate := &store.Memo{
ResourceName: "test-resource-name", UID: "test-resource-name",
CreatorID: user.ID, CreatorID: user.ID,
Content: "test_content", Content: "test_content",
Visibility: store.Public, Visibility: store.Public,
} }
memo, err := ts.CreateMemo(ctx, memoCreate) memo, err := ts.CreateMemo(ctx, memoCreate)
require.NoError(t, err) require.NoError(t, err)
...@@ -68,10 +68,10 @@ func TestDeleteMemoStore(t *testing.T) { ...@@ -68,10 +68,10 @@ func TestDeleteMemoStore(t *testing.T) {
user, err := createTestingHostUser(ctx, ts) user, err := createTestingHostUser(ctx, ts)
require.NoError(t, err) require.NoError(t, err)
memoCreate := &store.Memo{ memoCreate := &store.Memo{
ResourceName: "test-resource-name", UID: "test-resource-name",
CreatorID: user.ID, CreatorID: user.ID,
Content: "test_content", Content: "test_content",
Visibility: store.Public, Visibility: store.Public,
} }
memo, err := ts.CreateMemo(ctx, memoCreate) memo, err := ts.CreateMemo(ctx, memoCreate)
require.NoError(t, err) require.NoError(t, err)
......
...@@ -14,7 +14,7 @@ func TestResourceStore(t *testing.T) { ...@@ -14,7 +14,7 @@ func TestResourceStore(t *testing.T) {
ctx := context.Background() ctx := context.Background()
ts := NewTestingStore(ctx, t) ts := NewTestingStore(ctx, t)
_, err := ts.CreateResource(ctx, &store.Resource{ _, err := ts.CreateResource(ctx, &store.Resource{
ResourceName: shortuuid.New(), UID: shortuuid.New(),
CreatorID: 101, CreatorID: 101,
Filename: "test.epub", Filename: "test.epub",
Blob: []byte("test"), Blob: []byte("test"),
......
...@@ -17,11 +17,11 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => { ...@@ -17,11 +17,11 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
const context = useContext(RendererContext); const context = useContext(RendererContext);
const loadingState = useLoading(); const loadingState = useLoading();
const memoStore = useMemoStore(); const memoStore = useMemoStore();
const memo = memoStore.getMemoByResourceId(resourceId); const memo = memoStore.getMemoByUid(resourceId);
const resourceName = `memos/${resourceId}`; const resourceName = `memos/${resourceId}`;
useEffect(() => { useEffect(() => {
memoStore.searchMemos(`resource_name == "${resourceId}"`).finally(() => loadingState.setFinish()); memoStore.searchMemos(`uid == "${resourceId}"`).finally(() => loadingState.setFinish());
}, [resourceId]); }, [resourceId]);
if (loadingState.isLoading) { if (loadingState.isLoading) {
......
...@@ -13,11 +13,11 @@ const ReferencedMemo = ({ resourceId, params: paramsStr }: Props) => { ...@@ -13,11 +13,11 @@ const ReferencedMemo = ({ resourceId, params: paramsStr }: Props) => {
const navigateTo = useNavigateTo(); const navigateTo = useNavigateTo();
const loadingState = useLoading(); const loadingState = useLoading();
const memoStore = useMemoStore(); const memoStore = useMemoStore();
const memo = memoStore.getMemoByResourceId(resourceId); const memo = memoStore.getMemoByUid(resourceId);
const params = new URLSearchParams(paramsStr); const params = new URLSearchParams(paramsStr);
useEffect(() => { useEffect(() => {
memoStore.searchMemos(`resource_name == "${resourceId}"`).finally(() => loadingState.setFinish()); memoStore.searchMemos(`uid == "${resourceId}"`).finally(() => loadingState.setFinish());
}, [resourceId]); }, [resourceId]);
if (loadingState.isLoading) { if (loadingState.isLoading) {
......
...@@ -58,7 +58,7 @@ const MemoView: React.FC<Props> = (props: Props) => { ...@@ -58,7 +58,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
if (event.altKey) { if (event.altKey) {
showChangeMemoCreatedTsDialog(extractMemoIdFromName(memo.name)); showChangeMemoCreatedTsDialog(extractMemoIdFromName(memo.name));
} else { } else {
navigateTo(`/m/${memo.resourceId}`); navigateTo(`/m/${memo.uid}`);
} }
}; };
...@@ -119,7 +119,7 @@ const MemoView: React.FC<Props> = (props: Props) => { ...@@ -119,7 +119,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
"flex flex-row justify-start items-center hover:opacity-70", "flex flex-row justify-start items-center hover:opacity-70",
commentAmount === 0 && "invisible group-hover:visible", commentAmount === 0 && "invisible group-hover:visible",
)} )}
to={`/m/${memo.resourceId}#comments`} to={`/m/${memo.uid}#comments`}
unstable_viewTransition unstable_viewTransition
> >
<Icon.MessageCircleMore className="w-4 h-4 mx-auto text-gray-500 dark:text-gray-400" /> <Icon.MessageCircleMore className="w-4 h-4 mx-auto text-gray-500 dark:text-gray-400" />
......
...@@ -19,8 +19,8 @@ const MemoDetail = () => { ...@@ -19,8 +19,8 @@ const MemoDetail = () => {
const navigateTo = useNavigateTo(); const navigateTo = useNavigateTo();
const currentUser = useCurrentUser(); const currentUser = useCurrentUser();
const memoStore = useMemoStore(); const memoStore = useMemoStore();
const resourceId = params.resourceId; const uid = params.uid;
const memo = memoStore.getMemoByResourceId(resourceId || ""); const memo = memoStore.getMemoByUid(uid || "");
const [parentMemo, setParentMemo] = useState<Memo | undefined>(undefined); const [parentMemo, setParentMemo] = useState<Memo | undefined>(undefined);
const commentRelations = const commentRelations =
memo?.relations.filter((relation) => relation.relatedMemo === memo.name && relation.type === MemoRelation_Type.COMMENT) || []; memo?.relations.filter((relation) => relation.relatedMemo === memo.name && relation.type === MemoRelation_Type.COMMENT) || [];
...@@ -28,15 +28,15 @@ const MemoDetail = () => { ...@@ -28,15 +28,15 @@ const MemoDetail = () => {
// Prepare memo. // Prepare memo.
useEffect(() => { useEffect(() => {
if (resourceId) { if (uid) {
memoStore.searchMemos(`resource_name == "${resourceId}"`).catch((error: ClientError) => { memoStore.searchMemos(`uid == "${uid}"`).catch((error: ClientError) => {
toast.error(error.details); toast.error(error.details);
navigateTo("/403"); navigateTo("/403");
}); });
} else { } else {
navigateTo("/404"); navigateTo("/404");
} }
}, [resourceId]); }, [uid]);
// Prepare memo comments. // Prepare memo comments.
useEffect(() => { useEffect(() => {
......
...@@ -132,7 +132,7 @@ const Resources = () => { ...@@ -132,7 +132,7 @@ const Resources = () => {
{relatedMemo && ( {relatedMemo && (
<Link <Link
className="shrink-0 text-xs ml-1 text-gray-400 hover:underline hover:text-blue-600" className="shrink-0 text-xs ml-1 text-gray-400 hover:underline hover:text-blue-600"
to={`/m/${relatedMemo.resourceId}`} to={`/m/${relatedMemo.uid}`}
> >
#{extractMemoIdFromName(relatedMemo.name)} #{extractMemoIdFromName(relatedMemo.name)}
</Link> </Link>
......
...@@ -88,7 +88,7 @@ const router = createBrowserRouter([ ...@@ -88,7 +88,7 @@ const router = createBrowserRouter([
element: <Explore />, element: <Explore />,
}, },
{ {
path: "m/:resourceId", path: "m/:uid",
element: <MemoDetail />, element: <MemoDetail />,
}, },
{ {
......
...@@ -58,9 +58,9 @@ export const useMemoStore = create( ...@@ -58,9 +58,9 @@ export const useMemoStore = create(
set({ memoMapByName: memoMap }); set({ memoMapByName: memoMap });
return memos; return memos;
}, },
getMemoByResourceId: (resourceId: string) => { getMemoByUid: (uid: string) => {
const memoMap = get().memoMapByName; const memoMap = get().memoMapByName;
return Object.values(memoMap).find((memo) => memo.resourceId === resourceId); return Object.values(memoMap).find((memo) => memo.uid === uid);
}, },
createMemo: async (request: CreateMemoRequest) => { createMemo: async (request: CreateMemoRequest) => {
const { memo } = await memoServiceClient.createMemo(request); const { memo } = await memoServiceClient.createMemo(request);
......
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