mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-06 21:22:36 +00:00
chore: implement i18n setting
This commit is contained in:
@ -35,12 +35,12 @@ func (s *UserSettingService) GetUserSetting(ctx context.Context, request *apiv2p
|
||||
}
|
||||
|
||||
func (s *UserSettingService) UpdateUserSetting(ctx context.Context, request *apiv2pb.UpdateUserSettingRequest) (*apiv2pb.UpdateUserSettingResponse, error) {
|
||||
if len(request.UpdateMask.Paths) == 0 {
|
||||
if request.UpdateMask == nil || len(request.UpdateMask) == 0 {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "update mask is empty")
|
||||
}
|
||||
|
||||
userID := ctx.Value(UserIDContextKey).(int32)
|
||||
for _, path := range request.UpdateMask.Paths {
|
||||
for _, path := range request.UpdateMask {
|
||||
if path == "locale" {
|
||||
if _, err := s.Store.UpsertUserSetting(ctx, &storepb.UserSetting{
|
||||
UserId: userID,
|
||||
@ -73,7 +73,9 @@ func getUserSetting(ctx context.Context, s *store.Store, userID int32) (*apiv2pb
|
||||
return nil, errors.Wrap(err, "failed to find user setting")
|
||||
}
|
||||
|
||||
userSetting := &apiv2pb.UserSetting{}
|
||||
userSetting := &apiv2pb.UserSetting{
|
||||
Id: userID,
|
||||
}
|
||||
for _, setting := range userSettings {
|
||||
if setting.Key == storepb.UserSettingKey_USER_SETTING_LOCALE {
|
||||
userSetting.Locale = convertUserSettingLocaleFromStore(setting.GetLocale())
|
||||
|
Reference in New Issue
Block a user