shrub/pkg/arvo/app/invite-hook.hoon

102 lines
2.2 KiB
Plaintext
Raw Normal View History

:: 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.
2019-11-21 01:09:31 +03:00
::
/- *invite-store
/+ default-agent, dbug
2019-11-21 01:09:31 +03:00
::
|%
+$ state-0 [%0 ~]
+$ card card:agent:gall
--
::
=| state-0
=* state -
2020-03-12 03:33:48 +03:00
%- agent:dbug
2019-11-21 01:09:31 +03:00
^- agent:gall
::
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
2019-11-21 01:09:31 +03:00
::
++ on-init [~ this]
++ on-save !>(state)
++ on-load
|= old=vase
^- (quip card _this)
[~ this(state !<(state-0 old))]
2019-11-21 01:09:31 +03:00
::
++ on-poke
|= [=mark =vase]
^- (quip card _this)
|^
:_ this
?+ mark (on-poke:def mark vase)
2019-11-21 01:09:31 +03:00
%invite-action
=/ act=invite-action !<(invite-action vase)
?. ?=(%invite -.act) ~
?: (team:title [our src]:bowl)
:: outgoing. we must be inviting another ship. send them the invite.
::
?< (team:title our.bowl recipient.invite.act)
[(invite-hook-poke recipient.invite.act act)]~
:: else incoming. ensure invitatory exists and invite is not a duplicate.
::
?> ?=(^ (invitatory-scry term.act))
?> ?=(~ (invite-scry term.act uid.act))
[(invite-poke term.act act)]~
2019-11-21 01:09:31 +03:00
==
::
++ invite-hook-poke
|= [=ship action=invite-action]
^- card
:* %pass
/invite-hook
%agent
[ship %invite-hook]
%poke
%invite-action
!>(action)
2020-05-19 23:53:55 +03:00
==
::
++ invite-poke
|= [=term action=invite-action]
^- card
:* %pass
/[term]
%agent
[our.bowl %invite-store]
%poke
%invite-action
!>(action)
2020-05-19 23:53:55 +03:00
==
::
++ invitatory-scry
|= =term
.^ (unit invitatory)
%gx
%+ weld
/(scot %p our.bowl)/invite-store/(scot %da now.bowl)/invitatory
/[term]/noun
==
::
++ invite-scry
|= [=term uid=serial]
.^ (unit invite)
%gx
%+ weld
/(scot %p our.bowl)/invite-store/(scot %da now.bowl)/invite
/[term]/(scot %uv uid)/noun
==
--
::
++ on-peek on-peek:def
++ on-watch on-watch:def
++ on-leave on-leave:def
++ on-agent on-agent:def
++ on-arvo on-arvo:def
++ on-fail on-fail:def
2019-11-21 01:09:31 +03:00
--