2019-10-31 21:38:23 +03:00
|
|
|
/+ *invite-json
|
|
|
|
|%
|
|
|
|
+$ move [bone card]
|
|
|
|
::
|
|
|
|
+$ card
|
2019-11-02 01:18:17 +03:00
|
|
|
$% [%diff invite-diff]
|
2019-10-31 21:38:23 +03:00
|
|
|
[%quit ~]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ state
|
|
|
|
$% [%0 state-zero]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ state-zero
|
|
|
|
$: =invites
|
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
|
|
|
|_ [bol=bowl:gall state]
|
|
|
|
::
|
|
|
|
++ this .
|
|
|
|
::
|
|
|
|
++ prep
|
|
|
|
|= old=(unit state)
|
|
|
|
^- (quip move _this)
|
|
|
|
?~ old
|
|
|
|
[~ this]
|
|
|
|
[~ this(+<+ u.old)]
|
|
|
|
::
|
|
|
|
++ peek-x-all
|
|
|
|
|= pax=path
|
|
|
|
^- (unit (unit [%noun (map path invitatory)]))
|
|
|
|
[~ ~ %noun invites]
|
|
|
|
::
|
|
|
|
++ peek-x-invitatory
|
|
|
|
|= pax=path
|
|
|
|
^- (unit (unit [%noun (unit invitatory)]))
|
|
|
|
?~ pax
|
|
|
|
~
|
|
|
|
=/ invitatory=(unit invitatory) (~(get by invites) pax)
|
|
|
|
[~ ~ %noun invitatory]
|
|
|
|
::
|
|
|
|
++ peek-x-invite
|
|
|
|
|= pax=path
|
|
|
|
^- (unit (unit [%noun (unit invite)]))
|
2019-11-02 01:18:17 +03:00
|
|
|
:: /:path/:uid
|
|
|
|
=/ pas (flop pax)
|
|
|
|
?~ pas
|
2019-10-31 21:38:23 +03:00
|
|
|
~
|
2019-11-02 01:18:17 +03:00
|
|
|
=/ uid=serial (slav %uv i.pas)
|
|
|
|
=. pax (scag (dec (lent pax)) `(list @ta)`pax)
|
|
|
|
=/ invitatory=(unit invitatory) (~(get by invites) pax)
|
2019-10-31 21:38:23 +03:00
|
|
|
?~ invitatory
|
|
|
|
~
|
|
|
|
=/ invite=(unit invite) (~(get by u.invitatory) uid)
|
|
|
|
[~ ~ %noun invite]
|
|
|
|
::
|
|
|
|
++ peer-all
|
|
|
|
|= pax=path
|
|
|
|
^- (quip move _this)
|
|
|
|
?> (team:title our.bol src.bol)
|
|
|
|
:: send all updates from now on
|
|
|
|
:_ this
|
|
|
|
[ost.bol %diff %invite-initial invites]~
|
|
|
|
::
|
|
|
|
++ peer-updates
|
|
|
|
|= pax=path
|
|
|
|
^- (quip move _this)
|
|
|
|
?> (team:title our.bol src.bol)
|
|
|
|
:: send all updates from now on
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
++ peer-invitatory
|
|
|
|
|= pax=path
|
|
|
|
^- (quip move _this)
|
|
|
|
?> (team:title our.bol src.bol)
|
|
|
|
=/ inv=(unit invitatory) (~(get by invites) pax)
|
|
|
|
?~ inv !!
|
|
|
|
:_ this
|
|
|
|
[ost.bol %diff %invite-update [%invitatory u.inv]]~
|
|
|
|
::
|
|
|
|
++ poke-json
|
|
|
|
|= =json
|
|
|
|
^- (quip move _this)
|
|
|
|
?> (team:title our.bol src.bol)
|
|
|
|
(poke-invite-action (json-to-action json))
|
|
|
|
::
|
|
|
|
++ poke-invite-action
|
|
|
|
|= action=invite-action
|
|
|
|
^- (quip move _this)
|
|
|
|
?> (team:title our.bol src.bol)
|
|
|
|
?- -.action
|
2019-11-01 01:13:23 +03:00
|
|
|
%create (handle-create action)
|
|
|
|
%delete (handle-delete action)
|
|
|
|
%invite (handle-invite action)
|
|
|
|
%accept (handle-accept action)
|
|
|
|
%decline (handle-decline action)
|
2019-10-31 21:38:23 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-create
|
|
|
|
|= act=invite-action
|
|
|
|
^- (quip move _this)
|
|
|
|
?> ?=(%create -.act)
|
|
|
|
?: (~(has by invites) path.act)
|
|
|
|
[~ this]
|
|
|
|
:- (send-diff path.act act)
|
|
|
|
this(invites (~(put by invites) path.act *invitatory))
|
|
|
|
::
|
|
|
|
++ handle-delete
|
|
|
|
|= act=invite-action
|
|
|
|
^- (quip move _this)
|
|
|
|
?> ?=(%delete -.act)
|
|
|
|
?. (~(has by invites) path.act)
|
|
|
|
[~ this]
|
|
|
|
:- (send-diff path.act act)
|
|
|
|
this(invites (~(del by invites) path.act))
|
|
|
|
::
|
|
|
|
++ handle-invite
|
|
|
|
|= act=invite-action
|
|
|
|
^- (quip move _this)
|
|
|
|
?> ?=(%invite -.act)
|
|
|
|
?. (~(has by invites) path.act)
|
|
|
|
[~ this]
|
|
|
|
=/ container (~(got by invites) path.act)
|
|
|
|
=. uid.act (sham eny.bol)
|
|
|
|
=. container (~(put by container) uid.act invite.act)
|
|
|
|
:- (send-diff path.act act)
|
|
|
|
this(invites (~(put by invites) path.act container))
|
|
|
|
::
|
|
|
|
++ handle-accept
|
|
|
|
|= act=invite-action
|
|
|
|
^- (quip move _this)
|
|
|
|
?> ?=(%accept -.act)
|
|
|
|
?. (~(has by invites) path.act)
|
|
|
|
[~ this]
|
|
|
|
=/ container (~(got by invites) path.act)
|
|
|
|
=/ invite (~(get by container) uid.act)
|
|
|
|
?~ invite
|
|
|
|
[~ this]
|
|
|
|
=. container (~(del by container) uid.act)
|
|
|
|
:- (send-diff path.act [%accepted path.act uid.act u.invite])
|
|
|
|
this(invites (~(put by invites) path.act container))
|
|
|
|
::
|
|
|
|
++ handle-decline
|
|
|
|
|= act=invite-action
|
|
|
|
^- (quip move _this)
|
|
|
|
?> ?=(%decline -.act)
|
|
|
|
?. (~(has by invites) path.act)
|
|
|
|
[~ this]
|
|
|
|
=/ container (~(got by invites) path.act)
|
|
|
|
=/ invite (~(get by container) uid.act)
|
|
|
|
?~ invite
|
|
|
|
[~ this]
|
|
|
|
=. container (~(del by container) uid.act)
|
|
|
|
:- (send-diff path.act act)
|
|
|
|
this(invites (~(put by invites) path.act container))
|
|
|
|
::
|
|
|
|
++ update-subscribers
|
|
|
|
|= [pax=path upd=invite-update]
|
|
|
|
^- (list move)
|
|
|
|
%+ turn (prey:pubsub:userlib pax bol)
|
|
|
|
|= [=bone *]
|
|
|
|
[bone %diff %invite-update upd]
|
|
|
|
::
|
|
|
|
++ send-diff
|
|
|
|
|= [pax=path upd=invite-update]
|
|
|
|
^- (list move)
|
|
|
|
%- zing
|
|
|
|
:~ (update-subscribers /all upd)
|
|
|
|
(update-subscribers /updates upd)
|
|
|
|
(update-subscribers [%invitatory pax] upd)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
--
|