feat: add workbench and client settings APIs
This commit is contained in:
@@ -214,6 +214,7 @@ type testSecurityStore struct {
|
||||
realName *types.RealNameVerification
|
||||
actionToken *types.ActionToken
|
||||
independentPassword *types.IndependentPassword
|
||||
youthMode *types.YouthModeSettings
|
||||
attempts int
|
||||
lockedUntil *time.Time
|
||||
notifications []types.SystemNotification
|
||||
@@ -292,6 +293,46 @@ func (s *testSecurityStore) UpdateIndependentPasswordAttempts(_ types.TenantID,
|
||||
return s.err
|
||||
}
|
||||
|
||||
func (s *testSecurityStore) GetYouthMode(_ types.TenantID, uid types.Uid) (*types.YouthModeSettings, error) {
|
||||
if s.err != nil {
|
||||
return nil, s.err
|
||||
}
|
||||
if s.youthMode == nil {
|
||||
now := time.Now().UTC().Round(time.Millisecond)
|
||||
s.youthMode = &types.YouthModeSettings{
|
||||
UserID: uid,
|
||||
Enabled: false,
|
||||
PolicyVersion: 1,
|
||||
Restrictions: []string{"night_quiet", "content_filter", "payment_guard"},
|
||||
PasswordSet: s.independentPassword != nil,
|
||||
CanEnable: s.independentPassword != nil,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
}
|
||||
return s.youthMode, nil
|
||||
}
|
||||
|
||||
func (s *testSecurityStore) SetYouthMode(_ types.TenantID, uid types.Uid, enabled bool, policyVersion int, now time.Time) (*types.YouthModeSettings, error) {
|
||||
if s.err != nil {
|
||||
return nil, s.err
|
||||
}
|
||||
if s.youthMode == nil {
|
||||
s.youthMode = &types.YouthModeSettings{UserID: uid, Restrictions: []string{"night_quiet", "content_filter", "payment_guard"}}
|
||||
}
|
||||
s.youthMode.Enabled = enabled
|
||||
s.youthMode.PolicyVersion = policyVersion
|
||||
s.youthMode.PasswordSet = true
|
||||
s.youthMode.CanEnable = !enabled
|
||||
s.youthMode.UpdatedAt = now
|
||||
if enabled {
|
||||
s.youthMode.EnabledAt = &now
|
||||
} else {
|
||||
s.youthMode.EnabledAt = nil
|
||||
}
|
||||
return s.youthMode, nil
|
||||
}
|
||||
|
||||
func (s *testSecurityStore) CreateSystemNotification(_ types.TenantID, notification *types.SystemNotification) error {
|
||||
if notification != nil {
|
||||
s.notifications = append(s.notifications, *notification)
|
||||
|
||||
Reference in New Issue
Block a user