From c9583ee10480aa1232fc284691ac94977098195a Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 1 Feb 2021 14:49:14 -0600 Subject: [PATCH 01/20] push-hook: revert removal of +resource-for-update, change type from (unit resource) to (list resource) to support contact-push-hook use case --- pkg/arvo/app/contact-push-hook.hoon | 15 +++++ pkg/arvo/app/graph-push-hook.hoon | 21 ++++++ pkg/arvo/app/group-push-hook.hoon | 8 +++ pkg/arvo/app/metadata-push-hook.hoon | 7 ++ pkg/arvo/lib/push-hook.hoon | 99 ++++++++++++++-------------- pkg/arvo/mar/contact/update.hoon | 16 ----- pkg/arvo/mar/graph/update.hoon | 7 -- pkg/arvo/mar/group/update.hoon | 4 -- pkg/arvo/mar/metadata/update.hoon | 3 - 9 files changed, 100 insertions(+), 80 deletions(-) diff --git a/pkg/arvo/app/contact-push-hook.hoon b/pkg/arvo/app/contact-push-hook.hoon index 716d33e8b..6b4ed252a 100644 --- a/pkg/arvo/app/contact-push-hook.hoon +++ b/pkg/arvo/app/contact-push-hook.hoon @@ -48,6 +48,21 @@ %set-public %.n == :: +++ resource-for-update + |= =vase + ^- (list resource:res) + =/ =update:store !<(update:store vase) + ~ + ::?- -.update + :: %initial !! + :: %add !! + :: %remove !! + :: %edit !! + :: %allow !! + :: %disallow !! + :: %set-public !! + ::== +:: ++ initial-watch |= [=path =resource:res] ^- vase diff --git a/pkg/arvo/app/graph-push-hook.hoon b/pkg/arvo/app/graph-push-hook.hoon index c862a53c0..bc4743af1 100644 --- a/pkg/arvo/app/graph-push-hook.hoon +++ b/pkg/arvo/app/graph-push-hook.hoon @@ -93,6 +93,27 @@ %run-updates (is-allowed resource.q.update bowl %.y) == :: +++ resource-for-update + |= =vase + ^- (list resource:res) + =/ =update:store !<(update:store vase) + ?- -.q.update + %add-graph ~[resource.q.update] + %remove-graph ~[resource.q.update] + %add-nodes ~[resource.q.update] + %remove-nodes ~[resource.q.update] + %add-signatures ~[resource.uid.q.update] + %remove-signatures ~[resource.uid.q.update] + %archive-graph ~[resource.q.update] + %unarchive-graph ~ + %add-tag ~ + %remove-tag ~ + %keys ~ + %tags ~ + %tag-queries ~ + %run-updates ~[resource.q.update] + == +:: ++ initial-watch |= [=path =resource:res] ^- vase diff --git a/pkg/arvo/app/group-push-hook.hoon b/pkg/arvo/app/group-push-hook.hoon index b4d0d69ca..79d597f08 100644 --- a/pkg/arvo/app/group-push-hook.hoon +++ b/pkg/arvo/app/group-push-hook.hoon @@ -142,6 +142,14 @@ == -- :: +++ resource-for-update + |= =vase + ^- (list resource) + =/ =update:store !<(update:store vase) + ?: ?=(%initial -.update) + ~ + ~[resource.update] +:: ++ take-update |= =vase ^- [(list card) agent] diff --git a/pkg/arvo/app/metadata-push-hook.hoon b/pkg/arvo/app/metadata-push-hook.hoon index 63a726c49..3468651c5 100644 --- a/pkg/arvo/app/metadata-push-hook.hoon +++ b/pkg/arvo/app/metadata-push-hook.hoon @@ -86,6 +86,13 @@ ?~ u.role %.n ?=(?(%admin %moderator) u.u.role) :: +++ resource-for-update + |= =vase + ^- (list resource) + =/ =update:store !<(update:store vase) + ?. ?=(?(%add %remove %initial-group) -.update) ~ + ~[group.update] +:: ++ take-update |= =vase ^- [(list card) agent] diff --git a/pkg/arvo/lib/push-hook.hoon b/pkg/arvo/lib/push-hook.hoon index b36fc5284..2cb7bd705 100644 --- a/pkg/arvo/lib/push-hook.hoon +++ b/pkg/arvo/lib/push-hook.hoon @@ -67,6 +67,16 @@ |* =config $_ ^| |_ bowl:gall + :: + :: +resource-for-update: get affected resources from an update + :: + :: Given a vase of the update, the mark of which is + :: update-mark.config, produce the affected resources, if any. + :: + ++ resource-for-update + |~ vase + *(list resource) + :: :: +take-update: handle update from store :: :: Given an update from the store, do other things after proxying @@ -145,12 +155,12 @@ =* state - ^- agent:gall =< - |_ =bowl:gall +* this . og ~(. push-hook bowl) hc ~(. +> bowl) def ~(. (default-agent this %|) bowl) + :: ++ on-init =^ cards push-hook on-init:og @@ -165,11 +175,9 @@ |^ ?- -.old %1 - =. cards - :_(cards (build-mark:hc %sing)) =^ og-cards push-hook (on-load:og inner-state.old) - [(weld (flop cards) og-cards) this(state old)] + [(weld cards og-cards) this(state old)] :: %0 %_ $ @@ -261,6 +269,7 @@ (push-updates:hc q.cage.sign) cards == + :: ++ on-leave |= =path =^ cards push-hook @@ -269,20 +278,16 @@ :: ++ on-arvo |= [=wire =sign-arvo] - ?. ?=([%helper %push-hook @ *] wire) - =^ cards push-hook - (on-arvo:og wire sign-arvo) - [cards this] - ?. ?=(%resource-conversion i.t.t.wire) - (on-arvo:def wire sign-arvo) - :_ this - ~[(build-mark:hc %next)] + =^ cards push-hook + (on-arvo:og wire sign-arvo) + [cards this] :: ++ on-fail |= [=term =tang] =^ cards push-hook (on-fail:og term tang) [cards this] + :: ++ on-peek |= =path ^- (unit (unit cage)) @@ -311,6 +316,7 @@ %remove (remove +.action) %revoke (revoke +.action) == + :: ++ add |= rid=resource =. sharing @@ -322,7 +328,7 @@ =/ pax=path [%resource (en-path:resource rid)] =/ paths=(set path) - %- sy + %- silt %+ turn (incoming-subscriptions pax) |=([ship pox=path] pox) @@ -344,6 +350,7 @@ ~ `[%give %kick ~[path] `her] -- + :: ++ incoming-subscriptions |= prefix=path ^- (list (pair ship path)) @@ -371,58 +378,50 @@ ++ push-updates |= =vase ^- (list card:agent:gall) - =/ rid=(unit resource) - (resource-for-update vase) - ?~ rid ~ + =/ rids=(list resource) (resource-for-update vase) + =| cards=(list card:agent:gall) + |- + ?~ rids cards =/ prefix=path - resource+(en-path:resource u.rid) + resource+(en-path:resource i.rids) =/ paths=(list path) %~ tap in %- silt %+ turn (incoming-subscriptions prefix) |=([ship pax=path] pax) - ?~ paths ~ - [%give %fact paths update-mark.config vase]~ + ?~ paths $(rids t.rids) + %_ $ + rids t.rids + cards (snoc cards [%give %fact paths update-mark.config vase]) + == :: ++ forward-update - |= update=vase + |= =vase ^- (list card:agent:gall) - =/ rid=resource - (need (resource-for-update update)) + =/ rids=(list resource) (resource-for-update vase) + =| cards=(list card:agent:gall) + |- + ?~ rids cards =/ =path - resource+(en-path:resource rid) + resource+(en-path:resource i.rids) =/ =wire - (make-wire resource+(en-path:resource rid)) + (make-wire resource+(en-path:resource i.rids)) =/ dap=term - ?:(=(our.bowl entity.rid) store-name.config dap.bowl) - [%pass wire %agent [entity.rid dap] %poke update-mark.config update]~ - :: - ++ get-conversion - .^ tube:clay - %cc (scot %p our.bowl) %home (scot %da now.bowl) - /[update-mark.config]/resource + ?:(=(our.bowl entity.i.rids) store-name.config dap.bowl) + %_ $ + rids t.rids + :: + cards + %+ snoc cards + [%pass wire %agent [entity.i.rids dap] %poke update-mark.config vase] == :: ++ resource-for-update - |= update=vase - ^- (unit resource) - =/ converted=(each vase (list tank)) - (mule |.((get-conversion update))) - ?: ?=(%| -.converted) - %- (slog p.converted) - ~ - [~ !<(resource p.converted)] - :: - ++ build-mark - |= rav=?(%sing %next) - ^- card - =/ =wire - (make-wire /resource-conversion) - =/ =mood:clay - [%c da+now.bowl /[update-mark.config]/resource] - =/ =rave:clay - ?:(?=(%next rav) [rav mood] [rav mood]) - [%pass wire %arvo %c %warp our.bowl [%home `rave]] + |= =vase + ^- (list resource) + %~ tap in + %- silt + (resource-for-update:og vase) -- -- diff --git a/pkg/arvo/mar/contact/update.hoon b/pkg/arvo/mar/contact/update.hoon index 87d3f18a5..733d30f48 100644 --- a/pkg/arvo/mar/contact/update.hoon +++ b/pkg/arvo/mar/contact/update.hoon @@ -6,22 +6,6 @@ |% ++ noun upd ++ json (update:enjs upd) - ++ resource - |^ - ?- -.upd - %initial [nobody %contacts] - %add [nobody %contacts] - %remove [nobody %contacts] - %edit [nobody %contacts] - %allow !! - %disallow !! - %set-public !! - == - :: - ++ nobody - ^- @p - (bex 128) - -- -- :: ++ grab diff --git a/pkg/arvo/mar/graph/update.hoon b/pkg/arvo/mar/graph/update.hoon index 405ae76c8..e6766edb5 100644 --- a/pkg/arvo/mar/graph/update.hoon +++ b/pkg/arvo/mar/graph/update.hoon @@ -7,13 +7,6 @@ |% ++ noun upd ++ json (update:enjs upd) - ++ resource - ?+ -.q.upd !! - ?(%run-updates %add-nodes %remove-nodes %add-graph) resource.q.upd - ?(%remove-graph %archive-graph %unarchive-graph) resource.q.upd - ?(%add-tag %remove-tag) resource.q.upd - ?(%add-signatures %remove-signatures) resource.uid.q.upd - == ++ mime [/application/x-urb-graph-update (as-octs (jam upd))] -- :: diff --git a/pkg/arvo/mar/group/update.hoon b/pkg/arvo/mar/group/update.hoon index 62fdc5af2..d4ea2abd9 100644 --- a/pkg/arvo/mar/group/update.hoon +++ b/pkg/arvo/mar/group/update.hoon @@ -4,10 +4,6 @@ ++ grow |% ++ noun upd - ++ resource - ?< ?=(%initial -.upd) - resource.upd - :: ++ json %+ frond:enjs:format 'groupUpdate' (update:enjs upd) diff --git a/pkg/arvo/mar/metadata/update.hoon b/pkg/arvo/mar/metadata/update.hoon index 0c8867018..d9aa1b9c3 100644 --- a/pkg/arvo/mar/metadata/update.hoon +++ b/pkg/arvo/mar/metadata/update.hoon @@ -4,9 +4,6 @@ ++ grow |% ++ noun update - ++ resource - ?> ?=(?(%add %remove %initial-group) -.update) - group.update ++ json (update:enjs:store update) -- :: From c8b83eb1dd1cdd1bbd5868fa81a22c56bf3e4c15 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 1 Feb 2021 15:28:52 -0600 Subject: [PATCH 02/20] contact-push-hook: direct any ship's update to all the affected resources --- pkg/arvo/app/contact-push-hook.hoon | 44 +++++++++++++++++++++-------- pkg/arvo/app/contact-store.hoon | 2 ++ pkg/arvo/lib/group.hoon | 9 ++++++ 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/pkg/arvo/app/contact-push-hook.hoon b/pkg/arvo/app/contact-push-hook.hoon index 6b4ed252a..2025b7a3c 100644 --- a/pkg/arvo/app/contact-push-hook.hoon +++ b/pkg/arvo/app/contact-push-hook.hoon @@ -1,4 +1,5 @@ -/+ store=contact-store, res=resource, contact, default-agent, dbug, push-hook +/+ store=contact-store, res=resource, contact, group, + default-agent, dbug, push-hook ~% %contact-push-hook-top ..part ~ |% +$ card card:agent:gall @@ -22,6 +23,7 @@ +* this . def ~(. (default-agent this %|) bowl) con ~(. contact bowl) + grp ~(. group bowl) :: ++ on-init on-init:def ++ on-save !>(~) @@ -51,17 +53,37 @@ ++ resource-for-update |= =vase ^- (list resource:res) + |^ =/ =update:store !<(update:store vase) - ~ - ::?- -.update - :: %initial !! - :: %add !! - :: %remove !! - :: %edit !! - :: %allow !! - :: %disallow !! - :: %set-public !! - ::== + ?- -.update + %initial ~ + %add (rids-for-ship ship.update) + %remove (rids-for-ship ship.update) + %edit (rids-for-ship ship.update) + %allow ~ + %disallow ~ + %set-public ~ + == + :: + ++ rids-for-ship + |= s=ship + ^- (list resource:res) + :: if the ship is in any group that I am pushing updates for, push + :: it out to that resource. + :: + %+ skim ~(tap in scry-sharing) + |= r=resource:res + (is-member:grp s r) + :: + ++ scry-sharing + .^ (set resource:res) + %gx + (scot %p our.bowl) + %contact-push-hook + (scot %da now.bowl) + /sharing/noun + == + -- :: ++ initial-watch |= [=path =resource:res] diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index c58b73d02..2a8b504fe 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -101,7 +101,9 @@ ++ handle-initial |= [rolo=rolodex:store is-public=?] ^- (quip card _state) + =/ our-contact (~(got by rolodex) our.bowl) =. rolodex (~(uni by rolodex) rolo) + =. rolodex (~(put by rolodex) our.bowl our-contact) :_ state(rolodex rolodex, is-public is-public) (send-diff [%initial rolodex is-public] %.n) :: diff --git a/pkg/arvo/lib/group.hoon b/pkg/arvo/lib/group.hoon index bfd0c975b..d121f86ea 100644 --- a/pkg/arvo/lib/group.hoon +++ b/pkg/arvo/lib/group.hoon @@ -28,6 +28,15 @@ %+ scry-for ,(unit group) `path`groups+(en-path:resource rid) :: +++ scry-groups + .^ ,(set resource) + %gy + (scot %p our.bowl) + %group-store + (scot %da now.bowl) + /groups/noun + == +:: ++ members |= rid=resource =; =group From d6eb1638d992483eedf222d4f85ecb29cdd5222f Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 1 Feb 2021 16:01:23 -0600 Subject: [PATCH 03/20] contact-push-hook: write out initial-watch to expose proper data --- pkg/arvo/app/contact-push-hook.hoon | 19 ++++++++++++++----- pkg/arvo/app/contact-store.hoon | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/arvo/app/contact-push-hook.hoon b/pkg/arvo/app/contact-push-hook.hoon index 2025b7a3c..e2d94abd2 100644 --- a/pkg/arvo/app/contact-push-hook.hoon +++ b/pkg/arvo/app/contact-push-hook.hoon @@ -88,13 +88,22 @@ ++ initial-watch |= [=path =resource:res] ^- vase + |^ ?> (is-allowed:con src.bowl) !> ^- update:store - =/ contact=(unit contact:store) (get-contact:con our.bowl) - :+ %add - our.bowl - ?^ contact u.contact - *contact:store + [%initial rolo %.n] + :: + ++ rolo + ^- rolodex:store + =/ ugroup (scry-group:grp resource) + ?~ ugroup *rolodex:store + %- ~(gas by *rolodex:store) + %+ murn ~(tap in (members:grp resource)) + |= s=ship + ^- (unit [ship contact:store]) + =/ c=(unit contact:store) (get-contact:con s) + ?~(c ~ `[s u.c]) + -- :: ++ take-update |= =vase diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 2a8b504fe..5f04cc865 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -104,7 +104,7 @@ =/ our-contact (~(got by rolodex) our.bowl) =. rolodex (~(uni by rolodex) rolo) =. rolodex (~(put by rolodex) our.bowl our-contact) - :_ state(rolodex rolodex, is-public is-public) + :_ state(rolodex rolodex) (send-diff [%initial rolodex is-public] %.n) :: ++ handle-add From e1b1e1abf7fa6b2f9b4679640fb238e4a6b48e8a Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 1 Feb 2021 16:19:25 -0600 Subject: [PATCH 04/20] group-threads: contact push/pull hooks added to group lifecycle --- pkg/arvo/ted/group/create.hoon | 1 + pkg/arvo/ted/group/delete.hoon | 1 + pkg/arvo/ted/group/leave.hoon | 1 + 3 files changed, 3 insertions(+) diff --git a/pkg/arvo/ted/group/create.hoon b/pkg/arvo/ted/group/create.hoon index 4185eeb38..1b7da9b83 100644 --- a/pkg/arvo/ted/group/create.hoon +++ b/pkg/arvo/ted/group/create.hoon @@ -45,6 +45,7 @@ [%add rid groups+rid metadatum] ;< ~ bind:m (poke-our %metadata-store %metadata-action !>(met-action)) ;< ~ bind:m (poke-our %metadata-push-hook push-hook-act) +;< ~ bind:m (poke-our %contact-push-hook push-hook-act) (pure:m !>(~)) diff --git a/pkg/arvo/ted/group/delete.hoon b/pkg/arvo/ted/group/delete.hoon index 3c9d1e924..08525780d 100644 --- a/pkg/arvo/ted/group/delete.hoon +++ b/pkg/arvo/ted/group/delete.hoon @@ -26,5 +26,6 @@ ;< ~ bind:m (cleanup-md:view rid) ;< ~ bind:m (poke-our %group-store %group-update !>([%remove-group rid ~])) ;< ~ bind:m (poke-our %metadata-push-hook push-hook-act) +;< ~ bind:m (poke-our %contact-push-hook push-hook-act) ;< ~ bind:m (poke-our %group-push-hook push-hook-act) (pure:m !>(~)) diff --git a/pkg/arvo/ted/group/leave.hoon b/pkg/arvo/ted/group/leave.hoon index ec4da0555..65ea051cb 100644 --- a/pkg/arvo/ted/group/leave.hoon +++ b/pkg/arvo/ted/group/leave.hoon @@ -22,6 +22,7 @@ :- %pull-hook-action !> ^- action:pull-hook [%remove rid] +;< ~ bind:m (poke-our %contact-pull-hook pull-hook-act) ;< ~ bind:m (poke-our %metadata-pull-hook pull-hook-act) ;< ~ bind:m (poke-our %group-pull-hook pull-hook-act) ;< ~ bind:m (poke-our %group-store %group-update !>([%remove-group rid ~])) From d3ac83de0eddbdfe8deebb41d7f6a11f737026a0 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 1 Feb 2021 16:21:18 -0600 Subject: [PATCH 05/20] contact-pull-hook: do not remove contact data upon nack --- pkg/arvo/app/contact-pull-hook.hoon | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/arvo/app/contact-pull-hook.hoon b/pkg/arvo/app/contact-pull-hook.hoon index 9d66a20c1..eb354509c 100644 --- a/pkg/arvo/app/contact-pull-hook.hoon +++ b/pkg/arvo/app/contact-pull-hook.hoon @@ -35,11 +35,7 @@ ++ on-pull-nack |= [=resource =tang] ^- (quip card _this) - :_ this - ?~ (get-contact:con entity.resource) ~ - =- [%pass /pl-nack %agent [our.bowl %contact-store] %poke %contact-update -]~ - !> ^- update:store - [%remove entity.resource] + [~ this] :: ++ on-pull-kick |=(=resource `/) -- From 48d9e8c9b834ad19d50b18e59651210918bc9949 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 1 Feb 2021 16:36:16 -0600 Subject: [PATCH 06/20] group-view: initiate %contact-pull-hook subscription upon group join --- pkg/arvo/app/group-view.hoon | 26 ++++++++++++++++---------- pkg/arvo/lib/hood/drum.hoon | 2 -- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pkg/arvo/app/group-view.hoon b/pkg/arvo/app/group-view.hoon index 2cebb3eb5..43c2f62a5 100644 --- a/pkg/arvo/app/group-view.hoon +++ b/pkg/arvo/app/group-view.hoon @@ -69,9 +69,7 @@ [cards this] :: ++ on-arvo on-arvo:def -:: ++ on-leave on-leave:def -:: ++ on-fail on-fail:def -- |_ =bowl:gall @@ -86,6 +84,7 @@ ++ emit-many |= crds=(list card) jn-core(cards (weld (flop crds) cards)) + :: ++ emit |= =card jn-core(cards [card cards]) @@ -152,43 +151,50 @@ %+ poke-our:(jn-pass-io /pull-groups) %group-pull-hook pull-hook-action+!>([%add ship rid]) (tx-progress %added) - :: + :: %pull-groups ?> ?=(%poke-ack -.sign) (ack +.sign) - :: + :: %groups ?+ -.sign !! %fact (groups-fact +.sign) %watch-ack (ack +.sign) %kick watch-groups == - :: + :: %pull-md ?> ?=(%poke-ack -.sign) (ack +.sign) - :: + :: + %pull-co + ?> ?=(%poke-ack -.sign) + (ack +.sign) + :: %md ?+ -.sign !! %fact (md-fact +.sign) %watch-ack (ack +.sign) %kick watch-md == - :: + :: %pull-graphs ?> ?=(%poke-ack -.sign) %- cleanup ?^(p.sign %strange %done) == + :: ++ groups-fact |= =cage ?. ?=(%group-update p.cage) jn-core =+ !<(=update:group-store q.cage) ?. ?=(%initial-group -.update) jn-core ?. =(rid resource.update) jn-core - %- emit - %+ poke-our:(jn-pass-io /pull-md) %metadata-pull-hook - pull-hook-action+!>([%add [entity .]:rid]) + %- emit-many + =/ cag=^cage pull-hook-action+!>([%add [entity .]:rid]) + :~ (poke-our:(jn-pass-io /pull-md) %metadata-pull-hook cag) + (poke-our:(jn-pass-io /pull-co) %contact-pull-hook cag) + == :: ++ md-fact |= [=mark =vase] diff --git a/pkg/arvo/lib/hood/drum.hoon b/pkg/arvo/lib/hood/drum.hoon index 96c377b66..a7327cc22 100644 --- a/pkg/arvo/lib/hood/drum.hoon +++ b/pkg/arvo/lib/hood/drum.hoon @@ -90,10 +90,8 @@ %chat-cli %herm %contact-store - %contact-hook %contact-push-hook %contact-pull-hook - %contact-view %metadata-store %s3-store %file-server From da03594fbca195f5ba3da55c702323e36b8a1f4b Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Mon, 1 Feb 2021 18:24:56 -0600 Subject: [PATCH 07/20] contact-push-hook: add blank personal psuedo-resource for personal contact subscriptions --- pkg/arvo/app/contact-push-hook.hoon | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/arvo/app/contact-push-hook.hoon b/pkg/arvo/app/contact-push-hook.hoon index e2d94abd2..67d6e3093 100644 --- a/pkg/arvo/app/contact-push-hook.hoon +++ b/pkg/arvo/app/contact-push-hook.hoon @@ -71,9 +71,13 @@ :: if the ship is in any group that I am pushing updates for, push :: it out to that resource. :: - %+ skim ~(tap in scry-sharing) - |= r=resource:res - (is-member:grp s r) + =/ rids + %+ skim ~(tap in scry-sharing) + |= r=resource:res + (is-member:grp s r) + ?. =(s our.bowl) + rids + (snoc rids [our.bowl %'']) :: ++ scry-sharing .^ (set resource:res) @@ -96,8 +100,12 @@ ++ rolo ^- rolodex:store =/ ugroup (scry-group:grp resource) - ?~ ugroup *rolodex:store %- ~(gas by *rolodex:store) + ?~ ugroup + =/ c=(unit contact:store) (get-contact:con our.bowl) + ?~ c + [our.bowl *contact:store]~ + [our.bowl u.c]~ %+ murn ~(tap in (members:grp resource)) |= s=ship ^- (unit [ship contact:store]) From 66c8cafe75e0bb3fc59b20a59f246e8564928e7c Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 2 Feb 2021 14:27:12 +1000 Subject: [PATCH 08/20] pull-hook: move +resource-for-update back into door, add %no-validate flag Adds %no-validate flag, to prevent checking the wire/src.bowl/resource all match-up to enable P2P connections. Moves the resource-for-update back into the inner door, to match the push-hook. --- pkg/arvo/lib/pull-hook.hoon | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/pkg/arvo/lib/pull-hook.hoon b/pkg/arvo/lib/pull-hook.hoon index 55c48b233..5b7c8289d 100644 --- a/pkg/arvo/lib/pull-hook.hoon +++ b/pkg/arvo/lib/pull-hook.hoon @@ -30,12 +30,15 @@ :: .store-name: name of the store to send subscription updates to. :: .update-mark: mark that updates will be tagged with :: .push-hook-name: name of the corresponding push-hook +:: .no-validate: If true, don't validate that resource/wire/src match +:: up :: +$ config $: store-name=term update=mold update-mark=term push-hook-name=term + no-validate=_| == :: :: $base-state-0: state for the pull hook @@ -106,6 +109,14 @@ ++ on-pull-kick |~ resource *(unit path) + :: +resource-for-update: get resources from vase + :: + :: This should be identical to the +resource-for-update arm in the + :: corresponding push-hook + :: + ++ resource-for-update + |~ vase + *(list resource) :: :: from agent:gall ++ on-init @@ -470,24 +481,30 @@ /helper/pull-hook wire :: - ++ get-conversion - .^ tube:clay - %cc (scot %p our.bowl) %home (scot %da now.bowl) - /[update-mark.config]/resource - == - :: ++ give-update ^- card [%give %fact ~[/tracking] %pull-hook-update !>(tracking)] :: + ++ check-src + |= resources=(set resource) + ^- ? + %+ roll ~(tap in resources) + |= [rid=resource out=_|] + ?: out %.y + ?~ ship=(~(get by tracking) rid) + %.n + =(src.bowl u.ship) + :: ++ update-store |= [wire-rid=resource =vase] ^- card =/ =wire (make-wire /store) - =+ !<(rid=resource (get-conversion vase)) - ?> =(src.bowl (~(got by tracking) rid)) - ?> =(wire-rid rid) + =+ resources=(~(gas in *(set resource)) (resource-for-update:og vase)) + ?> ?| no-validate.config + ?& (check-src resources) + (~(has in resources) wire-rid) + == == [%pass wire %agent [our.bowl store-name.config] %poke update-mark.config vase] -- -- From 638d5e67733f9029ac1c703a3f2002b0a296e8c0 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 2 Feb 2021 14:30:12 +1000 Subject: [PATCH 09/20] contact-hooks: move +resource-for-update into common library --- pkg/arvo/app/contact-pull-hook.hoon | 2 ++ pkg/arvo/app/contact-push-hook.hoon | 40 +-------------------------- pkg/arvo/lib/contact.hoon | 42 ++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 40 deletions(-) diff --git a/pkg/arvo/app/contact-pull-hook.hoon b/pkg/arvo/app/contact-pull-hook.hoon index eb354509c..4ca07a365 100644 --- a/pkg/arvo/app/contact-pull-hook.hoon +++ b/pkg/arvo/app/contact-pull-hook.hoon @@ -9,6 +9,7 @@ update:store %contact-update %contact-push-hook + %.y :: necessary to enable p2p == -- :: @@ -32,6 +33,7 @@ ++ on-agent on-agent:def ++ on-watch on-watch:def ++ on-leave on-leave:def +++ resource-for-update resource-for-update:con ++ on-pull-nack |= [=resource =tang] ^- (quip card _this) diff --git a/pkg/arvo/app/contact-push-hook.hoon b/pkg/arvo/app/contact-push-hook.hoon index 67d6e3093..d1c08a1b7 100644 --- a/pkg/arvo/app/contact-push-hook.hoon +++ b/pkg/arvo/app/contact-push-hook.hoon @@ -49,45 +49,7 @@ %disallow %.n %set-public %.n == -:: -++ resource-for-update - |= =vase - ^- (list resource:res) - |^ - =/ =update:store !<(update:store vase) - ?- -.update - %initial ~ - %add (rids-for-ship ship.update) - %remove (rids-for-ship ship.update) - %edit (rids-for-ship ship.update) - %allow ~ - %disallow ~ - %set-public ~ - == - :: - ++ rids-for-ship - |= s=ship - ^- (list resource:res) - :: if the ship is in any group that I am pushing updates for, push - :: it out to that resource. - :: - =/ rids - %+ skim ~(tap in scry-sharing) - |= r=resource:res - (is-member:grp s r) - ?. =(s our.bowl) - rids - (snoc rids [our.bowl %'']) - :: - ++ scry-sharing - .^ (set resource:res) - %gx - (scot %p our.bowl) - %contact-push-hook - (scot %da now.bowl) - /sharing/noun - == - -- +++ resource-for-update resource-for-update:con :: ++ initial-watch |= [=path =resource:res] diff --git a/pkg/arvo/lib/contact.hoon b/pkg/arvo/lib/contact.hoon index 449478e12..baab9e6ff 100644 --- a/pkg/arvo/lib/contact.hoon +++ b/pkg/arvo/lib/contact.hoon @@ -1,6 +1,7 @@ /- store=contact-store, *resource -/+ group +/+ group, grpl=group |_ =bowl:gall ++* grp ~(. grpl bowl) ++ scry-for |* [=mold =path] .^ mold @@ -11,6 +12,45 @@ (snoc `^path`path %noun) == :: +++ resource-for-update + |= =vase + ^- (list resource) + |^ + =/ =update:store !<(update:store vase) + ?- -.update + %initial ~ + %add (rids-for-ship ship.update) + %remove (rids-for-ship ship.update) + %edit (rids-for-ship ship.update) + %allow ~ + %disallow ~ + %set-public ~ + == + :: + ++ rids-for-ship + |= s=ship + ^- (list resource) + :: if the ship is in any group that I am pushing updates for, push + :: it out to that resource. + :: + =/ rids + %+ skim ~(tap in scry-sharing) + |= r=resource + (is-member:grp s r) + ?. =(s our.bowl) + rids + (snoc rids [our.bowl %'']) + :: + ++ scry-sharing + .^ (set resource) + %gx + (scot %p our.bowl) + %contact-push-hook + (scot %da now.bowl) + /sharing/noun + == + -- +:: ++ get-contact |= =ship ^- (unit contact:store) From 8672261d1a61a98ae462be25955d164bc1531221 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 2 Feb 2021 14:30:48 +1000 Subject: [PATCH 10/20] graph-hooks: move +resource-for-update into common library --- pkg/arvo/app/graph-pull-hook.hoon | 3 +++ pkg/arvo/app/graph-push-hook.hoon | 22 +--------------------- pkg/arvo/lib/graph.hoon | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/pkg/arvo/app/graph-pull-hook.hoon b/pkg/arvo/app/graph-pull-hook.hoon index ee7d73796..01ca5e8f1 100644 --- a/pkg/arvo/app/graph-pull-hook.hoon +++ b/pkg/arvo/app/graph-pull-hook.hoon @@ -9,6 +9,7 @@ update:store %graph-update %graph-push-hook + %.n == -- :: @@ -48,4 +49,6 @@ =/ maybe-time (peek-update-log:gra resource) ?~ maybe-time `/ `/(scot %da u.maybe-time) +:: +++ resource-for-update resource-for-update:gra -- diff --git a/pkg/arvo/app/graph-push-hook.hoon b/pkg/arvo/app/graph-push-hook.hoon index bc4743af1..d685e3dec 100644 --- a/pkg/arvo/app/graph-push-hook.hoon +++ b/pkg/arvo/app/graph-push-hook.hoon @@ -92,27 +92,7 @@ %tag-queries %.n %run-updates (is-allowed resource.q.update bowl %.y) == -:: -++ resource-for-update - |= =vase - ^- (list resource:res) - =/ =update:store !<(update:store vase) - ?- -.q.update - %add-graph ~[resource.q.update] - %remove-graph ~[resource.q.update] - %add-nodes ~[resource.q.update] - %remove-nodes ~[resource.q.update] - %add-signatures ~[resource.uid.q.update] - %remove-signatures ~[resource.uid.q.update] - %archive-graph ~[resource.q.update] - %unarchive-graph ~ - %add-tag ~ - %remove-tag ~ - %keys ~ - %tags ~ - %tag-queries ~ - %run-updates ~[resource.q.update] - == +++ resource-for-update resource-for-update:gra :: ++ initial-watch |= [=path =resource:res] diff --git a/pkg/arvo/lib/graph.hoon b/pkg/arvo/lib/graph.hoon index 6d78a206f..3c71c20a7 100644 --- a/pkg/arvo/lib/graph.hoon +++ b/pkg/arvo/lib/graph.hoon @@ -11,6 +11,27 @@ (snoc `^path`path %noun) == :: +++ resource-for-update + |= =vase + ^- (list resource) + =/ =update:store !<(update:store vase) + ?- -.q.update + %add-graph ~[resource.q.update] + %remove-graph ~[resource.q.update] + %add-nodes ~[resource.q.update] + %remove-nodes ~[resource.q.update] + %add-signatures ~[resource.uid.q.update] + %remove-signatures ~[resource.uid.q.update] + %archive-graph ~[resource.q.update] + %unarchive-graph ~ + %add-tag ~ + %remove-tag ~ + %keys ~ + %tags ~ + %tag-queries ~ + %run-updates ~[resource.q.update] + == +:: ++ get-graph |= res=resource ^- update:store From b3c01981777933e0759f2c2fc7c89a914e9bbbdd Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 2 Feb 2021 14:31:16 +1000 Subject: [PATCH 11/20] group-hooks: move +resource-for-update into common library --- pkg/arvo/app/group-pull-hook.hoon | 5 +++++ pkg/arvo/app/group-push-hook.hoon | 9 +-------- pkg/arvo/lib/group.hoon | 9 +++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/app/group-pull-hook.hoon b/pkg/arvo/app/group-pull-hook.hoon index 9141c8e82..5bc8208d8 100644 --- a/pkg/arvo/app/group-pull-hook.hoon +++ b/pkg/arvo/app/group-pull-hook.hoon @@ -14,6 +14,7 @@ update:store %group-update %group-push-hook + %.n == :: -- @@ -28,6 +29,7 @@ +* this . def ~(. (default-agent this %|) bowl) dep ~(. (default:pull-hook this config) bowl) + grp ~(. grpl bowl) :: ++ on-init on-init:def ++ on-save !>(~) @@ -45,8 +47,11 @@ :_ this =- [%pass / %agent [our.bowl %group-store] %poke -]~ group-update+!>([%remove-group resource ~]) +:: ++ on-pull-kick |= =resource ^- (unit path) `/ +:: +++ resource-for-update resource-for-update:grp -- diff --git a/pkg/arvo/app/group-push-hook.hoon b/pkg/arvo/app/group-push-hook.hoon index 79d597f08..5924db566 100644 --- a/pkg/arvo/app/group-push-hook.hoon +++ b/pkg/arvo/app/group-push-hook.hoon @@ -141,14 +141,7 @@ =(~(tap in ships.update) ~[src.bowl]) == -- -:: -++ resource-for-update - |= =vase - ^- (list resource) - =/ =update:store !<(update:store vase) - ?: ?=(%initial -.update) - ~ - ~[resource.update] +++ resource-for-update resource-for-update:grp :: ++ take-update |= =vase diff --git a/pkg/arvo/lib/group.hoon b/pkg/arvo/lib/group.hoon index d121f86ea..dc4041805 100644 --- a/pkg/arvo/lib/group.hoon +++ b/pkg/arvo/lib/group.hoon @@ -3,6 +3,15 @@ :: |_ =bowl:gall +$ card card:agent:gall +:: +++ resource-for-update + |= =vase + ^- (list resource) + =/ =update:store !<(update:store vase) + ?: ?=(%initial -.update) + ~ + ~[resource.update] +:: ++ scry-for |* [=mold =path] =. path From 3dcd6395accddda2455cd2ec7591bbb8435fe0de Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 2 Feb 2021 14:31:35 +1000 Subject: [PATCH 12/20] metadata-hooks: move +resource-for-update to common library --- pkg/arvo/app/metadata-pull-hook.hoon | 2 ++ pkg/arvo/app/metadata-push-hook.hoon | 8 +------- pkg/arvo/lib/metadata.hoon | 7 +++++++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/arvo/app/metadata-pull-hook.hoon b/pkg/arvo/app/metadata-pull-hook.hoon index 227a84dbf..1b638b9d7 100644 --- a/pkg/arvo/app/metadata-pull-hook.hoon +++ b/pkg/arvo/app/metadata-pull-hook.hoon @@ -15,6 +15,7 @@ update:metadata %metadata-update %metadata-push-hook + %.n == +$ state-zero [%0 previews=(map resource group-preview:metadata)] @@ -126,6 +127,7 @@ ++ on-arvo on-arvo:def :: ++ on-fail on-fail:def +++ resource-for-update resource-for-update:met ++ on-pull-nack |= [=resource =tang] ^- (quip card _this) diff --git a/pkg/arvo/app/metadata-push-hook.hoon b/pkg/arvo/app/metadata-push-hook.hoon index 3468651c5..a2d5f3c13 100644 --- a/pkg/arvo/app/metadata-push-hook.hoon +++ b/pkg/arvo/app/metadata-push-hook.hoon @@ -86,13 +86,7 @@ ?~ u.role %.n ?=(?(%admin %moderator) u.u.role) :: -++ resource-for-update - |= =vase - ^- (list resource) - =/ =update:store !<(update:store vase) - ?. ?=(?(%add %remove %initial-group) -.update) ~ - ~[group.update] -:: +++ resource-for-update resource-for-update:met ++ take-update |= =vase ^- [(list card) agent] diff --git a/pkg/arvo/lib/metadata.hoon b/pkg/arvo/lib/metadata.hoon index b8eb1285c..8e5aa8f9f 100644 --- a/pkg/arvo/lib/metadata.hoon +++ b/pkg/arvo/lib/metadata.hoon @@ -4,6 +4,13 @@ /+ resource :: |_ =bowl:gall +++ resource-for-update + |= =vase + ^- (list resource) + =/ =update:store !<(update:store vase) + ?. ?=(?(%add %remove %initial-group) -.update) ~ + ~[group.update] +:: ++ app-paths-from-group |= [=app-name:store group=resource] ^- (list resource) From 9f9cfc086c65553bd7ae4b1ef8aba91ab612de9c Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 2 Feb 2021 15:35:29 +1000 Subject: [PATCH 13/20] lib/contact: fix +is-allowed, +get-contact --- pkg/arvo/app/contact-push-hook.hoon | 2 +- pkg/arvo/lib/contact.hoon | 32 +++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/pkg/arvo/app/contact-push-hook.hoon b/pkg/arvo/app/contact-push-hook.hoon index d1c08a1b7..cd741187a 100644 --- a/pkg/arvo/app/contact-push-hook.hoon +++ b/pkg/arvo/app/contact-push-hook.hoon @@ -55,7 +55,7 @@ |= [=path =resource:res] ^- vase |^ - ?> (is-allowed:con src.bowl) + ?> (is-allowed:con resource src.bowl) !> ^- update:store [%initial rolo %.n] :: diff --git a/pkg/arvo/lib/contact.hoon b/pkg/arvo/lib/contact.hoon index baab9e6ff..ebd9674ec 100644 --- a/pkg/arvo/lib/contact.hoon +++ b/pkg/arvo/lib/contact.hoon @@ -40,32 +40,34 @@ ?. =(s our.bowl) rids (snoc rids [our.bowl %'']) - :: - ++ scry-sharing - .^ (set resource) - %gx - (scot %p our.bowl) - %contact-push-hook - (scot %da now.bowl) - /sharing/noun - == -- +++ scry-sharing + .^ (set resource) + %gx + (scot %p our.bowl) + %contact-push-hook + (scot %da now.bowl) + /sharing/noun + == :: ++ get-contact |= =ship ^- (unit contact:store) - =/ upd (scry-for (unit update:store) /contact/(scot %p ship)) - ?~ upd ~ - ?> ?=(%add -.u.upd) - `contact.u.upd + =/ =rolodex:store + (scry-for rolodex:store /all) + (~(get by rolodex) ship) :: ++ is-allowed - |= =ship + |= [rid=resource =ship] ^- ? + =/ grp ~(. group bowl) =/ shp (scry-for ? /allowed-ship/(scot %p ship)) ?: shp %.y + ?: ?& (~(has in scry-sharing) rid) + (~(has in (members:grp rid)) ship) + == + %.y =/ allowed-groups ~(tap in (scry-for (set resource) /allowed-groups)) - =/ grp ~(. group bowl) |- ?~ allowed-groups %.n ?: (~(has in (members:grp i.allowed-groups)) ship) From de3b350efbea640d15201c135606a439cb5e4a16 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 2 Feb 2021 13:36:05 -0600 Subject: [PATCH 14/20] contacts + group-view: added in flow for auto-sharing your profile with a group if it is public --- pkg/arvo/app/contact-push-hook.hoon | 22 +++++++++++++++++++++- pkg/arvo/app/contact-store.hoon | 3 +++ pkg/arvo/app/group-view.hoon | 17 ++++++++++++++--- pkg/arvo/lib/contact.hoon | 13 +++++++++++++ pkg/arvo/mar/contact/share.hoon | 12 ++++++++++++ 5 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 pkg/arvo/mar/contact/share.hoon diff --git a/pkg/arvo/app/contact-push-hook.hoon b/pkg/arvo/app/contact-push-hook.hoon index cd741187a..e6e10075d 100644 --- a/pkg/arvo/app/contact-push-hook.hoon +++ b/pkg/arvo/app/contact-push-hook.hoon @@ -1,3 +1,4 @@ +/- pull-hook /+ store=contact-store, res=resource, contact, group, default-agent, dbug, push-hook ~% %contact-push-hook-top ..part ~ @@ -13,6 +14,8 @@ == :: +$ agent (push-hook:push-hook config) +:: ++$ share [%share =ship] -- :: %- agent:dbug @@ -28,7 +31,23 @@ ++ on-init on-init:def ++ on-save !>(~) ++ on-load on-load:def -++ on-poke on-poke:def +++ on-poke + |= [=mark =vase] + ^- (quip card _this) + ?. =(mark %contact-share) (on-poke:def mark vase) + =/ =share !<(share vase) + ?> =(src.bowl ship.share) + :_ this :_ ~ + :* %pass + /(scot %p src.bowl)/share + %agent + [our.bowl %contact-pull-hook] + %poke + %pull-hook-action + !> ^- action:pull-hook + [%add ship.share [ship.share %'']] + == +:: ++ on-agent on-agent:def ++ on-watch on-watch:def ++ on-leave on-leave:def @@ -49,6 +68,7 @@ %disallow %.n %set-public %.n == +:: ++ resource-for-update resource-for-update:con :: ++ initial-watch diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 5f04cc865..1d7969d16 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -210,6 +210,9 @@ [%x %allowed-ship @ ~] =/ =ship (slav %p i.t.t.path) ``noun+!>((~(has in allowed-ships) ship)) + :: + [%x %is-public ~] + ``noun+!>(is-public) :: [%x %allowed-groups ~] ``noun+!>(allowed-groups) diff --git a/pkg/arvo/app/group-view.hoon b/pkg/arvo/app/group-view.hoon index 43c2f62a5..61664f60f 100644 --- a/pkg/arvo/app/group-view.hoon +++ b/pkg/arvo/app/group-view.hoon @@ -1,5 +1,6 @@ /- view-sur=group-view, group-store, *group, metadata=metadata-store -/+ default-agent, agentio, mdl=metadata, resource, dbug, grpl=group, verb +/+ default-agent, agentio, mdl=metadata, + resource, dbug, grpl=group, con=contact, verb |% ++ card card:agent:gall +$ state-zero @@ -170,6 +171,10 @@ %pull-co ?> ?=(%poke-ack -.sign) (ack +.sign) + :: + %share-co + ?> ?=(%poke-ack -.sign) + (ack +.sign) :: %md ?+ -.sign !! @@ -192,8 +197,14 @@ ?. =(rid resource.update) jn-core %- emit-many =/ cag=^cage pull-hook-action+!>([%add [entity .]:rid]) - :~ (poke-our:(jn-pass-io /pull-md) %metadata-pull-hook cag) - (poke-our:(jn-pass-io /pull-co) %contact-pull-hook cag) + %- zing + :~ [(poke-our:(jn-pass-io /pull-md) %metadata-pull-hook cag)]~ + [(poke-our:(jn-pass-io /pull-co) %contact-pull-hook cag)]~ + ?. scry-is-public:con ~ + :_ ~ + %+ poke:(jn-pass-io /share-co) + [entity.rid %contact-push-hook] + [%contact-share !>([%share our.bowl])] == :: ++ md-fact diff --git a/pkg/arvo/lib/contact.hoon b/pkg/arvo/lib/contact.hoon index ebd9674ec..39bb0a621 100644 --- a/pkg/arvo/lib/contact.hoon +++ b/pkg/arvo/lib/contact.hoon @@ -57,11 +57,24 @@ (scry-for rolodex:store /all) (~(get by rolodex) ship) :: +++ scry-is-public + .^ ? + %gx + (scot %p our.bowl) + %contact-store + (scot %da now.bowl) + /is-public/noun + == +:: ++ is-allowed |= [rid=resource =ship] ^- ? =/ grp ~(. group bowl) =/ shp (scry-for ? /allowed-ship/(scot %p ship)) + ?: ?& scry-is-public + =(rid [our.bowl %'']) + == + %.y ?: shp %.y ?: ?& (~(has in scry-sharing) rid) (~(has in (members:grp rid)) ship) diff --git a/pkg/arvo/mar/contact/share.hoon b/pkg/arvo/mar/contact/share.hoon new file mode 100644 index 000000000..15b534f01 --- /dev/null +++ b/pkg/arvo/mar/contact/share.hoon @@ -0,0 +1,12 @@ +|_ share=[%share =ship] +++ grad %noun +++ grow + |% + ++ noun share + -- +:: +++ grab + |% + ++ noun share + -- +-- From 992562a128e6d1e49108ec3fd15ed9518a208284 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 2 Feb 2021 13:47:53 -0600 Subject: [PATCH 15/20] contact-push-hook: add our pseudoresource to sharing --- pkg/arvo/app/contact-push-hook.hoon | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/arvo/app/contact-push-hook.hoon b/pkg/arvo/app/contact-push-hook.hoon index e6e10075d..08fdb2881 100644 --- a/pkg/arvo/app/contact-push-hook.hoon +++ b/pkg/arvo/app/contact-push-hook.hoon @@ -28,7 +28,13 @@ con ~(. contact bowl) grp ~(. group bowl) :: -++ on-init on-init:def +++ on-init + ^- (quip card _this) + :_ this :_ ~ + =- [%pass /us %agent [our.bowl %contact-push-hook] %poke %push-hook-action -] + !> ^- action:push-hook + [%add [our.bowl %'']] +:: ++ on-save !>(~) ++ on-load on-load:def ++ on-poke From b51eee2882be64ec6b39175c052ae232cd56f3d6 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 2 Feb 2021 13:50:58 -0600 Subject: [PATCH 16/20] interface: removed deprecated ContactCard --- .../apps/profile/components/ContactCard.tsx | 167 ------------------ 1 file changed, 167 deletions(-) delete mode 100644 pkg/interface/src/views/apps/profile/components/ContactCard.tsx diff --git a/pkg/interface/src/views/apps/profile/components/ContactCard.tsx b/pkg/interface/src/views/apps/profile/components/ContactCard.tsx deleted file mode 100644 index b7fe89e29..000000000 --- a/pkg/interface/src/views/apps/profile/components/ContactCard.tsx +++ /dev/null @@ -1,167 +0,0 @@ -import React from "react"; -import { Sigil } from "~/logic/lib/sigil"; -import * as Yup from "yup"; - -import { uxToHex } from "~/logic/lib/util"; -import { - ManagedForm as Form, - Col, - ManagedTextInputField as Input, - Box, - Text, - Row, - BaseImage -} from "@tlon/indigo-react"; -import { Formik, FormikHelpers } from "formik"; -import { Contact } from "~/types/contact-update"; -import { AsyncButton } from "~/views/components/AsyncButton"; -import { ColorInput } from "~/views/components/ColorInput"; -import GlobalApi from "~/logic/api/global"; -import { ImageInput } from "~/views/components/ImageInput"; -import { S3State } from "~/types"; -import useLocalState from "~/logic/state/local"; - -interface ContactCardProps { - contact: Contact; - path: string; - api: GlobalApi; - s3: S3State; - rootIdentity: Contact; -} - -const formSchema = Yup.object({ - color: Yup.string(), - nickname: Yup.string(), - email: Yup.string().matches( - new RegExp( - String( - /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*/.source - ) + - /@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/ - .source - ), - "Not a valid email" - ), - phone: Yup.string().matches( - new RegExp( - String(/^\s*(?:\+?(\d{1,3}))?/.source) + - /([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$/ - .source - ), - "Not a valid phone" - ), - - website: Yup.string().matches( - new RegExp( - String(/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}/.source) + - /\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/.source - ), - "Not a valid website" - ), -}); - -const emptyContact = { - avatar: null, - color: '0', - nickname: '', - email: '', - phone: '', - website: '', - notes: '' -}; - -export function ContactCard(props: ContactCardProps) { - const { hideAvatars, hideNicknames } = useLocalState(({ hideAvatars, hideNicknames }) => ({ - hideAvatars, hideNicknames - })); - const us = `~${window.ship}`; - const { contact, rootIdentity } = props; - const onSubmit = async (values: any, actions: FormikHelpers) => { - try { - if(!contact) { - const [,,ship] = props.path.split('/'); - values.color = uxToHex(values.color); - const sharedValues = Object.assign({}, values); - sharedValues.avatar = !values.avatar ? null : { url: values.avatar }; - console.log(values); - await props.api.contacts.share(ship, props.path, us, sharedValues); - actions.setStatus({ success: null }); - return; - } - - await Object.keys(values).reduce((acc, key) => { - const newValue = key !== "color" ? values[key] : uxToHex(values[key]); - if (newValue !== contact[key]) { - if (key === "avatar") { - return acc.then(() => - props.api.contacts.edit(props.path, us, { - avatar: { url: newValue }, - } as any) - ); - } - - return acc.then(() => - props.api.contacts.edit(props.path, us, { - [key]: newValue, - } as any) - ); - } - return acc; - }, Promise.resolve()); - actions.setStatus({ success: null }); - } catch (e) { - console.error(e); - actions.setStatus({ error: e.message }); - } - }; - - const hexColor = contact?.color ? `#${uxToHex(contact.color)}` : "#000000"; - const image = (!hideAvatars && contact?.avatar) - ? - : ; - - const nickname = (!hideNicknames && contact?.nickname) ? contact.nickname : ""; - - return ( - - -
- - - {image} - - - {nickname} - - - - - - - - - - - {(contact) ? "Save" : "Share Contact"} - - -
-
- ); -} From a728514aa5f072c78562dac9393ab1778bbdcb2f Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 2 Feb 2021 17:04:28 -0600 Subject: [PATCH 17/20] contact: improved +is-allowed and added %contact-share mark --- pkg/arvo/app/contact-store.hoon | 9 ++++++++- pkg/arvo/lib/contact-store.hoon | 6 ++++++ pkg/arvo/lib/contact.hoon | 29 +++++++++++++++-------------- pkg/arvo/mar/contact/share.hoon | 3 +++ 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 1d7969d16..027b54fc4 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -3,7 +3,7 @@ :: data store that holds individual contact data :: /- store=contact-store, *resource -/+ default-agent, dbug, *migrate +/+ default-agent, dbug, *migrate, contact |% +$ card card:agent:gall +$ state-4 @@ -29,6 +29,7 @@ |_ =bowl:gall +* this . def ~(. (default-agent this %|) bowl) + con ~(. contact bowl) :: ++ on-init =. rolodex (~(put by rolodex) our.bowl *contact:store) @@ -216,6 +217,12 @@ :: [%x %allowed-groups ~] ``noun+!>(allowed-groups) + + :: + [%x %is-allowed @ ~] + =/ =ship (slav %p i.t.t.path) + ~& ship + ``json+!>(`json`b+(is-allowed:con [our.bowl %''] ship)) == :: ++ on-leave on-leave:def diff --git a/pkg/arvo/lib/contact-store.hoon b/pkg/arvo/lib/contact-store.hoon index 18efaa09f..af70ed022 100644 --- a/pkg/arvo/lib/contact-store.hoon +++ b/pkg/arvo/lib/contact-store.hoon @@ -173,4 +173,10 @@ == -- -- +:: +++ share-dejs + =, dejs:format + |% + ++ share (ot [%share (su ;~(pfix sig fed:ag))]~) + -- -- diff --git a/pkg/arvo/lib/contact.hoon b/pkg/arvo/lib/contact.hoon index 39bb0a621..cf25eab16 100644 --- a/pkg/arvo/lib/contact.hoon +++ b/pkg/arvo/lib/contact.hoon @@ -70,20 +70,21 @@ |= [rid=resource =ship] ^- ? =/ grp ~(. group bowl) - =/ shp (scry-for ? /allowed-ship/(scot %p ship)) - ?: ?& scry-is-public - =(rid [our.bowl %'']) + :: if they are requesting our personal profile, check if we are + :: either public, or if they are on the allowed-ships list. + :: this is used for direct messages and leap searches + :: + ?: ?& =(rid [our.bowl %'']) + ?| scry-is-public + (scry-for ? /allowed-ship/(scot %p ship)) == %.y - ?: shp %.y - ?: ?& (~(has in scry-sharing) rid) - (~(has in (members:grp rid)) ship) - == - %.y - =/ allowed-groups ~(tap in (scry-for (set resource) /allowed-groups)) - |- - ?~ allowed-groups %.n - ?: (~(has in (members:grp i.allowed-groups)) ship) - %.y - $(allowed-groups t.allowed-groups) + :: if they are requesting our profile within a group, make sure we + :: are the host of that group and that they are a member of the group + :: + =/ allowed-groups (scry-for (set resource) /allowed-groups) + ?& (~(has in allowed-groups) rid) + (~(has in scry-sharing) rid) + (~(has in (members:grp rid)) ship) + == -- diff --git a/pkg/arvo/mar/contact/share.hoon b/pkg/arvo/mar/contact/share.hoon index 15b534f01..54e0d7b1d 100644 --- a/pkg/arvo/mar/contact/share.hoon +++ b/pkg/arvo/mar/contact/share.hoon @@ -1,3 +1,5 @@ +/+ *contact-store +:: |_ share=[%share =ship] ++ grad %noun ++ grow @@ -8,5 +10,6 @@ ++ grab |% ++ noun share + ++ json share:share-dejs -- -- From fe76d75a188ffe48a97b54760b9c4e3d452156db Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 2 Feb 2021 17:29:42 -0600 Subject: [PATCH 18/20] contacts: clarify syntax for +is-allowed --- pkg/arvo/app/contact-store.hoon | 8 ++++---- pkg/arvo/lib/contact.hoon | 31 +++++++++++++++---------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 027b54fc4..da90bbabf 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -219,10 +219,10 @@ ``noun+!>(allowed-groups) :: - [%x %is-allowed @ ~] - =/ =ship (slav %p i.t.t.path) - ~& ship - ``json+!>(`json`b+(is-allowed:con [our.bowl %''] ship)) + [%x %is-allowed @ @ @ ~] + =/ =resource [(slav %p i.t.t.path) i.t.t.t.path] + =/ =ship (slav %p i.t.t.t.t.path) + ``json+!>(`json`b+(is-allowed:con resource ship)) == :: ++ on-leave on-leave:def diff --git a/pkg/arvo/lib/contact.hoon b/pkg/arvo/lib/contact.hoon index cf25eab16..8904f931a 100644 --- a/pkg/arvo/lib/contact.hoon +++ b/pkg/arvo/lib/contact.hoon @@ -70,21 +70,20 @@ |= [rid=resource =ship] ^- ? =/ grp ~(. group bowl) - :: if they are requesting our personal profile, check if we are - :: either public, or if they are on the allowed-ships list. - :: this is used for direct messages and leap searches - :: - ?: ?& =(rid [our.bowl %'']) - ?| scry-is-public - (scry-for ? /allowed-ship/(scot %p ship)) - == - %.y - :: if they are requesting our profile within a group, make sure we - :: are the host of that group and that they are a member of the group - :: =/ allowed-groups (scry-for (set resource) /allowed-groups) - ?& (~(has in allowed-groups) rid) - (~(has in scry-sharing) rid) - (~(has in (members:grp rid)) ship) - == + ?| :: if they are requesting our personal profile, check if we are + :: either public, or if they are on the allowed-ships list. + :: this is used for direct messages and leap searches + :: + ?& =(rid [our.bowl %'']) + ?| scry-is-public + (scry-for ? /allowed-ship/(scot %p ship)) + == == + :: if they are requesting our profile within a group, make sure we + :: are the host of that group and that they are a member of the group + :: + ?& (~(has in allowed-groups) rid) + (~(has in scry-sharing) rid) + (~(has in (members:grp rid)) ship) + == == -- From 02f4ff58a17c5f15a7bdfa2da2e3438809cdccfa Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 2 Feb 2021 19:13:33 -0600 Subject: [PATCH 19/20] contact: perfected the +is-allowed arm and fixed issue with share type --- pkg/arvo/app/contact-store.hoon | 8 ++++++-- pkg/arvo/app/group-view.hoon | 5 +++++ pkg/arvo/lib/contact.hoon | 22 ++++++++++++++++------ pkg/arvo/mar/contact/share.hoon | 2 +- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index da90bbabf..3a125137a 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -219,8 +219,12 @@ ``noun+!>(allowed-groups) :: - [%x %is-allowed @ @ @ ~] - =/ =resource [(slav %p i.t.t.path) i.t.t.t.path] + [%x %is-allowed @ @ @ @ ~] + =/ is-personal =(i.t.t.t.t.t.path 'true') + =/ =resource + ?: is-personal + [our.bowl %''] + [(slav %p i.t.t.path) i.t.t.t.path] =/ =ship (slav %p i.t.t.t.t.path) ``json+!>(`json`b+(is-allowed:con resource ship)) == diff --git a/pkg/arvo/app/group-view.hoon b/pkg/arvo/app/group-view.hoon index 61664f60f..884b30236 100644 --- a/pkg/arvo/app/group-view.hoon +++ b/pkg/arvo/app/group-view.hoon @@ -175,6 +175,10 @@ %share-co ?> ?=(%poke-ack -.sign) (ack +.sign) + :: + %push-co + ?> ?=(%poke-ack -.sign) + (ack +.sign) :: %md ?+ -.sign !! @@ -200,6 +204,7 @@ %- zing :~ [(poke-our:(jn-pass-io /pull-md) %metadata-pull-hook cag)]~ [(poke-our:(jn-pass-io /pull-co) %contact-pull-hook cag)]~ + :: ?. scry-is-public:con ~ :_ ~ %+ poke:(jn-pass-io /share-co) diff --git a/pkg/arvo/lib/contact.hoon b/pkg/arvo/lib/contact.hoon index 8904f931a..2f3c6106a 100644 --- a/pkg/arvo/lib/contact.hoon +++ b/pkg/arvo/lib/contact.hoon @@ -76,14 +76,24 @@ :: this is used for direct messages and leap searches :: ?& =(rid [our.bowl %'']) - ?| scry-is-public + ?| :: if our profile is public, allow + :: + scry-is-public + :: if the requester is an allowed-ship, allow + :: (scry-for ? /allowed-ship/(scot %p ship)) + :: if the requester of our profile is the host of one of + :: our allowed-groups, allow + :: + %+ lien ~(tap in allowed-groups) + |= res=resource + =(entity.res ship) == == - :: if they are requesting our profile within a group, make sure we - :: are the host of that group and that they are a member of the group + :: if they are requesting our contact data within a group, + :: we make sure that we are sharing that group, + :: and that they are a member of the group :: - ?& (~(has in allowed-groups) rid) - (~(has in scry-sharing) rid) + ?& (~(has in scry-sharing) rid) (~(has in (members:grp rid)) ship) - == == + == == -- diff --git a/pkg/arvo/mar/contact/share.hoon b/pkg/arvo/mar/contact/share.hoon index 54e0d7b1d..abca9f637 100644 --- a/pkg/arvo/mar/contact/share.hoon +++ b/pkg/arvo/mar/contact/share.hoon @@ -9,7 +9,7 @@ :: ++ grab |% - ++ noun share + ++ noun _share ++ json share:share-dejs -- -- From 8a0a007261da03673e5360a2816fe4961b45f46b Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Tue, 2 Feb 2021 19:13:59 -0600 Subject: [PATCH 20/20] interface: partially working share banner --- pkg/interface/src/logic/api/base.ts | 1 + pkg/interface/src/logic/api/contacts.ts | 23 ++++ .../src/views/apps/chat/ChatResource.tsx | 13 ++- .../apps/chat/components/ShareProfile.js | 104 ++++++++++++++++-- .../apps/profile/components/SetStatus.tsx | 1 + 5 files changed, 130 insertions(+), 12 deletions(-) diff --git a/pkg/interface/src/logic/api/base.ts b/pkg/interface/src/logic/api/base.ts index 323c13ce7..085c4cc32 100644 --- a/pkg/interface/src/logic/api/base.ts +++ b/pkg/interface/src/logic/api/base.ts @@ -57,6 +57,7 @@ export default class BaseApi { } scry(app: string, path: Path): Promise { + console.log(path); return fetch(`/~/scry/${app}${path}.json`).then(r => r.json() as Promise); } diff --git a/pkg/interface/src/logic/api/contacts.ts b/pkg/interface/src/logic/api/contacts.ts index fab1ed90a..628532700 100644 --- a/pkg/interface/src/logic/api/contacts.ts +++ b/pkg/interface/src/logic/api/contacts.ts @@ -34,12 +34,35 @@ export default class ContactsApi extends BaseApi { }); } + allow(ship) { + return this.storeAction({ + allow: ship + }); + } + setPublic(setPublic: any) { return this.storeAction({ 'set-public': setPublic }); } + share(recipient, us) { + return this.action( + 'contact-push-hook', + 'contact-share', + { share: us }, + recipient + ); + } + + fetchIsAllowed(entity, name, ship, personal) { + const isPersonal = personal ? 'true' : 'false'; + return this.scry( + 'contact-store', + `/is-allowed/${entity}/${name}/${ship}/${isPersonal}` + ); + } + private storeAction(action: any): Promise { return this.action('contact-store', 'contact-update', action) } diff --git a/pkg/interface/src/views/apps/chat/ChatResource.tsx b/pkg/interface/src/views/apps/chat/ChatResource.tsx index 56bc414b6..df3db4fb4 100644 --- a/pkg/interface/src/views/apps/chat/ChatResource.tsx +++ b/pkg/interface/src/views/apps/chat/ChatResource.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useCallback, useEffect } from 'react'; +import React, { useRef, useCallback, useEffect, useState } from 'react'; import { RouteComponentProps } from 'react-router-dom'; import { Col } from '@tlon/indigo-react'; import _ from 'lodash'; @@ -35,6 +35,7 @@ export function ChatResource(props: ChatResourceProps) { const [,, owner, name] = station.split('/'); const ourContact = contacts?.[`~${window.ship}`]; + console.log(contacts); const chatInput = useRef(); @@ -86,7 +87,15 @@ export function ChatResource(props: ChatResourceProps) { return ( - + { + setProfileAllowed(true); + }} /> {dragging && } { - const image = (props?.our?.avatar) - ? - : - - ; +const pathAsResource = (path) => { + if (!path) { + return false; + } + const pathArr = path.split('/'); + if (pathArr.length !== 4) { + return false; + } - return ( + return { + entity: pathArr[2], + name: pathArr[3] + }; +}; + +export const ShareProfile = (props) => { + const { api, recipient, hideBanner, group, groupPath } = props; + console.log(groupPath); + // TODO: use isContactPublic somewhere + + const [showBanner, setShowBanner] = useState(false); + const res = pathAsResource(groupPath); + + useEffect(() => { + if (!res) { return; } + if (!group) { return; } + console.log(group); + if (group.hidden) { + // TODO: + // take the union of the pending set and the members set, + // subtract ourselves, then if *anyone* has not already been shared with, + // show the banner + // Promise.all all the members of the set + let check = + Promise.all() + props.api.contacts.fetchIsAllowed( + `~${window.ship}`, + 'personal', // not used + recipient, + true + ).then((retVal) => { + console.log(retVal); + setShowBanner(!retVal); + }); + } else { + // TODO: + // if the group is not in the allowed-groups set, then show the banner + props.api.contacts.fetchIsAllowed( + res.entity, + res.name, + recipient, + false + ).then((retVal) => { + console.log(retVal); + setShowBanner(!retVal); + }); + } + }, [recipient, res, group]); + + const image = (props?.our?.avatar) + ? ( + + ) : ( + + + + ); + + const onClick = () => { + api.contacts.allow(recipient).then(() => { + api.contacts.share(recipient, window.ship); + }); + hideBanner(); + }; + + return showBanner ? ( { {image} Share private profile? - + Share - ); + ) : null; }; diff --git a/pkg/interface/src/views/apps/profile/components/SetStatus.tsx b/pkg/interface/src/views/apps/profile/components/SetStatus.tsx index 4674f315c..0d2240077 100644 --- a/pkg/interface/src/views/apps/profile/components/SetStatus.tsx +++ b/pkg/interface/src/views/apps/profile/components/SetStatus.tsx @@ -59,3 +59,4 @@ export function SetStatus(props: any) { ); } +