user feature restriction supports application settings syncing

This commit is contained in:
MaysWind
2025-06-30 22:06:43 +08:00
parent e13efdc11f
commit b37cde5a8c
4 changed files with 42 additions and 4 deletions
+8 -2
View File
@@ -31,7 +31,7 @@ func (r UserFeatureRestrictions) Contains(featureRestrictionType UserFeatureRest
func (r UserFeatureRestrictions) String() string {
builder := strings.Builder{}
for restrictionType := USER_FEATURE_RESTRICTION_TYPE_UPDATE_PASSWORD; restrictionType <= USER_FEATURE_RESTRICTION_TYPE_CLEAR_ALL_DATA; restrictionType++ {
for restrictionType := userFeatureRestrictionTypeMinValue; restrictionType <= userFeatureRestrictionTypeMaxValue; restrictionType++ {
if !r.Contains(restrictionType) {
continue
}
@@ -62,7 +62,7 @@ func ParseUserFeatureRestrictions(featureRestrictions string) UserFeatureRestric
continue
}
if uint64(USER_FEATURE_RESTRICTION_TYPE_UPDATE_PASSWORD) <= uint64(value) && uint64(value) <= uint64(USER_FEATURE_RESTRICTION_TYPE_CLEAR_ALL_DATA) {
if uint64(userFeatureRestrictionTypeMinValue) <= uint64(value) && uint64(value) <= uint64(userFeatureRestrictionTypeMaxValue) {
typeValue := uint64(1 << (value - 1))
restrictions = restrictions | typeValue
}
@@ -87,8 +87,12 @@ const (
USER_FEATURE_RESTRICTION_TYPE_IMPORT_TRANSACTION UserFeatureRestrictionType = 9
USER_FEATURE_RESTRICTION_TYPE_EXPORT_TRANSACTION UserFeatureRestrictionType = 10
USER_FEATURE_RESTRICTION_TYPE_CLEAR_ALL_DATA UserFeatureRestrictionType = 11
USER_FEATURE_RESTRICTION_TYPE_SYNC_APPLICATION_SETTINGS UserFeatureRestrictionType = 12
)
const userFeatureRestrictionTypeMinValue UserFeatureRestrictionType = USER_FEATURE_RESTRICTION_TYPE_UPDATE_PASSWORD
const userFeatureRestrictionTypeMaxValue UserFeatureRestrictionType = USER_FEATURE_RESTRICTION_TYPE_SYNC_APPLICATION_SETTINGS
// String returns a textual representation of the restriction type of user features
func (t UserFeatureRestrictionType) String() string {
switch t {
@@ -114,6 +118,8 @@ func (t UserFeatureRestrictionType) String() string {
return "Export Transactions"
case USER_FEATURE_RESTRICTION_TYPE_CLEAR_ALL_DATA:
return "Clear All Data"
case USER_FEATURE_RESTRICTION_TYPE_SYNC_APPLICATION_SETTINGS:
return "Sync Application Settings"
default:
return fmt.Sprintf("Invalid(%d)", int(t))
}