sane: fix contact desyncs
:: their hooks
:: - Each group has its associated metadata and contacts
:: - Each graph is being synced
-:: - Each chat is being synced
::
/- *metadata-store, contacts=contact-store, *group
/+ default-agent, verb, dbug, resource, graph, mdl=metadata, group
-~% %sane-app ..card ~
+~% %sane-app ..part ~
|%
+$ card card:agent:gall
::
+$ issue
$% [%lib-pull-hook-desync app=term =resource]
[%lib-push-hook-desync app=term =resource]
- [%contact-hook-desync =path]
[%dangling-md =resource]
==
::
++ on-peek
|= =path
^- (unit (unit cage))
- ?. ?=([%x %bad-path ~] path)
+ ?: ?=([%x %bad-path ~] path) ~
(on-peek:def path)
- ~
::
++ on-arvo on-arvo:def
++ on-fail on-fail:def
--
::
|_ =bowl:gall
-::
++ gra ~(. graph bowl)
-::
++ md ~(. mdl bowl)
-::
++ grp ~(. group bowl)
::
++ foreign-keys
=> (lib-hooks-desync %group scry-groups)
=> (lib-hooks-desync %graph get-keys:gra)
=> (lib-hooks-desync %metadata scry-groups)
- => groups
+ => contacts
metadata
::
- ++ groups
+ ++ contacts
^+ fk-core
=/ groups=(list resource)
~(tap in scry-groups)
?~ groups
fk-core
=* group i.groups
- =? fk-core &((is-managed:grp group) !(~(has in scry-contact-syncs) group))
- (report %contact-hook-desync (en-path:resource group))
+ =? fk-core
+ ?& (is-managed:grp group)
+ !=(our.bowl entity.group)
+ !(~(has in (tracking-pull-hook %contact-pull-hook)) group)
+ ==
+ (report %lib-pull-hook-desync %contact-pull-hook group)
$(groups t.groups)
::
++ metadata
::
%lib-push-hook-desync
(poke-our app.issue push-hook-action+!>([%add resource.issue]))^~
- ::
- %contact-hook-desync
- =/ rid=resource
- (de-path:resource path.issue)
- =/ act
- ?: =(entity.rid our.bowl)
- [%add-owned path.issue]
- [%add-synced entity.rid path.issue]
- (poke-our %contact-hook contact-hook-action+!>(act))^~
::
%dangling-md
=/ app-indices
,(set resource)
/x/[hook]/sharing/noun
::
-++ scry-contact-syncs
- ^- (set resource)
- =- (~(run in -) de-path:resource)
- %+ scry
- ,(set path)
- /x/contact-hook/synced/noun
-::
-++ scry-chat-syncs
- ^- (set path)
- %+ scry
- ,(set path)
- /x/chat-hook/synced/noun
-::
-++ scry-chats
- ^- (set path)
- %+ scry
- ,(set path)
- /x/chat-store/keys/noun
-::
-::
++ md-group-indices
(scry (jug resource md-resource) /y/metadata-store/group-indices)
::
