chore: remove unused user id

pull/4290/head
Steven 2 months ago
parent 3081015692
commit 8b7e9f5443

@ -34,9 +34,9 @@ message Inbox {
// The name of the inbox.
// Format: inboxes/{id}
string name = 1;
// Format: users/{id}
// Format: users/{user}
string sender = 2;
// Format: users/{id}
// Format: users/{user}
string receiver = 3;
enum Status {
@ -59,7 +59,7 @@ message Inbox {
}
message ListInboxesRequest {
// Format: users/{id}
// Format: users/{user}
string user = 1;
// The maximum number of inbox to return.

@ -140,7 +140,7 @@ message Memo {
State state = 3;
// The name of the creator.
// Format: users/{id}
// Format: users/{user}
string creator = 4;
google.protobuf.Timestamp create_time = 5;
@ -222,7 +222,7 @@ message ListMemosRequest {
string page_token = 2;
// Filter is used to filter memos returned in the list.
// Format: "creator == 'users/{uid}' && visibilities == ['PUBLIC', 'PROTECTED']"
// Format: "creator == 'users/{user}' && visibilities == ['PUBLIC', 'PROTECTED']"
string filter = 3;
// The view of the memo.

@ -8,7 +8,7 @@ message Reaction {
int32 id = 1;
// The name of the creator.
// Format: users/{id}
// Format: users/{user}
string creator = 2;
string content_id = 3;

@ -88,12 +88,9 @@ service UserService {
message User {
// The name of the user.
// Format: users/{id}
// Format: users/{user}. {user} is a system-generated auto-increment id.
string name = 1;
// The system generated uid of the user.
int32 id = 2;
enum Role {
ROLE_UNSPECIFIED = 0;
HOST = 1;
@ -139,13 +136,13 @@ message SearchUsersResponse {
message GetUserRequest {
// The name of the user.
// Format: users/{id}
// Format: users/{user}
string name = 1;
}
message GetUserAvatarBinaryRequest {
// The name of the user.
// Format: users/{id}
// Format: users/{user}
string name = 1;
// The raw HTTP body is bound to this field.
@ -164,13 +161,13 @@ message UpdateUserRequest {
message DeleteUserRequest {
// The name of the user.
// Format: users/{id}
// Format: users/{user}
string name = 1;
}
message UserSetting {
// The name of the user.
// Format: users/{id}
// Format: users/{user}
string name = 1;
// The preferred locale of the user.
string locale = 2;
@ -182,7 +179,7 @@ message UserSetting {
message GetUserSettingRequest {
// The name of the user.
// Format: users/{id}
// Format: users/{user}
string name = 1;
}
@ -201,7 +198,7 @@ message UserAccessToken {
message ListUserAccessTokensRequest {
// The name of the user.
// Format: users/{id}
// Format: users/{user}
string name = 1;
}
@ -211,7 +208,7 @@ message ListUserAccessTokensResponse {
message CreateUserAccessTokenRequest {
// The name of the user.
// Format: users/{id}
// Format: users/{user}
string name = 1;
string description = 2;
@ -221,7 +218,7 @@ message CreateUserAccessTokenRequest {
message DeleteUserAccessTokenRequest {
// The name of the user.
// Format: users/{id}
// Format: users/{user}
string name = 1;
// access_token is the access token to delete.
string access_token = 2;

@ -15,7 +15,7 @@ service WorkspaceService {
message WorkspaceProfile {
// The name of instance owner.
// Format: "users/{id}"
// Format: users/{user}
string owner = 1;
// version is the current version of instance
string version = 2;

@ -127,9 +127,9 @@ type Inbox struct {
// The name of the inbox.
// Format: inboxes/{id}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// Format: users/{id}
// Format: users/{user}
Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"`
// Format: users/{id}
// Format: users/{user}
Receiver string `protobuf:"bytes,3,opt,name=receiver,proto3" json:"receiver,omitempty"`
Status Inbox_Status `protobuf:"varint,4,opt,name=status,proto3,enum=memos.api.v1.Inbox_Status" json:"status,omitempty"`
CreateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
@ -220,7 +220,7 @@ func (x *Inbox) GetActivityId() int32 {
type ListInboxesRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Format: users/{id}
// Format: users/{user}
User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
// The maximum number of inbox to return.
PageSize int32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`

@ -137,7 +137,7 @@ type Memo struct {
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty"`
State State `protobuf:"varint,3,opt,name=state,proto3,enum=memos.api.v1.State" json:"state,omitempty"`
// The name of the creator.
// Format: users/{id}
// Format: users/{user}
Creator string `protobuf:"bytes,4,opt,name=creator,proto3" json:"creator,omitempty"`
CreateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
UpdateTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty"`
@ -537,7 +537,7 @@ type ListMemosRequest struct {
// Provide this to retrieve the subsequent page.
PageToken string `protobuf:"bytes,2,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"`
// Filter is used to filter memos returned in the list.
// Format: "creator == 'users/{uid}' && visibilities == ['PUBLIC', 'PROTECTED']"
// Format: "creator == 'users/{user}' && visibilities == ['PUBLIC', 'PROTECTED']"
Filter string `protobuf:"bytes,3,opt,name=filter,proto3" json:"filter,omitempty"`
// The view of the memo.
View MemoView `protobuf:"varint,4,opt,name=view,proto3,enum=memos.api.v1.MemoView" json:"view,omitempty"`

@ -24,7 +24,7 @@ type Reaction struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
// The name of the creator.
// Format: users/{id}
// Format: users/{user}
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"`
ReactionType string `protobuf:"bytes,4,opt,name=reaction_type,json=reactionType,proto3" json:"reaction_type,omitempty"`

@ -80,10 +80,8 @@ func (User_Role) EnumDescriptor() ([]byte, []int) {
type User struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the user.
// Format: users/{id}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// The system generated uid of the user.
Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"`
// Format: users/{user}. {user} is a system-generated auto-increment id.
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Role User_Role `protobuf:"varint,3,opt,name=role,proto3,enum=memos.api.v1.User_Role" json:"role,omitempty"`
Username string `protobuf:"bytes,4,opt,name=username,proto3" json:"username,omitempty"`
Email string `protobuf:"bytes,5,opt,name=email,proto3" json:"email,omitempty"`
@ -135,13 +133,6 @@ func (x *User) GetName() string {
return ""
}
func (x *User) GetId() int32 {
if x != nil {
return x.Id
}
return 0
}
func (x *User) GetRole() User_Role {
if x != nil {
return x.Role
@ -385,7 +376,7 @@ func (x *SearchUsersResponse) GetUsers() []*User {
type GetUserRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the user.
// Format: users/{id}
// Format: users/{user}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@ -431,7 +422,7 @@ func (x *GetUserRequest) GetName() string {
type GetUserAvatarBinaryRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the user.
// Format: users/{id}
// Format: users/{user}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// The raw HTTP body is bound to this field.
HttpBody *httpbody.HttpBody `protobuf:"bytes,2,opt,name=http_body,json=httpBody,proto3" json:"http_body,omitempty"`
@ -582,7 +573,7 @@ func (x *UpdateUserRequest) GetUpdateMask() *fieldmaskpb.FieldMask {
type DeleteUserRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the user.
// Format: users/{id}
// Format: users/{user}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@ -628,7 +619,7 @@ func (x *DeleteUserRequest) GetName() string {
type UserSetting struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the user.
// Format: users/{id}
// Format: users/{user}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// The preferred locale of the user.
Locale string `protobuf:"bytes,2,opt,name=locale,proto3" json:"locale,omitempty"`
@ -701,7 +692,7 @@ func (x *UserSetting) GetMemoVisibility() string {
type GetUserSettingRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the user.
// Format: users/{id}
// Format: users/{user}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@ -867,7 +858,7 @@ func (x *UserAccessToken) GetExpiresAt() *timestamppb.Timestamp {
type ListUserAccessTokensRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the user.
// Format: users/{id}
// Format: users/{user}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@ -957,7 +948,7 @@ func (x *ListUserAccessTokensResponse) GetAccessTokens() []*UserAccessToken {
type CreateUserAccessTokenRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the user.
// Format: users/{id}
// Format: users/{user}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,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"`
@ -1019,7 +1010,7 @@ func (x *CreateUserAccessTokenRequest) GetExpiresAt() *timestamppb.Timestamp {
type DeleteUserAccessTokenRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the user.
// Format: users/{id}
// Format: users/{user}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// access_token is the access token to delete.
AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
@ -1091,9 +1082,8 @@ var file_api_v1_user_service_proto_rawDesc = []byte{
0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0xea, 0x03, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e,
0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2b,
0x6f, 0x22, 0xda, 0x03, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2b,
0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x6d,
0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72,
0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75,

@ -24,7 +24,7 @@ const (
type WorkspaceProfile struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of instance owner.
// Format: "users/{id}"
// Format: users/{user}
Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
// version is the current version of instance
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`

@ -190,7 +190,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: user
description: 'Format: users/{id}'
description: 'Format: users/{user}'
in: query
required: false
type: string
@ -320,7 +320,7 @@ paths:
- name: filter
description: |-
Filter is used to filter memos returned in the list.
Format: "creator == 'users/{uid}' && visibilities == ['PUBLIC', 'PROTECTED']"
Format: "creator == 'users/{user}' && visibilities == ['PUBLIC', 'PROTECTED']"
in: query
required: false
type: string
@ -787,10 +787,10 @@ paths:
properties:
sender:
type: string
title: 'Format: users/{id}'
title: 'Format: users/{user}'
receiver:
type: string
title: 'Format: users/{id}'
title: 'Format: users/{user}'
status:
$ref: '#/definitions/v1InboxStatus'
createTime:
@ -841,7 +841,7 @@ paths:
type: string
title: |-
The name of the creator.
Format: users/{id}
Format: users/{user}
createTime:
type: string
format: date-time
@ -919,7 +919,7 @@ paths:
- name: name_1
description: |-
The name of the user.
Format: users/{id}
Format: users/{user}
in: path
required: true
type: string
@ -1137,7 +1137,7 @@ paths:
- name: name
description: |-
The name of the user.
Format: users/{id}
Format: users/{user}
in: path
required: true
type: string
@ -1161,7 +1161,7 @@ paths:
- name: name
description: |-
The name of the user.
Format: users/{id}
Format: users/{user}
in: path
required: true
type: string
@ -1184,7 +1184,7 @@ paths:
- name: name
description: |-
The name of the user.
Format: users/{id}
Format: users/{user}
in: path
required: true
type: string
@ -1214,7 +1214,7 @@ paths:
- name: name
description: |-
The name of the user.
Format: users/{id}
Format: users/{user}
in: path
required: true
type: string
@ -1453,7 +1453,7 @@ paths:
- name: name
description: |-
The name of the user.
Format: users/{id}
Format: users/{user}
in: path
required: true
type: string
@ -1595,7 +1595,7 @@ paths:
- name: setting.name
description: |-
The name of the user.
Format: users/{id}
Format: users/{user}
in: path
required: true
type: string
@ -1636,7 +1636,7 @@ paths:
- name: user.name
description: |-
The name of the user.
Format: users/{id}
Format: users/{user}. {user} is a system-generated auto-increment id.
in: path
required: true
type: string
@ -1647,10 +1647,6 @@ paths:
schema:
type: object
properties:
id:
type: integer
format: int32
description: The system generated uid of the user.
role:
$ref: '#/definitions/UserRole'
username:
@ -1694,7 +1690,7 @@ paths:
- name: name
description: |-
The name of the user.
Format: users/{id}
Format: users/{user}
in: path
required: true
type: string
@ -1975,7 +1971,7 @@ definitions:
type: string
title: |-
The name of the creator.
Format: users/{id}
Format: users/{user}
createTime:
type: string
format: date-time
@ -2060,7 +2056,7 @@ definitions:
type: string
title: |-
The name of the user.
Format: users/{id}
Format: users/{user}
locale:
type: string
description: The preferred locale of the user.
@ -2486,10 +2482,10 @@ definitions:
Format: inboxes/{id}
sender:
type: string
title: 'Format: users/{id}'
title: 'Format: users/{user}'
receiver:
type: string
title: 'Format: users/{id}'
title: 'Format: users/{user}'
status:
$ref: '#/definitions/v1InboxStatus'
createTime:
@ -2869,7 +2865,7 @@ definitions:
type: string
title: |-
The name of the creator.
Format: users/{id}
Format: users/{user}
contentId:
type: string
reactionType:
@ -3035,13 +3031,9 @@ definitions:
properties:
name:
type: string
title: |-
description: |-
The name of the user.
Format: users/{id}
id:
type: integer
format: int32
description: The system generated uid of the user.
Format: users/{user}. {user} is a system-generated auto-increment id.
role:
$ref: '#/definitions/UserRole'
username:
@ -3111,7 +3103,7 @@ definitions:
type: string
title: |-
The name of instance owner.
Format: "users/{id}"
Format: users/{user}
version:
type: string
title: version is the current version of instance

@ -556,7 +556,6 @@ func (s *APIV1Service) UpsertAccessTokenToStore(ctx context.Context, user *store
func convertUserFromStore(user *store.User) *v1pb.User {
userpb := &v1pb.User{
Name: fmt.Sprintf("%s%d", UserNamePrefix, user.ID),
Id: user.ID,
State: convertStateFromStore(user.RowStatus),
CreateTime: timestamppb.New(time.Unix(user.CreatedTs, 0)),
UpdateTime: timestamppb.New(time.Unix(user.UpdatedTs, 0)),

@ -0,0 +1,13 @@
package store
type LogicOperator string
const (
AND LogicOperator = "AND"
OR LogicOperator = "OR"
)
type QueryExpression struct {
Operator LogicOperator
Children []*QueryExpression
}

@ -173,14 +173,11 @@ const MemberSection = () => {
<thead>
<tr className="text-sm font-semibold text-left text-gray-900 dark:text-gray-400">
<th scope="col" className="px-3 py-2">
ID
{t("common.username")}
</th>
<th scope="col" className="px-3 py-2">
{t("common.role")}
</th>
<th scope="col" className="px-3 py-2">
{t("common.username")}
</th>
<th scope="col" className="px-3 py-2">
{t("common.nickname")}
</th>
@ -192,17 +189,16 @@ const MemberSection = () => {
</thead>
<tbody className="divide-y divide-gray-200 dark:divide-zinc-600">
{sortedUsers.map((user) => (
<tr key={user.id}>
<td className="whitespace-nowrap px-3 py-2 text-sm text-gray-900 dark:text-gray-400">{user.id}</td>
<td className="whitespace-nowrap px-3 py-2 text-sm text-gray-500 dark:text-gray-400">{stringifyUserRole(user.role)}</td>
<tr key={user.name}>
<td className="whitespace-nowrap px-3 py-2 text-sm text-gray-500 dark:text-gray-400">
{user.username}
<span className="ml-1 italic">{user.state === State.ARCHIVED && "(Archived)"}</span>
</td>
<td className="whitespace-nowrap px-3 py-2 text-sm text-gray-500 dark:text-gray-400">{stringifyUserRole(user.role)}</td>
<td className="whitespace-nowrap px-3 py-2 text-sm text-gray-500 dark:text-gray-400">{user.nickname}</td>
<td className="whitespace-nowrap px-3 py-2 text-sm text-gray-500 dark:text-gray-400">{user.email}</td>
<td className="relative whitespace-nowrap py-2 pl-3 pr-4 text-right text-sm font-medium flex justify-end">
{currentUser?.id === user.id ? (
{currentUser?.name === user.name ? (
<span>{t("common.yourself")}</span>
) : (
<Dropdown>

@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { webhookServiceClient } from "@/grpcweb";
import useCurrentUser from "@/hooks/useCurrentUser";
import { extractUserIdFromName } from "@/store/v1";
import { Webhook } from "@/types/proto/api/v1/webhook_service";
import { useTranslate } from "@/utils/i18n";
import showCreateWebhookDialog from "../CreateWebhookDialog";
@ -21,13 +22,13 @@ const WebhookSection = () => {
const [webhooks, setWebhooks] = useState<Webhook[]>([]);
useEffect(() => {
listWebhooks(currentUser.id).then((webhooks) => {
listWebhooks(extractUserIdFromName(currentUser.name)).then((webhooks) => {
setWebhooks(webhooks);
});
}, []);
const handleCreateAccessTokenDialogConfirm = async () => {
const webhooks = await listWebhooks(currentUser.id);
const webhooks = await listWebhooks(extractUserIdFromName(currentUser.name));
setWebhooks(webhooks);
};

@ -4,6 +4,10 @@ export const memoNamePrefix = "memos/";
export const identityProviderNamePrefix = "identityProviders/";
export const activityNamePrefix = "activities/";
export const extractUserIdFromName = (name: string) => {
return parseInt(name.split(userNamePrefix).pop() || "", 10);
};
export const extractMemoIdFromName = (name: string) => {
return parseInt(name.split(memoNamePrefix).pop() || "", 10);
};

Loading…
Cancel
Save