mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
refactor: update resource id naming
This commit is contained in:
@@ -269,7 +269,7 @@ func (s *APIV1Service) SignUp(c echo.Context) error {
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@@ -827,7 +827,7 @@ func (s *APIV1Service) UpdateMemo(c echo.Context) error {
|
||||
func (s *APIV1Service) convertMemoFromStore(ctx context.Context, memo *store.Memo) (*Memo, error) {
|
||||
memoMessage := &Memo{
|
||||
ID: memo.ID,
|
||||
Name: memo.ResourceName,
|
||||
Name: memo.UID,
|
||||
RowStatus: RowStatus(memo.RowStatus.String()),
|
||||
CreatorID: memo.CreatorID,
|
||||
CreatedTs: memo.CreatedTs,
|
||||
@@ -921,11 +921,11 @@ func convertCreateMemoRequestToMemoMessage(memoCreate *CreateMemoRequest) *store
|
||||
createdTs = *memoCreate.CreatedTs
|
||||
}
|
||||
return &store.Memo{
|
||||
ResourceName: shortuuid.New(),
|
||||
CreatorID: memoCreate.CreatorID,
|
||||
CreatedTs: createdTs,
|
||||
Content: memoCreate.Content,
|
||||
Visibility: store.Visibility(memoCreate.Visibility),
|
||||
UID: shortuuid.New(),
|
||||
CreatorID: memoCreate.CreatorID,
|
||||
CreatedTs: createdTs,
|
||||
Content: memoCreate.Content,
|
||||
Visibility: store.Visibility(memoCreate.Visibility),
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -138,7 +138,7 @@ func (s *APIV1Service) CreateResource(c echo.Context) error {
|
||||
}
|
||||
|
||||
create := &store.Resource{
|
||||
ResourceName: shortuuid.New(),
|
||||
UID: shortuuid.New(),
|
||||
CreatorID: userID,
|
||||
Filename: request.Filename,
|
||||
ExternalLink: request.ExternalLink,
|
||||
@@ -220,11 +220,11 @@ func (s *APIV1Service) UploadResource(c echo.Context) error {
|
||||
defer sourceFile.Close()
|
||||
|
||||
create := &store.Resource{
|
||||
ResourceName: shortuuid.New(),
|
||||
CreatorID: userID,
|
||||
Filename: file.Filename,
|
||||
Type: file.Header.Get("Content-Type"),
|
||||
Size: file.Size,
|
||||
UID: shortuuid.New(),
|
||||
CreatorID: userID,
|
||||
Filename: file.Filename,
|
||||
Type: file.Header.Get("Content-Type"),
|
||||
Size: file.Size,
|
||||
}
|
||||
err = SaveResourceBlob(ctx, s.Store, create, sourceFile)
|
||||
if err != nil {
|
||||
@@ -371,7 +371,7 @@ func replacePathTemplate(path, filename string) string {
|
||||
func convertResourceFromStore(resource *store.Resource) *Resource {
|
||||
return &Resource{
|
||||
ID: resource.ID,
|
||||
Name: resource.ResourceName,
|
||||
Name: resource.UID,
|
||||
CreatorID: resource.CreatorID,
|
||||
CreatedTs: resource.CreatedTs,
|
||||
UpdatedTs: resource.UpdatedTs,
|
||||
|
@@ -157,7 +157,7 @@ func (s *APIV1Service) CreateUser(c echo.Context) error {
|
||||
if err := userCreate.Validate(); err != nil {
|
||||
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)
|
||||
}
|
||||
// Disallow host user to be created.
|
||||
@@ -377,7 +377,7 @@ func (s *APIV1Service) UpdateUser(c echo.Context) error {
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
userUpdate.Username = request.Username
|
||||
|
@@ -152,7 +152,7 @@ GetMemo gets a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name_1 | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name_1 | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -252,7 +252,7 @@ GetUserMemosStats gets stats of memos for a user.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | query | name is the name of the user to get stats for. Format: users/{uid} | No | string |
|
||||
| name | query | name is the name of the user to get stats for. Format: users/{id} | No | string |
|
||||
| timezone | query | timezone location Format: uses tz identifier https://en.wikipedia.org/wiki/List_of_tz_database_time_zones | No | string |
|
||||
| filter | query | Same as ListMemosRequest.filter | No | string |
|
||||
|
||||
@@ -314,8 +314,8 @@ UpdateMemo updates a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| memo.name | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| memo | body | | Yes | { **"resourceId"**: string, **"rowStatus"**: [apiv2RowStatus](#apiv2rowstatus), **"creator"**: string, **"createTime"**: dateTime, **"updateTime"**: dateTime, **"displayTime"**: dateTime, **"content"**: string, **"visibility"**: [v2Visibility](#v2visibility), **"pinned"**: boolean, **"parentId"**: integer, **"resources"**: [ [v2Resource](#v2resource) ], **"relations"**: [ [v2MemoRelation](#v2memorelation) ], **"reactions"**: [ [apiv2Reaction](#apiv2reaction) ] } |
|
||||
| memo.name | path | The name of the memo. Format: memos/{id} id is the system generated id. | Yes | string |
|
||||
| memo | body | | Yes | { **"uid"**: string, **"rowStatus"**: [apiv2RowStatus](#apiv2rowstatus), **"creator"**: string, **"createTime"**: dateTime, **"updateTime"**: dateTime, **"displayTime"**: dateTime, **"content"**: string, **"visibility"**: [v2Visibility](#v2visibility), **"pinned"**: boolean, **"parentId"**: integer, **"resources"**: [ [v2Resource](#v2resource) ], **"relations"**: [ [v2MemoRelation](#v2memorelation) ], **"reactions"**: [ [apiv2Reaction](#apiv2reaction) ] } |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -335,7 +335,7 @@ GetMemo gets a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name_1 | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name_1 | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -373,7 +373,7 @@ DeleteMemo deletes a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name_2 | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name_2 | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -393,7 +393,7 @@ ListMemoComments lists comments for a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -411,7 +411,7 @@ CreateMemoComment creates a comment for a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
| comment.content | query | | No | string |
|
||||
| comment.visibility | query | | No | string |
|
||||
|
||||
@@ -433,7 +433,7 @@ ListMemoReactions lists reactions for a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -451,9 +451,9 @@ UpsertMemoReaction upserts a reaction for a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
| reaction.id | query | | No | integer |
|
||||
| reaction.creator | query | The name of the creator. Format: users/{uid} | No | string |
|
||||
| reaction.creator | query | The name of the creator. Format: users/{id} | No | string |
|
||||
| reaction.contentId | query | | No | string |
|
||||
| reaction.reactionType | query | | No | string |
|
||||
|
||||
@@ -475,7 +475,7 @@ DeleteMemoReaction deletes a reaction for a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
| reactionId | path | | Yes | integer |
|
||||
|
||||
##### Responses
|
||||
@@ -496,7 +496,7 @@ ListMemoRelations lists relations for a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -514,7 +514,7 @@ SetMemoRelations sets relations for a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
| body | body | | Yes | [MemoServiceSetMemoRelationsBody](#memoservicesetmemorelationsbody) |
|
||||
|
||||
##### Responses
|
||||
@@ -535,7 +535,7 @@ ListMemoResources lists resources for a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -553,7 +553,7 @@ SetMemoResources sets resources for a memo.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the memo. Format: memos/{uid} | Yes | string |
|
||||
| name | path | The name of the memo. Format: memos/{id} | Yes | string |
|
||||
| body | body | | Yes | [MemoServiceSetMemoResourcesBody](#memoservicesetmemoresourcesbody) |
|
||||
|
||||
##### Responses
|
||||
@@ -694,7 +694,7 @@ ListTags lists tags.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| user | query | The creator of tags. Format: users/{uid} | No | string |
|
||||
| user | query | The creator of tags. Format: users/{id} | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -713,7 +713,7 @@ DeleteTag deletes a tag.
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| tag.name | query | | No | string |
|
||||
| tag.creator | query | The creator of tags. Format: users/{uid} | No | string |
|
||||
| tag.creator | query | The creator of tags. Format: users/{id} | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -751,7 +751,7 @@ GetTagSuggestions gets tag suggestions from the user's memos.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| user | query | The creator of tags. Format: users/{uid} | No | string |
|
||||
| user | query | The creator of tags. Format: users/{id} | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -786,7 +786,7 @@ All related memos will be updated.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| user | query | The creator of tags. Format: users/{uid} | No | string |
|
||||
| user | query | The creator of tags. Format: users/{id} | No | string |
|
||||
| oldName | query | | No | string |
|
||||
| newName | query | | No | string |
|
||||
|
||||
@@ -863,7 +863,7 @@ GetUser gets a user by name.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the user. Format: users/{uid} | Yes | string |
|
||||
| name | path | The name of the user. Format: users/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -881,7 +881,7 @@ DeleteUser deletes a user.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the user. Format: users/{uid} | Yes | string |
|
||||
| name | path | The name of the user. Format: users/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -901,7 +901,7 @@ ListUserAccessTokens returns a list of access tokens for a user.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the user. Format: users/{uid} | Yes | string |
|
||||
| name | path | The name of the user. Format: users/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -919,7 +919,7 @@ CreateUserAccessToken creates a new access token for a user.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the user. Format: users/{uid} | Yes | string |
|
||||
| name | path | The name of the user. Format: users/{id} | Yes | string |
|
||||
| body | body | | Yes | [UserServiceCreateUserAccessTokenBody](#userservicecreateuseraccesstokenbody) |
|
||||
|
||||
##### Responses
|
||||
@@ -940,7 +940,7 @@ DeleteUserAccessToken deletes an access token for a user.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the user. Format: users/{uid} | Yes | string |
|
||||
| name | path | The name of the user. Format: users/{id} | Yes | string |
|
||||
| accessToken | path | access_token is the access token to delete. | Yes | string |
|
||||
|
||||
##### Responses
|
||||
@@ -961,7 +961,7 @@ GetUserSetting gets the setting of a user.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| name | path | The name of the user. Format: users/{uid} | Yes | string |
|
||||
| name | path | The name of the user. Format: users/{id} | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
@@ -981,7 +981,7 @@ UpdateUserSetting updates the setting of a user.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| setting.name | path | The name of the user. Format: users/{uid} | Yes | string |
|
||||
| setting.name | path | The name of the user. Format: users/{id} | Yes | string |
|
||||
| setting | body | | Yes | { **"locale"**: string, **"appearance"**: string, **"memoVisibility"**: string, **"telegramUserId"**: string } |
|
||||
|
||||
##### Responses
|
||||
@@ -1002,7 +1002,7 @@ UpdateUser updates a user.
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ------ |
|
||||
| user.name | path | The name of the user. Format: users/{uid} | Yes | string |
|
||||
| user.name | path | The name of the user. Format: users/{id} | Yes | string |
|
||||
| user | body | | Yes | { **"id"**: integer, **"role"**: [UserRole](#userrole), **"username"**: string, **"email"**: string, **"nickname"**: string, **"avatarUrl"**: string, **"description"**: string, **"password"**: string, **"rowStatus"**: [apiv2RowStatus](#apiv2rowstatus), **"createTime"**: dateTime, **"updateTime"**: dateTime } |
|
||||
|
||||
##### Responses
|
||||
@@ -1620,8 +1620,8 @@ GetActivity returns the activity with the given id.
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| name | string | | No |
|
||||
| resourceId | string | | No |
|
||||
| name | string | The name of the memo. Format: memos/{id} id is the system generated id. | No |
|
||||
| uid | string | The user defined id of the memo. | No |
|
||||
| rowStatus | [apiv2RowStatus](#apiv2rowstatus) | | No |
|
||||
| creator | string | | No |
|
||||
| createTime | dateTime | | No |
|
||||
|
@@ -243,7 +243,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
name is the name of the user to get stats for.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
@@ -477,7 +477,7 @@ paths:
|
||||
- name: user
|
||||
description: |-
|
||||
The creator of tags.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
@@ -503,7 +503,7 @@ paths:
|
||||
- name: tag.creator
|
||||
description: |-
|
||||
The creator of tags.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
@@ -545,7 +545,7 @@ paths:
|
||||
- name: user
|
||||
description: |-
|
||||
The creator of tags.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
@@ -585,7 +585,7 @@ paths:
|
||||
- name: user
|
||||
description: |-
|
||||
The creator of tags.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
@@ -915,7 +915,8 @@ paths:
|
||||
- name: memo.name
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
id is the system generated id.
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -926,15 +927,16 @@ paths:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
resourceId:
|
||||
uid:
|
||||
type: string
|
||||
description: The user defined id of the memo.
|
||||
rowStatus:
|
||||
$ref: '#/definitions/apiv2RowStatus'
|
||||
creator:
|
||||
type: string
|
||||
title: |-
|
||||
The name of the creator.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
createTime:
|
||||
type: string
|
||||
format: date-time
|
||||
@@ -991,7 +993,7 @@ paths:
|
||||
- name: name_1
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1038,7 +1040,7 @@ paths:
|
||||
- name: name_2
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1062,7 +1064,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the user.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1085,7 +1087,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the user.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1109,7 +1111,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the user.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1132,7 +1134,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the user.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1161,7 +1163,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the user.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1190,7 +1192,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1213,7 +1215,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1251,7 +1253,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1274,7 +1276,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1287,7 +1289,7 @@ paths:
|
||||
- name: reaction.creator
|
||||
description: |-
|
||||
The name of the creator.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: query
|
||||
required: false
|
||||
type: string
|
||||
@@ -1333,7 +1335,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1362,7 +1364,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1385,7 +1387,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1414,7 +1416,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1437,7 +1439,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
Format: memos/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1466,7 +1468,7 @@ paths:
|
||||
- name: name
|
||||
description: |-
|
||||
The name of the user.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1490,7 +1492,7 @@ paths:
|
||||
- name: setting.name
|
||||
description: |-
|
||||
The name of the user.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1532,7 +1534,7 @@ paths:
|
||||
- name: user.name
|
||||
description: |-
|
||||
The name of the user.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
@@ -1656,7 +1658,7 @@ definitions:
|
||||
type: string
|
||||
title: |-
|
||||
The name of the creator.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
contentId:
|
||||
type: string
|
||||
reactionType:
|
||||
@@ -1692,7 +1694,7 @@ definitions:
|
||||
type: string
|
||||
title: |-
|
||||
The name of the user.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
locale:
|
||||
type: string
|
||||
description: The preferred locale of the user.
|
||||
@@ -2078,18 +2080,20 @@ definitions:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
title: |-
|
||||
description: |-
|
||||
The name of the memo.
|
||||
Format: memos/{uid}
|
||||
resourceId:
|
||||
Format: memos/{id}
|
||||
id is the system generated id.
|
||||
uid:
|
||||
type: string
|
||||
description: The user defined id of the memo.
|
||||
rowStatus:
|
||||
$ref: '#/definitions/apiv2RowStatus'
|
||||
creator:
|
||||
type: string
|
||||
title: |-
|
||||
The name of the creator.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
createTime:
|
||||
type: string
|
||||
format: date-time
|
||||
@@ -2230,7 +2234,7 @@ definitions:
|
||||
type: string
|
||||
title: |-
|
||||
The creator of tags.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
v2UpdateInboxResponse:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2283,7 +2287,7 @@ definitions:
|
||||
type: string
|
||||
title: |-
|
||||
The name of the user.
|
||||
Format: users/{uid}
|
||||
Format: users/{id}
|
||||
id:
|
||||
type: integer
|
||||
format: int32
|
||||
|
@@ -189,7 +189,7 @@ func (s *APIV2Service) SignUp(ctx context.Context, request *apiv2pb.SignUpReques
|
||||
Nickname: request.Username,
|
||||
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)
|
||||
}
|
||||
|
||||
|
@@ -44,10 +44,10 @@ func (s *APIV2Service) CreateMemo(ctx context.Context, request *apiv2pb.CreateMe
|
||||
}
|
||||
|
||||
create := &store.Memo{
|
||||
ResourceName: shortuuid.New(),
|
||||
CreatorID: user.ID,
|
||||
Content: request.Content,
|
||||
Visibility: convertVisibilityToStore(request.Visibility),
|
||||
UID: shortuuid.New(),
|
||||
CreatorID: user.ID,
|
||||
Content: request.Content,
|
||||
Visibility: convertVisibilityToStore(request.Visibility),
|
||||
}
|
||||
// Find disable public memos system setting.
|
||||
disablePublicMemosSystem, err := s.getDisablePublicMemosSystemSettingValue(ctx)
|
||||
@@ -231,9 +231,9 @@ func (s *APIV2Service) UpdateMemo(ctx context.Context, request *apiv2pb.UpdateMe
|
||||
for _, path := range request.UpdateMask.Paths {
|
||||
if path == "content" {
|
||||
update.Content = &request.Memo.Content
|
||||
} else if path == "resource_name" {
|
||||
update.ResourceName = &request.Memo.Name
|
||||
if !util.ResourceNameMatcher.MatchString(*update.ResourceName) {
|
||||
} else if path == "uid" {
|
||||
update.UID = &request.Memo.Name
|
||||
if !util.UIDMatcher.MatchString(*update.UID) {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid resource name")
|
||||
}
|
||||
} else if path == "visibility" {
|
||||
@@ -555,7 +555,7 @@ func (s *APIV2Service) convertMemoFromStore(ctx context.Context, memo *store.Mem
|
||||
|
||||
return &apiv2pb.Memo{
|
||||
Name: name,
|
||||
ResourceId: memo.ResourceName,
|
||||
Uid: memo.UID,
|
||||
RowStatus: convertRowStatusFromStore(memo.RowStatus),
|
||||
Creator: fmt.Sprintf("%s%d", UserNamePrefix, creator.ID),
|
||||
CreateTime: timestamppb.New(time.Unix(memo.CreatedTs, 0)),
|
||||
@@ -690,8 +690,8 @@ func (s *APIV2Service) buildMemoFindWithFilter(ctx context.Context, find *store.
|
||||
}
|
||||
find.CreatorID = &user.ID
|
||||
}
|
||||
if filter.ResourceName != nil {
|
||||
find.ResourceName = filter.ResourceName
|
||||
if filter.UID != nil {
|
||||
find.UID = filter.UID
|
||||
}
|
||||
if filter.RowStatus != nil {
|
||||
find.RowStatus = filter.RowStatus
|
||||
@@ -728,7 +728,7 @@ var SearchMemosFilterCELAttributes = []cel.EnvOption{
|
||||
cel.Variable("display_time_before", cel.IntType),
|
||||
cel.Variable("display_time_after", cel.IntType),
|
||||
cel.Variable("creator", cel.StringType),
|
||||
cel.Variable("resource_name", cel.StringType),
|
||||
cel.Variable("uid", cel.StringType),
|
||||
cel.Variable("row_status", cel.StringType),
|
||||
}
|
||||
|
||||
@@ -739,7 +739,7 @@ type SearchMemosFilter struct {
|
||||
DisplayTimeBefore *int64
|
||||
DisplayTimeAfter *int64
|
||||
Creator *string
|
||||
ResourceName *string
|
||||
UID *string
|
||||
RowStatus *store.RowStatus
|
||||
}
|
||||
|
||||
@@ -792,9 +792,9 @@ func findSearchMemosField(callExpr *expr.Expr_Call, filter *SearchMemosFilter) {
|
||||
} else if idExpr.Name == "creator" {
|
||||
creator := callExpr.Args[1].GetConstExpr().GetStringValue()
|
||||
filter.Creator = &creator
|
||||
} else if idExpr.Name == "resource_name" {
|
||||
resourceName := callExpr.Args[1].GetConstExpr().GetStringValue()
|
||||
filter.ResourceName = &resourceName
|
||||
} else if idExpr.Name == "uid" {
|
||||
uid := callExpr.Args[1].GetConstExpr().GetStringValue()
|
||||
filter.UID = &uid
|
||||
} else if idExpr.Name == "row_status" {
|
||||
rowStatus := store.RowStatus(callExpr.Args[1].GetConstExpr().GetStringValue())
|
||||
filter.RowStatus = &rowStatus
|
||||
|
@@ -31,7 +31,7 @@ func (s *APIV2Service) CreateResource(ctx context.Context, request *apiv2pb.Crea
|
||||
}
|
||||
|
||||
create := &store.Resource{
|
||||
ResourceName: shortuuid.New(),
|
||||
UID: shortuuid.New(),
|
||||
CreatorID: user.ID,
|
||||
Filename: request.Filename,
|
||||
ExternalLink: request.ExternalLink,
|
||||
@@ -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) {
|
||||
resource, err := s.Store.GetResource(ctx, &store.FindResource{
|
||||
ResourceName: &request.Name,
|
||||
UID: &request.Name,
|
||||
})
|
||||
if err != nil {
|
||||
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
|
||||
|
||||
return &apiv2pb.Resource{
|
||||
Id: resource.ID,
|
||||
Name: resource.ResourceName,
|
||||
Name: resource.UID,
|
||||
CreateTime: timestamppb.New(time.Unix(resource.CreatedTs, 0)),
|
||||
Filename: resource.Filename,
|
||||
ExternalLink: resource.ExternalLink,
|
||||
|
@@ -105,7 +105,7 @@ func (s *APIV2Service) CreateUser(ctx context.Context, request *apiv2pb.CreateUs
|
||||
if currentUser.Role != store.RoleHost {
|
||||
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)
|
||||
}
|
||||
passwordHash, err := bcrypt.GenerateFromPassword([]byte(request.User.Password), bcrypt.DefaultCost)
|
||||
@@ -161,7 +161,7 @@ func (s *APIV2Service) UpdateUser(ctx context.Context, request *apiv2pb.UpdateUs
|
||||
}
|
||||
for _, field := range request.UpdateMask.Paths {
|
||||
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)
|
||||
}
|
||||
update.Username = &request.User.Username
|
||||
|
Reference in New Issue
Block a user