2020-09-01 04:54:39 +03:00
|
|
|
:: invite-store [landscape]
|
2020-10-22 20:17:15 +03:00
|
|
|
/- store=invite-store
|
2020-12-02 10:03:05 +03:00
|
|
|
/+ res=resource, default-agent, dbug, *migrate
|
2019-11-21 02:38:32 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
+$ versioned-state
|
2020-10-15 18:38:42 +03:00
|
|
|
$% state-0
|
2020-10-16 21:22:57 +03:00
|
|
|
state-1
|
2021-01-08 01:49:24 +03:00
|
|
|
state-2
|
2019-11-21 02:38:32 +03:00
|
|
|
==
|
|
|
|
::
|
2020-10-22 20:17:15 +03:00
|
|
|
+$ invitatory-0 (map serial:store invite-0)
|
2020-10-16 21:22:57 +03:00
|
|
|
+$ invite-0
|
|
|
|
$: =ship :: ship to subscribe to upon accepting invite
|
|
|
|
app=@tas :: app to subscribe to upon accepting invite
|
|
|
|
=path :: path to subscribe to upon accepting invite
|
|
|
|
recipient=ship :: recipient to receive invite
|
|
|
|
text=cord :: text to describe the invite
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ state-0 [%0 invites=(map path invitatory-0)]
|
2020-10-22 20:17:15 +03:00
|
|
|
+$ state-1 [%1 =invites:store]
|
2021-01-08 01:49:24 +03:00
|
|
|
+$ state-2 [%2 =invites:store]
|
2019-11-21 02:38:32 +03:00
|
|
|
--
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
=| state-2
|
2019-11-21 02:38:32 +03:00
|
|
|
=* state -
|
2020-03-12 03:33:48 +03:00
|
|
|
%- agent:dbug
|
2019-11-21 02:38:32 +03:00
|
|
|
^- agent:gall
|
2020-10-15 18:38:42 +03:00
|
|
|
::
|
|
|
|
|_ =bowl:gall
|
2020-10-21 01:18:30 +03:00
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
2020-10-16 21:22:57 +03:00
|
|
|
::
|
2020-10-27 20:48:50 +03:00
|
|
|
++ on-init
|
|
|
|
^- (quip card _this)
|
|
|
|
:- ~
|
|
|
|
%_ this
|
|
|
|
invites.state
|
|
|
|
%- ~(gas by *invites:store)
|
|
|
|
[%graph *invitatory:store]~
|
|
|
|
==
|
|
|
|
::
|
2020-10-15 18:38:42 +03:00
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
2020-10-16 21:22:57 +03:00
|
|
|
|= old-vase=vase
|
|
|
|
=/ old !<(versioned-state old-vase)
|
2021-01-08 01:49:24 +03:00
|
|
|
=| cards=(list card)
|
|
|
|
|-
|
|
|
|
?: ?=(%2 -.old)
|
|
|
|
[cards this(state old)]
|
2020-10-16 21:22:57 +03:00
|
|
|
?: ?=(%1 -.old)
|
2021-01-08 01:49:24 +03:00
|
|
|
=. cards
|
|
|
|
:~ =- [%pass / %agent [our.bowl %invite-store] %poke %invite-action -]
|
|
|
|
!> ^- action:store
|
|
|
|
[%create %groups]
|
|
|
|
::
|
|
|
|
=- [%pass / %agent [our.bowl %invite-store] %poke %invite-action -]
|
|
|
|
!> ^- action:store
|
|
|
|
[%delete %contacts]
|
|
|
|
==
|
|
|
|
$(-.old %2)
|
|
|
|
$(old [%1 (~(gas by *invites:store) [%graph *invitatory:store]~)])
|
2020-10-15 18:38:42 +03:00
|
|
|
::
|
|
|
|
++ on-agent on-agent:def
|
|
|
|
++ on-arvo on-arvo:def
|
2020-10-16 21:22:57 +03:00
|
|
|
++ on-leave on-leave:def
|
2020-10-15 18:38:42 +03:00
|
|
|
++ on-fail on-fail:def
|
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
2020-10-16 21:22:57 +03:00
|
|
|
?> (team:title our.bowl src.bowl)
|
2020-10-15 18:38:42 +03:00
|
|
|
=/ cards=(list card)
|
2020-10-27 23:45:26 +03:00
|
|
|
?+ path (on-watch:def path)
|
2020-10-15 18:38:42 +03:00
|
|
|
[%all ~] [%give %fact ~ %invite-update !>([%initial invites])]~
|
|
|
|
[%updates ~] ~
|
2020-10-21 01:18:30 +03:00
|
|
|
[%invitatory @ ~]
|
2020-10-22 20:17:15 +03:00
|
|
|
=/ inv=invitatory:store (~(got by invites) i.t.path)
|
2020-10-15 18:38:42 +03:00
|
|
|
[%give %fact ~ %invite-update !>([%invitatory inv])]~
|
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
=^ cards state
|
|
|
|
?+ mark (on-poke:def mark vase)
|
2020-10-22 20:17:15 +03:00
|
|
|
%invite-action (poke-invite-action !<(action:store vase))
|
2020-12-01 00:07:26 +03:00
|
|
|
%import (poke-import q.vase)
|
2020-10-15 18:38:42 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
2019-11-21 02:38:32 +03:00
|
|
|
::
|
2020-12-01 00:07:26 +03:00
|
|
|
++ poke-import
|
|
|
|
|= arc=*
|
|
|
|
^- (quip card _state)
|
2021-01-08 01:49:24 +03:00
|
|
|
=/ sty=state-2
|
|
|
|
:- %2
|
2020-12-02 10:03:05 +03:00
|
|
|
%- remake-map-of-map
|
|
|
|
;;((tree [term (tree [serial:store invite:store])]) +.arc)
|
2021-01-08 01:49:24 +03:00
|
|
|
:_ sty
|
|
|
|
:~ =- [%pass / %agent [our.bowl %invite-store] %poke %invite-action -]
|
|
|
|
!> ^- action:store
|
|
|
|
[%create %groups]
|
|
|
|
::
|
|
|
|
=- [%pass / %agent [our.bowl %invite-store] %poke %invite-action -]
|
|
|
|
!> ^- action:store
|
|
|
|
[%delete %contacts]
|
|
|
|
==
|
2020-12-01 00:07:26 +03:00
|
|
|
::
|
2020-10-15 18:38:42 +03:00
|
|
|
++ poke-invite-action
|
2020-10-22 20:17:15 +03:00
|
|
|
|= =action:store
|
2020-10-15 18:38:42 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
?- -.action
|
2020-10-27 23:45:26 +03:00
|
|
|
%create (handle-create +.action)
|
|
|
|
%delete (handle-delete +.action)
|
|
|
|
%invite (handle-invite +.action)
|
|
|
|
%accept (handle-accept +.action)
|
|
|
|
%decline (handle-decline +.action)
|
|
|
|
%invites ~|('only send this to %invite-hook' !!)
|
2020-10-15 18:38:42 +03:00
|
|
|
==
|
2019-11-21 02:38:32 +03:00
|
|
|
::
|
2020-10-15 18:38:42 +03:00
|
|
|
++ handle-create
|
2020-10-21 01:18:30 +03:00
|
|
|
|= =term
|
2020-10-15 18:38:42 +03:00
|
|
|
^- (quip card _state)
|
2020-10-21 01:18:30 +03:00
|
|
|
?: (~(has by invites) term)
|
2020-10-15 18:38:42 +03:00
|
|
|
[~ state]
|
2020-10-21 01:18:30 +03:00
|
|
|
:- (send-diff term [%create term])
|
2020-10-22 20:17:15 +03:00
|
|
|
state(invites (~(put by invites) term *invitatory:store))
|
2019-11-21 02:38:32 +03:00
|
|
|
::
|
2020-10-15 18:38:42 +03:00
|
|
|
++ handle-delete
|
2020-10-21 01:18:30 +03:00
|
|
|
|= =term
|
2020-10-15 18:38:42 +03:00
|
|
|
^- (quip card _state)
|
2020-10-21 01:18:30 +03:00
|
|
|
?. (~(has by invites) term)
|
2020-10-15 18:38:42 +03:00
|
|
|
[~ state]
|
2020-10-21 01:18:30 +03:00
|
|
|
:- (send-diff term [%delete term])
|
|
|
|
state(invites (~(del by invites) term))
|
2020-10-15 18:38:42 +03:00
|
|
|
::
|
|
|
|
++ handle-invite
|
2020-10-22 20:17:15 +03:00
|
|
|
|= [=term =serial:store =invite:store]
|
2020-10-15 18:38:42 +03:00
|
|
|
^- (quip card _state)
|
2020-10-21 01:18:30 +03:00
|
|
|
?. (~(has by invites) term)
|
2020-10-15 18:38:42 +03:00
|
|
|
[~ state]
|
2020-10-21 01:18:30 +03:00
|
|
|
=/ container (~(got by invites) term)
|
2020-10-22 20:17:15 +03:00
|
|
|
=. serial (sham eny.bowl)
|
|
|
|
=. container (~(put by container) serial invite)
|
|
|
|
:- (send-diff term [%invite term serial invite])
|
2020-10-21 01:18:30 +03:00
|
|
|
state(invites (~(put by invites) term container))
|
2019-11-21 02:38:32 +03:00
|
|
|
::
|
2020-10-15 18:38:42 +03:00
|
|
|
++ handle-accept
|
2020-10-22 20:17:15 +03:00
|
|
|
|= [=term =serial:store]
|
2020-10-15 18:38:42 +03:00
|
|
|
^- (quip card _state)
|
2020-10-21 01:18:30 +03:00
|
|
|
?. (~(has by invites) term)
|
2020-10-15 18:38:42 +03:00
|
|
|
[~ state]
|
2020-10-21 01:18:30 +03:00
|
|
|
=/ container (~(got by invites) term)
|
2020-10-22 20:17:15 +03:00
|
|
|
=/ invite (~(get by container) serial)
|
2020-10-15 18:38:42 +03:00
|
|
|
?~ invite
|
|
|
|
[~ state]
|
2020-10-22 20:17:15 +03:00
|
|
|
=. container (~(del by container) serial)
|
|
|
|
:- (send-diff term [%accepted term serial u.invite])
|
2020-10-21 01:18:30 +03:00
|
|
|
state(invites (~(put by invites) term container))
|
2020-10-15 18:38:42 +03:00
|
|
|
::
|
|
|
|
++ handle-decline
|
2020-10-22 20:17:15 +03:00
|
|
|
|= [=term =serial:store]
|
2020-10-15 18:38:42 +03:00
|
|
|
^- (quip card _state)
|
2020-10-21 01:18:30 +03:00
|
|
|
?. (~(has by invites) term)
|
2020-10-15 18:38:42 +03:00
|
|
|
[~ state]
|
2020-10-21 01:18:30 +03:00
|
|
|
=/ container (~(got by invites) term)
|
2020-10-22 20:17:15 +03:00
|
|
|
=/ invite (~(get by container) serial)
|
2020-10-15 18:38:42 +03:00
|
|
|
?~ invite
|
|
|
|
[~ state]
|
2020-10-22 20:17:15 +03:00
|
|
|
=. container (~(del by container) serial)
|
|
|
|
:- (send-diff term [%decline term serial])
|
2020-10-21 01:18:30 +03:00
|
|
|
state(invites (~(put by invites) term container))
|
2020-10-15 18:38:42 +03:00
|
|
|
::
|
|
|
|
++ update-subscribers
|
2020-10-22 20:17:15 +03:00
|
|
|
|= [=path =update:store]
|
2020-10-15 18:38:42 +03:00
|
|
|
^- card
|
2020-10-22 20:17:15 +03:00
|
|
|
[%give %fact ~[path] %invite-update !>(update)]
|
2020-10-15 18:38:42 +03:00
|
|
|
::
|
|
|
|
++ send-diff
|
2020-10-22 20:17:15 +03:00
|
|
|
|= [=term =update:store]
|
2020-10-15 18:38:42 +03:00
|
|
|
^- (list card)
|
2020-10-22 20:17:15 +03:00
|
|
|
:~ (update-subscribers /all update)
|
|
|
|
(update-subscribers /updates update)
|
|
|
|
(update-subscribers /invitatory/[term] update)
|
2020-10-15 18:38:42 +03:00
|
|
|
==
|
2019-11-21 02:38:32 +03:00
|
|
|
--
|
|
|
|
::
|
2020-10-15 18:38:42 +03:00
|
|
|
++ on-peek
|
|
|
|
|= =path
|
2019-11-21 02:38:32 +03:00
|
|
|
^- (unit (unit cage))
|
2020-10-15 18:38:42 +03:00
|
|
|
?+ path (on-peek:def path)
|
2020-10-21 01:18:30 +03:00
|
|
|
[%x %all ~]
|
|
|
|
``noun+!>(invites)
|
2020-10-15 18:38:42 +03:00
|
|
|
::
|
2020-10-21 01:18:30 +03:00
|
|
|
[%x %invitatory @ ~]
|
|
|
|
:^ ~ ~ %noun
|
2020-10-22 20:17:15 +03:00
|
|
|
!> ^- (unit invitatory:store)
|
2020-10-21 01:18:30 +03:00
|
|
|
(~(get by invites) i.t.t.path)
|
2020-10-15 18:38:42 +03:00
|
|
|
::
|
2020-10-21 01:18:30 +03:00
|
|
|
[%x %invite @ @ ~]
|
|
|
|
=* term i.t.t.path
|
2020-10-22 20:17:15 +03:00
|
|
|
=/ =serial:store (slav %uv i.t.t.t.path)
|
2020-10-21 01:18:30 +03:00
|
|
|
?. (~(has by invites) term)
|
2020-10-15 18:38:42 +03:00
|
|
|
~
|
2020-10-22 20:17:15 +03:00
|
|
|
=/ =invitatory:store (~(got by invites) term)
|
2020-10-21 01:18:30 +03:00
|
|
|
:^ ~ ~ %noun
|
2020-10-22 20:17:15 +03:00
|
|
|
!> ^- (unit invite:store)
|
|
|
|
(~(get by invitatory) serial)
|
2020-12-01 00:07:26 +03:00
|
|
|
::
|
|
|
|
[%x %export ~] ``noun+!>(state)
|
2020-10-21 01:18:30 +03:00
|
|
|
==
|
2019-11-21 02:38:32 +03:00
|
|
|
--
|