Skip to content

Commit

Permalink
fix doc and getValue
Browse files Browse the repository at this point in the history
  • Loading branch information
2403905 committed Oct 6, 2023
1 parent 888d696 commit e82ee6f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion services/settings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ The settings service needs to know the ID's of service accounts but it doesn't n

## Default language

The default language can be defined via SETTINGS_DEFAULT_LANGUAGE environment variable. If this variable is not defined, English will be used as default. This setting can be used to set the default language for invitation emails.
The default language can be defined via SETTINGS_DEFAULT_LANGUAGE environment variable. If this variable is not defined, English will be used as default. The value has ISO 639-1 format ("de", "en", etc.) and limited by the supported languages. This setting can be used to set the default language for invitation emails.
2 changes: 1 addition & 1 deletion services/settings/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Config struct {

ServiceAccountIDAdmin string `yaml:"service_account_id_admin" env:"OCIS_SERVICE_ACCOUNT_ID;SETTINGS_SERVICE_ACCOUNT_ID_ADMIN" desc:"The ID of the service account having the admin role. See the 'auth-service' service description for more details."`

DefaultLanguage string `yaml:"default_language" env:"SETTINGS_DEFAULT_LANGUAGE" desc:"The default language. If not defined, English will be used as default."`
DefaultLanguage string `yaml:"default_language" env:"SETTINGS_DEFAULT_LANGUAGE" desc:"The default language. If not defined, English will be used as default. See the documentation for more details."`

Context context.Context `yaml:"-"`
}
Expand Down
17 changes: 8 additions & 9 deletions services/settings/pkg/service/v0/servicedecorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package svc

import (
"context"
"strings"

settingsmsg "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/settings/v0"
settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0"
"github.com/owncloud/ocis/v2/services/settings/pkg/settings"

"github.com/owncloud/ocis/v2/services/settings/pkg/config"
"github.com/owncloud/ocis/v2/services/settings/pkg/settings"
"github.com/owncloud/ocis/v2/services/settings/pkg/store/defaults"
)

Expand All @@ -29,11 +29,12 @@ type defaultLanguageDecorator struct {
func (s *defaultLanguageDecorator) GetValueByUniqueIdentifiers(ctx context.Context, req *settingssvc.GetValueByUniqueIdentifiersRequest, res *settingssvc.GetValueResponse) error {
err := s.ServiceHandler.GetValueByUniqueIdentifiers(ctx, req, res)
if err != nil {
if strings.Contains(strings.ToLower(err.Error()), "not found") && req.GetSettingId() == defaults.SettingUUIDProfileLanguage && res.GetValue() == nil {
res.Value = s.withDefaultLanguageSetting(req.AccountUuid)
return nil
}
return err
}
if res.Value == nil {
res.Value = s.withDefaultLanguageSetting(req.AccountUuid)
}
return nil
}

Expand All @@ -54,15 +55,13 @@ func (s *defaultLanguageDecorator) ListValues(ctx context.Context, req *settings
}

func (s *defaultLanguageDecorator) withDefaultLanguageSetting(accountUUID string) *settingsmsg.ValueWithIdentifier {
bundle := generateBundleProfileRequest()
return &settingsmsg.ValueWithIdentifier{
Identifier: &settingsmsg.Identifier{
Extension: bundle.Extension,
Bundle: bundle.Name,
Extension: "ocis-accounts",
Bundle: "profile",
Setting: "language",
},
Value: &settingsmsg.Value{
Id: "",
BundleId: defaults.BundleUUIDProfile,
SettingId: defaults.SettingUUIDProfileLanguage,
AccountUuid: accountUUID,
Expand Down

0 comments on commit e82ee6f

Please sign in to comment.