urbit/pkg/landscape/lib/invite-json.hoon

134 lines
2.7 KiB
Plaintext
Raw Normal View History

/- *invite-store
2020-10-21 01:27:44 +03:00
/+ resource
|%
++ slan |=(mod=@tas |=(txt=@ta (need (slaw mod txt))))
::
++ seri ::: serial
=, dejs:format
^- $-(json serial)
(cu (slan %uv) so)
::
++ invites-to-json
|= inv=invites
^- json
%- pairs:enjs:format
%+ turn ~(tap by inv)
2020-10-21 01:27:44 +03:00
|= [=term =invitatory]
^- [cord json]
2020-10-21 01:27:44 +03:00
[term (invitatory-to-json invitatory)]
::
++ invitatory-to-json
|= =invitatory
^- json
=, enjs:format
%- pairs
%+ turn ~(tap by invitatory)
|= [=serial =invite]
^- [cord json]
[(scot %uv serial) (invite-to-json invite)]
::
++ invite-to-json
|= =invite
^- json
=, enjs:format
%- pairs
2019-11-01 01:13:23 +03:00
:~ [%ship (ship ship.invite)]
[%app [%s app.invite]]
2020-10-21 01:27:44 +03:00
[%resource (enjs:resource resource.invite)]
2019-11-01 01:13:23 +03:00
[%recipient (ship recipient.invite)]
[%text [%s text.invite]]
==
::
++ update-to-json
|= upd=update
=, enjs:format
^- json
%+ frond %invite-update
%- pairs
:~
?: =(%initial -.upd)
?> ?=(%initial -.upd)
[%initial (invites-to-json invites.upd)]
?: =(%create -.upd)
?> ?=(%create -.upd)
2020-10-21 01:27:44 +03:00
[%create (pairs [%term s+term.upd]~)]
?: =(%delete -.upd)
?> ?=(%delete -.upd)
2020-10-21 01:27:44 +03:00
[%delete (pairs [%term s+term.upd]~)]
?: =(%accepted -.upd)
?> ?=(%accepted -.upd)
:- %accepted
%- pairs
2020-10-21 01:27:44 +03:00
:~ [%term s+term.upd]
[%uid s+(scot %uv uid.upd)]
[%invite (invite-to-json invite.upd)]
==
?: =(%decline -.upd)
?> ?=(%decline -.upd)
:- %decline
%- pairs
2020-10-21 01:27:44 +03:00
:~ [%term s+term.upd]
[%uid s+(scot %uv uid.upd)]
==
?: =(%invite -.upd)
?> ?=(%invite -.upd)
:- %invite
%- pairs
2020-10-21 01:27:44 +03:00
:~ [%term s+term.upd]
[%uid s+(scot %uv uid.upd)]
[%invite (invite-to-json invite.upd)]
==
?: =(%invitatory -.upd)
?> ?=(%invitatory -.upd)
:- %invitatory
(invitatory-to-json invitatory.upd)
::
:: %noop
[*@t *json]
==
::
++ json-to-action
|= jon=json
^- action
=, dejs:format
=< (parse-json jon)
|%
++ parse-json
%- of
2020-10-21 01:27:44 +03:00
:~ [%create so]
[%delete so]
[%invite invite]
[%accept accept]
[%decline decline]
==
::
++ invite
%- ot
2020-10-21 01:27:44 +03:00
:~ [%term so]
[%uid seri]
[%invite invi]
==
::
++ accept
%- ot
2020-10-21 01:27:44 +03:00
:~ [%term so]
[%uid seri]
==
::
++ decline
%- ot
2020-10-21 01:27:44 +03:00
:~ [%term so]
[%uid seri]
==
::
++ invi
%- ot
2019-11-01 01:13:23 +03:00
:~ [%ship (su ;~(pfix sig fed:ag))]
2020-10-21 01:27:44 +03:00
[%app so]
[%resource dejs:resource]
2019-11-01 01:13:23 +03:00
[%recipient (su ;~(pfix sig fed:ag))]
[%text so]
==
--
--