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

73 lines
1.6 KiB
Plaintext
Raw Normal View History

2019-11-21 01:50:30 +03:00
:: invite-view: provide a json interface to invite-store
::
2019-11-27 04:42:07 +03:00
:: accepts subscriptions at the /primary path.
2019-11-21 01:50:30 +03:00
:: passes through all invites and their updates.
:: only accepts subcriptions from the host's team.
::
::TODO could maybe use /lib/proxy-hook, be renamed invite-proxy-hook
::
2019-11-27 04:42:07 +03:00
/+ *invite-json, default-agent
2019-11-21 01:50:30 +03:00
::
|%
+$ card card:agent:gall
--
::
2019-11-27 04:42:07 +03:00
=>
|%
++ watch-updates
|= our=ship
^- card
[%pass /store %agent [our %invite-store] %watch /updates]
--
2019-11-21 01:50:30 +03:00
^- agent:gall
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
::
++ on-init
^- (quip card _this)
[[(watch-updates our.bowl)]~ this]
::
2019-11-27 04:42:07 +03:00
++ on-save on-save:def
2019-11-21 01:50:30 +03:00
++ on-load
|= old=vase
^- (quip card _this)
2019-11-27 04:42:07 +03:00
[~ this]
2019-11-21 01:50:30 +03:00
::
++ on-watch
|= =path
^- (quip card _this)
?> (team:title our.bowl src.bowl)
2019-11-27 04:42:07 +03:00
?. =(/primary path)
(on-watch:def path)
2019-11-21 01:50:30 +03:00
:_ this
=/ =invites
.^(invites %gx /=invite-store/(scot %da now.bowl)/all/noun)
[%give %fact ~ %json !>((invites-to-json invites))]~
::
++ on-agent
|= [=wire =sign:agent:gall]
^- (quip card _this)
:_ this
?- -.sign
%poke-ack ~|([dap.bowl %unexpected-poke-ack] !!)
%watch-ack ~
%kick [(watch-updates our.bowl)]~
::
%fact
~| [dap.bowl %unexpected-fact-mark p.cage.sign]
?> ?=(%invite-update p.cage.sign)
2019-11-27 04:42:07 +03:00
:~ :*
%give %fact
~[/primary] %json
2019-11-27 04:42:07 +03:00
!>((update-to-json !<(invite-update q.cage.sign)))
== ==
2019-11-21 01:50:30 +03:00
==
::
++ on-poke on-poke:def
++ on-peek on-peek:def
++ on-leave on-leave:def
++ on-arvo on-arvo:def
++ on-fail on-fail:def
--