feat: add user locale setting

This commit is contained in:
steven 2023-09-02 14:10:03 +08:00
parent 96c1901dce
commit 98cb5a2292
7 changed files with 222 additions and 42 deletions

View File

@ -19,6 +19,31 @@ export declare enum UserSettingKey {
* @generated from enum value: USER_SETTING_ACCESS_TOKENS = 1; * @generated from enum value: USER_SETTING_ACCESS_TOKENS = 1;
*/ */
USER_SETTING_ACCESS_TOKENS = 1, USER_SETTING_ACCESS_TOKENS = 1,
/**
* @generated from enum value: USER_SETTING_LOCALE = 2;
*/
USER_SETTING_LOCALE = 2,
}
/**
* @generated from enum slash.store.LocaleUserSetting
*/
export declare enum LocaleUserSetting {
/**
* @generated from enum value: LOCALE_USER_SETTING_UNSPECIFIED = 0;
*/
UNSPECIFIED = 0,
/**
* @generated from enum value: LOCALE_USER_SETTING_EN = 1;
*/
EN = 1,
/**
* @generated from enum value: LOCALE_USER_SETTING_ZH = 2;
*/
ZH = 2,
} }
/** /**
@ -44,6 +69,12 @@ export declare class UserSetting extends Message<UserSetting> {
*/ */
value: AccessTokensUserSetting; value: AccessTokensUserSetting;
case: "accessTokensUserSetting"; case: "accessTokensUserSetting";
} | {
/**
* @generated from field: slash.store.LocaleUserSetting locale_user_setting = 4;
*/
value: LocaleUserSetting;
case: "localeUserSetting";
} | { case: undefined; value?: undefined }; } | { case: undefined; value?: undefined };
constructor(data?: PartialMessage<UserSetting>); constructor(data?: PartialMessage<UserSetting>);

View File

@ -13,6 +13,19 @@ export const UserSettingKey = proto3.makeEnum(
[ [
{no: 0, name: "USER_SETTING_KEY_UNSPECIFIED"}, {no: 0, name: "USER_SETTING_KEY_UNSPECIFIED"},
{no: 1, name: "USER_SETTING_ACCESS_TOKENS"}, {no: 1, name: "USER_SETTING_ACCESS_TOKENS"},
{no: 2, name: "USER_SETTING_LOCALE"},
],
);
/**
* @generated from enum slash.store.LocaleUserSetting
*/
export const LocaleUserSetting = proto3.makeEnum(
"slash.store.LocaleUserSetting",
[
{no: 0, name: "LOCALE_USER_SETTING_UNSPECIFIED", localName: "UNSPECIFIED"},
{no: 1, name: "LOCALE_USER_SETTING_EN", localName: "EN"},
{no: 2, name: "LOCALE_USER_SETTING_ZH", localName: "ZH"},
], ],
); );
@ -25,6 +38,7 @@ export const UserSetting = proto3.makeMessageType(
{ no: 1, name: "user_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, { no: 1, name: "user_id", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
{ no: 2, name: "key", kind: "enum", T: proto3.getEnumType(UserSettingKey) }, { no: 2, name: "key", kind: "enum", T: proto3.getEnumType(UserSettingKey) },
{ no: 3, name: "access_tokens_user_setting", kind: "message", T: AccessTokensUserSetting, oneof: "value" }, { no: 3, name: "access_tokens_user_setting", kind: "message", T: AccessTokensUserSetting, oneof: "value" },
{ no: 4, name: "locale_user_setting", kind: "enum", T: proto3.getEnumType(LocaleUserSetting), oneof: "value" },
], ],
); );

View File

@ -20,6 +20,7 @@
- [AccessTokensUserSetting.AccessToken](#slash-store-AccessTokensUserSetting-AccessToken) - [AccessTokensUserSetting.AccessToken](#slash-store-AccessTokensUserSetting-AccessToken)
- [UserSetting](#slash-store-UserSetting) - [UserSetting](#slash-store-UserSetting)
- [LocaleUserSetting](#slash-store-LocaleUserSetting)
- [UserSettingKey](#slash-store-UserSettingKey) - [UserSettingKey](#slash-store-UserSettingKey)
- [Scalar Value Types](#scalar-value-types) - [Scalar Value Types](#scalar-value-types)
@ -208,6 +209,7 @@
| user_id | [int32](#int32) | | | | user_id | [int32](#int32) | | |
| key | [UserSettingKey](#slash-store-UserSettingKey) | | | | key | [UserSettingKey](#slash-store-UserSettingKey) | | |
| access_tokens_user_setting | [AccessTokensUserSetting](#slash-store-AccessTokensUserSetting) | | | | access_tokens_user_setting | [AccessTokensUserSetting](#slash-store-AccessTokensUserSetting) | | |
| locale_user_setting | [LocaleUserSetting](#slash-store-LocaleUserSetting) | | |
@ -216,6 +218,19 @@
<a name="slash-store-LocaleUserSetting"></a>
### LocaleUserSetting
| Name | Number | Description |
| ---- | ------ | ----------- |
| LOCALE_USER_SETTING_UNSPECIFIED | 0 | |
| LOCALE_USER_SETTING_EN | 1 | |
| LOCALE_USER_SETTING_ZH | 2 | |
<a name="slash-store-UserSettingKey"></a> <a name="slash-store-UserSettingKey"></a>
### UserSettingKey ### UserSettingKey
@ -225,6 +240,7 @@
| ---- | ------ | ----------- | | ---- | ------ | ----------- |
| USER_SETTING_KEY_UNSPECIFIED | 0 | | | USER_SETTING_KEY_UNSPECIFIED | 0 | |
| USER_SETTING_ACCESS_TOKENS | 1 | | | USER_SETTING_ACCESS_TOKENS | 1 | |
| USER_SETTING_LOCALE | 2 | |

View File

@ -25,6 +25,7 @@ type UserSettingKey int32
const ( const (
UserSettingKey_USER_SETTING_KEY_UNSPECIFIED UserSettingKey = 0 UserSettingKey_USER_SETTING_KEY_UNSPECIFIED UserSettingKey = 0
UserSettingKey_USER_SETTING_ACCESS_TOKENS UserSettingKey = 1 UserSettingKey_USER_SETTING_ACCESS_TOKENS UserSettingKey = 1
UserSettingKey_USER_SETTING_LOCALE UserSettingKey = 2
) )
// Enum value maps for UserSettingKey. // Enum value maps for UserSettingKey.
@ -32,10 +33,12 @@ var (
UserSettingKey_name = map[int32]string{ UserSettingKey_name = map[int32]string{
0: "USER_SETTING_KEY_UNSPECIFIED", 0: "USER_SETTING_KEY_UNSPECIFIED",
1: "USER_SETTING_ACCESS_TOKENS", 1: "USER_SETTING_ACCESS_TOKENS",
2: "USER_SETTING_LOCALE",
} }
UserSettingKey_value = map[string]int32{ UserSettingKey_value = map[string]int32{
"USER_SETTING_KEY_UNSPECIFIED": 0, "USER_SETTING_KEY_UNSPECIFIED": 0,
"USER_SETTING_ACCESS_TOKENS": 1, "USER_SETTING_ACCESS_TOKENS": 1,
"USER_SETTING_LOCALE": 2,
} }
) )
@ -66,6 +69,55 @@ func (UserSettingKey) EnumDescriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{0} return file_store_user_setting_proto_rawDescGZIP(), []int{0}
} }
type LocaleUserSetting int32
const (
LocaleUserSetting_LOCALE_USER_SETTING_UNSPECIFIED LocaleUserSetting = 0
LocaleUserSetting_LOCALE_USER_SETTING_EN LocaleUserSetting = 1
LocaleUserSetting_LOCALE_USER_SETTING_ZH LocaleUserSetting = 2
)
// Enum value maps for LocaleUserSetting.
var (
LocaleUserSetting_name = map[int32]string{
0: "LOCALE_USER_SETTING_UNSPECIFIED",
1: "LOCALE_USER_SETTING_EN",
2: "LOCALE_USER_SETTING_ZH",
}
LocaleUserSetting_value = map[string]int32{
"LOCALE_USER_SETTING_UNSPECIFIED": 0,
"LOCALE_USER_SETTING_EN": 1,
"LOCALE_USER_SETTING_ZH": 2,
}
)
func (x LocaleUserSetting) Enum() *LocaleUserSetting {
p := new(LocaleUserSetting)
*p = x
return p
}
func (x LocaleUserSetting) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (LocaleUserSetting) Descriptor() protoreflect.EnumDescriptor {
return file_store_user_setting_proto_enumTypes[1].Descriptor()
}
func (LocaleUserSetting) Type() protoreflect.EnumType {
return &file_store_user_setting_proto_enumTypes[1]
}
func (x LocaleUserSetting) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use LocaleUserSetting.Descriptor instead.
func (LocaleUserSetting) EnumDescriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{1}
}
type UserSetting struct { type UserSetting struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -76,6 +128,7 @@ type UserSetting struct {
// Types that are assignable to Value: // Types that are assignable to Value:
// //
// *UserSetting_AccessTokensUserSetting // *UserSetting_AccessTokensUserSetting
// *UserSetting_LocaleUserSetting
Value isUserSetting_Value `protobuf_oneof:"value"` Value isUserSetting_Value `protobuf_oneof:"value"`
} }
@ -139,6 +192,13 @@ func (x *UserSetting) GetAccessTokensUserSetting() *AccessTokensUserSetting {
return nil return nil
} }
func (x *UserSetting) GetLocaleUserSetting() LocaleUserSetting {
if x, ok := x.GetValue().(*UserSetting_LocaleUserSetting); ok {
return x.LocaleUserSetting
}
return LocaleUserSetting_LOCALE_USER_SETTING_UNSPECIFIED
}
type isUserSetting_Value interface { type isUserSetting_Value interface {
isUserSetting_Value() isUserSetting_Value()
} }
@ -147,8 +207,14 @@ type UserSetting_AccessTokensUserSetting struct {
AccessTokensUserSetting *AccessTokensUserSetting `protobuf:"bytes,3,opt,name=access_tokens_user_setting,json=accessTokensUserSetting,proto3,oneof"` AccessTokensUserSetting *AccessTokensUserSetting `protobuf:"bytes,3,opt,name=access_tokens_user_setting,json=accessTokensUserSetting,proto3,oneof"`
} }
type UserSetting_LocaleUserSetting struct {
LocaleUserSetting LocaleUserSetting `protobuf:"varint,4,opt,name=locale_user_setting,json=localeUserSetting,proto3,enum=slash.store.LocaleUserSetting,oneof"`
}
func (*UserSetting_AccessTokensUserSetting) isUserSetting_Value() {} func (*UserSetting_AccessTokensUserSetting) isUserSetting_Value() {}
func (*UserSetting_LocaleUserSetting) isUserSetting_Value() {}
type AccessTokensUserSetting struct { type AccessTokensUserSetting struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -256,7 +322,7 @@ var File_store_user_setting_proto protoreflect.FileDescriptor
var file_store_user_setting_proto_rawDesc = []byte{ var file_store_user_setting_proto_rawDesc = []byte{
0x0a, 0x18, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x0a, 0x18, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74,
0x74, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x73, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x73, 0x6c, 0x61, 0x73,
0x68, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x22, 0xc3, 0x01, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x68, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x22, 0x95, 0x02, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72,
0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
0x12, 0x2d, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x12, 0x2d, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e,
@ -268,35 +334,49 @@ var file_store_user_setting_proto_rawDesc = []byte{
0x65, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x55, 0x73, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x55, 0x73,
0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x17, 0x61, 0x63, 0x63, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x17, 0x61, 0x63, 0x63,
0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74,
0x74, 0x69, 0x6e, 0x67, 0x42, 0x07, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xc4, 0x01, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x50, 0x0a, 0x13, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x5f, 0x75,
0x0a, 0x17, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x55, 0x73, 0x73, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28,
0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x55, 0x0a, 0x0d, 0x61, 0x63, 0x63, 0x0e, 0x32, 0x1e, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e,
0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e,
0x32, 0x30, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x67, 0x48, 0x00, 0x52, 0x11, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53,
0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x07, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22,
0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0xc4, 0x01, 0x0a, 0x17, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73,
0x65, 0x6e, 0x52, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x55, 0x0a, 0x0d, 0x61,
0x1a, 0x52, 0x0a, 0x0b, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03,
0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x55, 0x73, 0x65,
0x65, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54,
0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65,
0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x52, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x6e, 0x73, 0x1a, 0x52, 0x0a, 0x0b, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65,
0x69, 0x6e, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x1c, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x53, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65,
0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54,
0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x1a, 0x55, 0x53, 0x45, 0x52, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72,
0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x53, 0x10, 0x01, 0x42, 0x9a, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x6b, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65,
0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x42, 0x10, 0x55, 0x73, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x4b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x1c, 0x55, 0x53, 0x45, 0x52,
0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x55, 0x4e, 0x53,
0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6f, 0x6f, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1e, 0x0a, 0x1a, 0x55, 0x53,
0x6a, 0x61, 0x63, 0x6b, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x45, 0x52, 0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x53,
0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0xa2, 0x02, 0x03, 0x53, 0x53, 0x58, 0x53, 0x5f, 0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x53, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x53,
0xaa, 0x02, 0x0b, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xca, 0x02, 0x45, 0x52, 0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f, 0x4c, 0x4f, 0x43, 0x41, 0x4c,
0x0b, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xe2, 0x02, 0x17, 0x53, 0x45, 0x10, 0x02, 0x2a, 0x70, 0x0a, 0x11, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x65, 0x55, 0x73, 0x65,
0x6c, 0x61, 0x73, 0x68, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x23, 0x0a, 0x1f, 0x4c, 0x4f, 0x43, 0x41,
0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x3a, 0x3a, 0x4c, 0x45, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x5f,
0x53, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1a, 0x0a,
0x16, 0x4c, 0x4f, 0x43, 0x41, 0x4c, 0x45, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x53, 0x45, 0x54,
0x54, 0x49, 0x4e, 0x47, 0x5f, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x4c, 0x4f, 0x43,
0x41, 0x4c, 0x45, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47,
0x5f, 0x5a, 0x48, 0x10, 0x02, 0x42, 0x9a, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c,
0x61, 0x73, 0x68, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x42, 0x10, 0x55, 0x73, 0x65, 0x72, 0x53,
0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6f, 0x6f, 0x6a, 0x61, 0x63,
0x6b, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65,
0x6e, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0xa2, 0x02, 0x03, 0x53, 0x53, 0x58, 0xaa, 0x02, 0x0b,
0x53, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xca, 0x02, 0x0b, 0x53, 0x6c,
0x61, 0x73, 0x68, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xe2, 0x02, 0x17, 0x53, 0x6c, 0x61, 0x73,
0x68, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0xea, 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x3a, 0x3a, 0x53, 0x74, 0x6f,
0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -311,23 +391,25 @@ func file_store_user_setting_proto_rawDescGZIP() []byte {
return file_store_user_setting_proto_rawDescData return file_store_user_setting_proto_rawDescData
} }
var file_store_user_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_store_user_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
var file_store_user_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_store_user_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_store_user_setting_proto_goTypes = []interface{}{ var file_store_user_setting_proto_goTypes = []interface{}{
(UserSettingKey)(0), // 0: slash.store.UserSettingKey (UserSettingKey)(0), // 0: slash.store.UserSettingKey
(*UserSetting)(nil), // 1: slash.store.UserSetting (LocaleUserSetting)(0), // 1: slash.store.LocaleUserSetting
(*AccessTokensUserSetting)(nil), // 2: slash.store.AccessTokensUserSetting (*UserSetting)(nil), // 2: slash.store.UserSetting
(*AccessTokensUserSetting_AccessToken)(nil), // 3: slash.store.AccessTokensUserSetting.AccessToken (*AccessTokensUserSetting)(nil), // 3: slash.store.AccessTokensUserSetting
(*AccessTokensUserSetting_AccessToken)(nil), // 4: slash.store.AccessTokensUserSetting.AccessToken
} }
var file_store_user_setting_proto_depIdxs = []int32{ var file_store_user_setting_proto_depIdxs = []int32{
0, // 0: slash.store.UserSetting.key:type_name -> slash.store.UserSettingKey 0, // 0: slash.store.UserSetting.key:type_name -> slash.store.UserSettingKey
2, // 1: slash.store.UserSetting.access_tokens_user_setting:type_name -> slash.store.AccessTokensUserSetting 3, // 1: slash.store.UserSetting.access_tokens_user_setting:type_name -> slash.store.AccessTokensUserSetting
3, // 2: slash.store.AccessTokensUserSetting.access_tokens:type_name -> slash.store.AccessTokensUserSetting.AccessToken 1, // 2: slash.store.UserSetting.locale_user_setting:type_name -> slash.store.LocaleUserSetting
3, // [3:3] is the sub-list for method output_type 4, // 3: slash.store.AccessTokensUserSetting.access_tokens:type_name -> slash.store.AccessTokensUserSetting.AccessToken
3, // [3:3] is the sub-list for method input_type 4, // [4:4] is the sub-list for method output_type
3, // [3:3] is the sub-list for extension type_name 4, // [4:4] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension extendee 4, // [4:4] is the sub-list for extension type_name
0, // [0:3] is the sub-list for field type_name 4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
} }
func init() { file_store_user_setting_proto_init() } func init() { file_store_user_setting_proto_init() }
@ -375,13 +457,14 @@ func file_store_user_setting_proto_init() {
} }
file_store_user_setting_proto_msgTypes[0].OneofWrappers = []interface{}{ file_store_user_setting_proto_msgTypes[0].OneofWrappers = []interface{}{
(*UserSetting_AccessTokensUserSetting)(nil), (*UserSetting_AccessTokensUserSetting)(nil),
(*UserSetting_LocaleUserSetting)(nil),
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_store_user_setting_proto_rawDesc, RawDescriptor: file_store_user_setting_proto_rawDesc,
NumEnums: 1, NumEnums: 2,
NumMessages: 3, NumMessages: 3,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,

View File

@ -11,6 +11,8 @@ message UserSetting {
oneof value { oneof value {
AccessTokensUserSetting access_tokens_user_setting = 3; AccessTokensUserSetting access_tokens_user_setting = 3;
LocaleUserSetting locale_user_setting = 4;
} }
} }
@ -18,6 +20,8 @@ enum UserSettingKey {
USER_SETTING_KEY_UNSPECIFIED = 0; USER_SETTING_KEY_UNSPECIFIED = 0;
USER_SETTING_ACCESS_TOKENS = 1; USER_SETTING_ACCESS_TOKENS = 1;
USER_SETTING_LOCALE = 2;
} }
message AccessTokensUserSetting { message AccessTokensUserSetting {
@ -27,3 +31,9 @@ message AccessTokensUserSetting {
} }
repeated AccessToken access_tokens = 1; repeated AccessToken access_tokens = 1;
} }
enum LocaleUserSetting {
LOCALE_USER_SETTING_UNSPECIFIED = 0;
LOCALE_USER_SETTING_EN = 1;
LOCALE_USER_SETTING_ZH = 2;
}

View File

@ -31,6 +31,8 @@ func (s *Store) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetti
return nil, err return nil, err
} }
valueString = string(valueBytes) valueString = string(valueBytes)
} else if upsert.Key == storepb.UserSettingKey_USER_SETTING_LOCALE {
valueString = upsert.GetLocaleUserSetting().String()
} else { } else {
return nil, errors.New("invalid user setting key") return nil, errors.New("invalid user setting key")
} }

View File

@ -19,6 +19,8 @@ func TestUserSettingStore(t *testing.T) {
}) })
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, 0, len(userSettings)) require.Equal(t, 0, len(userSettings))
// Test for access tokens user setting.
accessTokensUserSetting, err := ts.UpsertUserSetting(ctx, &storepb.UserSetting{ accessTokensUserSetting, err := ts.UpsertUserSetting(ctx, &storepb.UserSetting{
UserId: user.ID, UserId: user.ID,
Key: storepb.UserSettingKey_USER_SETTING_ACCESS_TOKENS, Key: storepb.UserSettingKey_USER_SETTING_ACCESS_TOKENS,
@ -70,4 +72,26 @@ func TestUserSettingStore(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, accessTokensUserSetting) require.NotNil(t, accessTokensUserSetting)
require.Equal(t, 2, len(accessTokensUserSetting.GetAccessTokensUserSetting().AccessTokens)) require.Equal(t, 2, len(accessTokensUserSetting.GetAccessTokensUserSetting().AccessTokens))
// Test for locale user setting.
localeUserSetting, err := ts.UpsertUserSetting(ctx, &storepb.UserSetting{
UserId: user.ID,
Key: storepb.UserSettingKey_USER_SETTING_LOCALE,
Value: &storepb.UserSetting_LocaleUserSetting{
LocaleUserSetting: storepb.LocaleUserSetting_LOCALE_USER_SETTING_ZH,
},
})
require.NoError(t, err)
require.NotNil(t, localeUserSetting)
require.Equal(t, storepb.UserSettingKey_USER_SETTING_LOCALE, localeUserSetting.Key)
require.Equal(t, storepb.LocaleUserSetting_LOCALE_USER_SETTING_ZH, localeUserSetting.GetLocaleUserSetting())
localeUserSetting, err = ts.UpsertUserSetting(ctx, &storepb.UserSetting{
UserId: user.ID,
Key: storepb.UserSettingKey_USER_SETTING_LOCALE,
Value: &storepb.UserSetting_LocaleUserSetting{
LocaleUserSetting: storepb.LocaleUserSetting_LOCALE_USER_SETTING_EN,
},
})
require.NoError(t, err)
require.Equal(t, storepb.LocaleUserSetting_LOCALE_USER_SETTING_EN, localeUserSetting.GetLocaleUserSetting())
} }