2021-04-23 04:03:36 +03:00
|
|
|
:: invite-hook [landscape]: receive invites from any source
|
|
|
|
::
|
|
|
|
:: only handles %invite actions:
|
|
|
|
:: - can be poked by the host team to send an invite out to someone.
|
|
|
|
:: - can be poked by foreign ships to send an invite to us.
|
|
|
|
::
|
|
|
|
/+ default-agent, dbug, store=graph-store, graphlib=graph, agentio, resource
|
2021-04-30 07:16:03 +03:00
|
|
|
/+ sig=signatures
|
2021-04-23 04:03:36 +03:00
|
|
|
::
|
|
|
|
|%
|
2021-04-30 07:16:03 +03:00
|
|
|
+$ state-0 [%0 pending=(jar ship atom)]
|
2021-04-23 04:03:36 +03:00
|
|
|
+$ card card:agent:gall
|
|
|
|
--
|
|
|
|
::
|
|
|
|
=| state-0
|
|
|
|
=* state -
|
|
|
|
%- agent:dbug
|
|
|
|
^- agent:gall
|
|
|
|
::
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
gra ~(. graphlib bowl)
|
|
|
|
io ~(. agentio bowl)
|
|
|
|
pass pass:io
|
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
:_ this
|
|
|
|
:_ ~
|
|
|
|
%+ poke-our:pass %graph-store
|
|
|
|
%+ update:cg:gra now.bowl
|
|
|
|
:+ %add-graph [our.bowl %inbox]
|
|
|
|
[*graph:store `%graph-validator-dm %.n]
|
|
|
|
::
|
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old=vase
|
|
|
|
^- (quip card _this)
|
2021-04-30 07:16:03 +03:00
|
|
|
`this(state !<(state-0 old))
|
2021-04-23 04:03:36 +03:00
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%graph-update-1
|
|
|
|
=+ !<(=update:store vase)
|
2021-04-30 07:16:03 +03:00
|
|
|
?+ -.q.update `this
|
2021-04-23 04:03:36 +03:00
|
|
|
%add-nodes
|
|
|
|
?> ?=([@ %inbox] resource.q.update)
|
2021-04-30 07:16:03 +03:00
|
|
|
=^ cards state
|
|
|
|
?: =(our.bowl src.bowl)
|
|
|
|
(outgoing-add nodes.q.update)
|
|
|
|
(incoming-add nodes.q.update)
|
|
|
|
[cards this]
|
2021-04-23 04:03:36 +03:00
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
2021-04-23 07:14:47 +03:00
|
|
|
++ add-node
|
|
|
|
|= [=index:store =node:store]
|
|
|
|
^- update:store
|
|
|
|
:^ now.bowl %add-nodes [our.bowl %inbox]
|
|
|
|
(~(gas by *(map index:store node:store)) [index node] ~)
|
|
|
|
::
|
|
|
|
++ add-missing-root
|
|
|
|
|= =ship
|
|
|
|
^- (list card)
|
|
|
|
=/ =index:store
|
|
|
|
[ship ~]
|
|
|
|
?: (check-node-existence:gra [our.bowl %inbox] index) ~
|
|
|
|
=| =node:store
|
|
|
|
=: author.post.node our.bowl
|
|
|
|
index.post.node index
|
|
|
|
time-sent.post.node now.bowl
|
|
|
|
==
|
2021-04-30 07:16:03 +03:00
|
|
|
(poke-our:pass %graph-store (update:cg:gra (add-node index node)))^~
|
2021-04-23 07:14:47 +03:00
|
|
|
::
|
2021-04-23 04:39:29 +03:00
|
|
|
++ outgoing-add
|
2021-04-23 04:03:36 +03:00
|
|
|
|= nodes=(map index:store node:store)
|
2021-04-30 07:16:03 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
=/ nodes=(list [=index:store =node:store])
|
|
|
|
~(tap by nodes)
|
|
|
|
=| cards=(list card)
|
|
|
|
|- ^- (quip card _state)
|
|
|
|
?~ nodes [cards state]
|
|
|
|
?> ?=([@ @ ~] index.i.nodes)
|
|
|
|
=/ =ship i.index.i.nodes
|
2021-04-23 04:03:36 +03:00
|
|
|
=/ =dock [ship %dm-hook]
|
|
|
|
=/ =wire /dm/(scot %p ship)
|
2021-04-23 07:14:47 +03:00
|
|
|
=/ =cage
|
2021-04-30 07:16:03 +03:00
|
|
|
(update:cg:gra (add-node [index node]:i.nodes))
|
|
|
|
%= $
|
|
|
|
nodes t.nodes
|
|
|
|
pending (~(add ja pending) ship now.bowl)
|
2021-04-23 07:14:47 +03:00
|
|
|
::
|
2021-04-30 07:16:03 +03:00
|
|
|
cards
|
|
|
|
;: welp
|
|
|
|
cards
|
|
|
|
(add-missing-root ship)
|
|
|
|
:~ (~(poke pass wire) dock cage)
|
|
|
|
(poke-our:pass %graph-store cage)
|
|
|
|
==
|
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
2021-04-23 04:39:29 +03:00
|
|
|
++ incoming-add
|
2021-04-23 04:03:36 +03:00
|
|
|
|= nodes=(map index:store node:store)
|
2021-04-30 07:16:03 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
:_ state
|
2021-04-23 04:03:36 +03:00
|
|
|
?> =(1 ~(wyt by nodes))
|
|
|
|
=* ship src.bowl
|
2021-04-23 07:14:47 +03:00
|
|
|
%+ snoc (add-missing-root ship)
|
2021-04-30 07:16:03 +03:00
|
|
|
%+ poke-our:pass %graph-store
|
2021-04-23 04:03:36 +03:00
|
|
|
%+ update:cg:gra now.bowl
|
2021-04-23 07:14:47 +03:00
|
|
|
:+ %add-nodes [our.bowl %inbox]
|
2021-04-23 04:03:36 +03:00
|
|
|
%- ~(gas by *(map index:store node:store))
|
|
|
|
%+ turn ~(tap by nodes)
|
|
|
|
|= [=index:store =node:store]
|
|
|
|
?> ?=([@ @ ~] index)
|
|
|
|
?> ?=(%empty -.children.node)
|
|
|
|
=/ new-index=index:store
|
|
|
|
[ship now.bowl ~]
|
|
|
|
=. index.post.node
|
|
|
|
new-index
|
|
|
|
[new-index node]
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-peek on-peek:def
|
|
|
|
++ on-watch on-watch:def
|
|
|
|
++ on-leave on-leave:def
|
2021-04-30 07:16:03 +03:00
|
|
|
++ on-agent
|
|
|
|
|= [=wire =sign:agent:gall]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?. ?=([%dm @ ~] wire)
|
|
|
|
(on-agent:def wire sign)
|
|
|
|
?> ?=(%poke-ack -.sign)
|
|
|
|
=/ =ship
|
|
|
|
(slav %p i.t.wire)
|
|
|
|
=^ acked=atom state
|
|
|
|
(remove-pending ship)
|
|
|
|
?~ p.sign
|
|
|
|
`this
|
|
|
|
:_ this
|
|
|
|
:_ ~
|
|
|
|
=+ indices=(~(gas in *(set index:store)) ~[ship acked] ~)
|
|
|
|
%+ poke-our:pass %graph-store
|
|
|
|
(update:cg:gra now.bowl %remove-nodes [our.bowl %inbox] indices)
|
|
|
|
::
|
|
|
|
++ remove-pending
|
|
|
|
|= =ship
|
|
|
|
^- [atom _state]
|
|
|
|
=/ pend-ship=(list atom)
|
|
|
|
(flop (~(get ja pending) ship))
|
|
|
|
?> ?=(^ pend-ship)
|
|
|
|
[i.pend-ship state(pending (~(put by pending) ship (flop t.pend-ship)))]
|
|
|
|
--
|
|
|
|
|
2021-04-23 04:03:36 +03:00
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|