-
Notifications
You must be signed in to change notification settings - Fork 16
feat: (DRAFT / SPIKE) managed policy profiles #1776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
…ed" policy profiles which can be pushed to the app.
@@ -129,6 +131,9 @@ class _OnboardingButtonState extends State<OnboardingButton> { | |||
} | |||
|
|||
Future<void> onboard({required String atsign, required String rootDomain, bool isFromInitState = false}) async { | |||
SyncServiceImpl.queueSize = 1; | |||
SyncServiceImpl.syncRequestThreshold = 1; | |||
SyncServiceImpl.syncRequestTriggerInSeconds = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we get a statsNotification that commitId has increased, we want to have the sync execute as soon as possible.
Dependence on sync for dynamic addition / removal of profiles is unlikely be part of the eventual solution.
await initializeContactsService(rootDomain: rootDomain); | ||
AtClientManager.getInstance().atClient.syncService.addProgressListener(ProfileProgressListener()); | ||
AtClientManager.getInstance().atClient.syncService.sync(); | ||
atClient.syncService.addProgressListener(ProfileProgressListener(atClient)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor to inject the atClient into the ProfileProgressListener
@@ -8,8 +8,11 @@ import 'package:npt_flutter/util/uuid.dart'; | |||
|
|||
class ProfileRepository { | |||
final Map<String, Profile> _profileCache = {}; | |||
final Map<String, String?> _profileSharedByMap = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this spike we need a way to keep track of who shared the profile so that when we actually fetch the profile from the datastore we can pass the correct sharedBy
if (ix >= 0) { | ||
final uuid = key.key.substring(0, ix); | ||
final sharedBy = key.sharedBy; | ||
_profileSharedByMap[uuid] = sharedBy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep track of the sharedBy
import 'package:npt_flutter/features/profile_list/bloc/profile_list_bloc.dart'; | ||
import 'package:npt_flutter/util/uuid.dart'; | ||
|
||
import '../../profile_list/cubit/sync_cubit.dart'; | ||
|
||
class ProfileProgressListener extends SyncProgressListener { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spike approach was to subscribe to notifications auto-generated as a result of another atSign sharing or unsharing a profile. Receiving an update
triggers a sync
the results of which are later handled by the onSyncProgressEvent
function below; receiving a delete
removes the cached:
profile and triggers a ProfileListLoadEvent
for the ProfileListBlock
final profileListBlock = | ||
App.navState.currentContext!.read<ProfileListBloc>(); | ||
|
||
bool profileSynced() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if this syncProgressEvent contained updates / deletes of any profiles
|
||
if (syncProgress.syncStatus == SyncStatus.success && | ||
(profileListBlock.state is ProfileListLoaded && | ||
profileListBlock.state is ProfileListLoaded && | ||
(profileSynced() || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now triggering the ProfileListLoadEvent not just on the initial sync of the app, but on subsequent syncs
Closes #1777
Currently end-users have to fully manage all of their profiles. We want to enable policy owners / administrators to have their policy management atSign “push” profiles to their end-users so that those profiles are visible and available for use (or removed, and unavailable for use) in near-real-time.
This PR currently only contains an initial spike. It illustrates the basic functionality but has the following limitations:
(1) It would permit 'spam' - i.e. any atSign could push profiles to any user
(2) It does not allow the end-user to remove or update these managed profiles as they wish, while still allowing for profiles to be deleted via the policy management atSign sending a deleteProfile event
Ongoing design discussion is here
- What I did
npp_push
) with hard-coded values to share and then un-share a profile- How I did it
Files Changed
tab- How to verify it
packages/sshnoports/bin/npp_push.dart
changing atSigns etc, then executedart bin/npp_push.dart <profile name>