2020-09-01 04:54:39 +03:00
|
|
|
:: contact-store [landscape]:
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
:: data store that holds individual contact data
|
2019-11-19 01:41:08 +03:00
|
|
|
::
|
2021-01-12 00:09:41 +03:00
|
|
|
/- store=contact-store, *resource
|
2021-02-12 07:39:15 +03:00
|
|
|
/+ default-agent, dbug, *migrate, contact, verb
|
2019-12-10 02:13:52 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
2021-01-12 00:09:41 +03:00
|
|
|
+$ state-4
|
|
|
|
$: %4
|
|
|
|
=rolodex:store
|
|
|
|
allowed-groups=(set resource)
|
|
|
|
allowed-ships=(set ship)
|
2021-01-28 02:20:42 +03:00
|
|
|
is-public=_|
|
2021-01-12 00:09:41 +03:00
|
|
|
==
|
2019-12-10 02:13:52 +03:00
|
|
|
+$ versioned-state
|
2021-01-08 01:49:24 +03:00
|
|
|
$% [%0 *]
|
|
|
|
[%1 *]
|
|
|
|
[%2 *]
|
|
|
|
[%3 *]
|
|
|
|
state-4
|
2020-07-23 10:54:45 +03:00
|
|
|
==
|
2019-12-10 02:13:52 +03:00
|
|
|
--
|
2019-11-19 01:41:08 +03:00
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
=| state-4
|
2019-12-10 02:13:52 +03:00
|
|
|
=* state -
|
2020-03-12 03:33:48 +03:00
|
|
|
%- agent:dbug
|
2021-02-12 07:39:15 +03:00
|
|
|
%+ verb |
|
2019-12-10 02:13:52 +03:00
|
|
|
^- agent:gall
|
2021-01-08 01:49:24 +03:00
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
2021-02-03 02:04:28 +03:00
|
|
|
con ~(. contact bowl)
|
2021-01-08 01:49:24 +03:00
|
|
|
::
|
2021-01-27 01:18:01 +03:00
|
|
|
++ on-init
|
|
|
|
=. rolodex (~(put by rolodex) our.bowl *contact:store)
|
|
|
|
[~ this(state state)]
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old-vase=vase
|
|
|
|
^- (quip card _this)
|
|
|
|
=/ old !<(versioned-state old-vase)
|
2021-01-27 00:22:33 +03:00
|
|
|
?+ -.old
|
|
|
|
=. rolodex (~(put by rolodex) our.bowl *contact:store)
|
|
|
|
[~ this(state state)]
|
|
|
|
::
|
2021-01-11 22:39:36 +03:00
|
|
|
%4 [~ this(state old)]
|
2021-01-08 01:49:24 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
|^
|
|
|
|
=/ cards=(list card)
|
|
|
|
?+ path (on-watch:def path)
|
2021-01-28 23:45:28 +03:00
|
|
|
[%all ~] (give [%initial rolodex is-public])
|
2021-01-08 01:49:24 +03:00
|
|
|
[%updates ~] ~
|
2021-01-20 00:07:11 +03:00
|
|
|
::
|
|
|
|
[%our ~]
|
|
|
|
%- give
|
|
|
|
:+ %add
|
|
|
|
our.bowl
|
|
|
|
=/ contact=(unit contact:store) (~(get by rolodex) our.bowl)
|
|
|
|
?~ contact *contact:store
|
|
|
|
u.contact
|
2021-01-08 01:49:24 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
2019-12-10 02:13:52 +03:00
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ give
|
2021-01-12 00:09:41 +03:00
|
|
|
|= =update:store
|
2021-01-08 01:49:24 +03:00
|
|
|
^- (list card)
|
2021-01-12 00:09:41 +03:00
|
|
|
[%give %fact ~ [%contact-update !>(update)]]~
|
2021-01-08 01:49:24 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
|^
|
|
|
|
=^ cards state
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%contact-update (update !<(update:store vase))
|
|
|
|
%import (import q.vase)
|
|
|
|
==
|
|
|
|
[cards this]
|
2019-12-10 02:13:52 +03:00
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ update
|
|
|
|
|= =update:store
|
|
|
|
^- (quip card _state)
|
2019-12-10 02:13:52 +03:00
|
|
|
|^
|
2021-01-08 01:49:24 +03:00
|
|
|
?- -.update
|
2021-01-28 02:20:42 +03:00
|
|
|
%initial (handle-initial +.update)
|
|
|
|
%add (handle-add +.update)
|
|
|
|
%remove (handle-remove +.update)
|
|
|
|
%edit (handle-edit +.update)
|
|
|
|
%allow (handle-allow +.update)
|
|
|
|
%disallow (handle-disallow +.update)
|
|
|
|
%set-public (handle-set-public +.update)
|
2021-01-08 01:49:24 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-initial
|
2021-02-18 22:19:52 +03:00
|
|
|
|= [rolo=rolodex:store *]
|
2021-01-08 01:49:24 +03:00
|
|
|
^- (quip card _state)
|
2021-02-02 00:28:52 +03:00
|
|
|
=/ our-contact (~(got by rolodex) our.bowl)
|
2021-02-13 07:51:42 +03:00
|
|
|
=/ diff-rolo=rolodex:store
|
|
|
|
%- ~(gas by *rolodex:store)
|
|
|
|
%+ skim ~(tap in rolo)
|
|
|
|
|= [=ship =contact:store]
|
|
|
|
?~ local-con=(~(get by rolodex) ship) %.y
|
|
|
|
(gth last-updated.contact last-updated.u.local-con)
|
2021-02-13 08:14:36 +03:00
|
|
|
=/ new-rolo=rolodex:store
|
|
|
|
(~(uni by rolodex) diff-rolo)
|
|
|
|
=. new-rolo (~(put by new-rolo) our.bowl our-contact)
|
|
|
|
?: =(new-rolo rolodex) `state
|
|
|
|
:_ state(rolodex new-rolo)
|
|
|
|
(send-diff [%initial new-rolo is-public] %.n)
|
2021-01-08 01:49:24 +03:00
|
|
|
::
|
|
|
|
++ handle-add
|
|
|
|
|= [=ship =contact:store]
|
|
|
|
^- (quip card _state)
|
2021-02-05 21:33:25 +03:00
|
|
|
:: ensure difference
|
|
|
|
=/ old=(unit contact:store) (~(get by rolodex) ship)
|
2021-02-05 22:19:53 +03:00
|
|
|
?. ?| ?=(~ old)
|
2021-02-05 21:33:25 +03:00
|
|
|
!=(contact(last-updated *@da) u.old(last-updated *@da))
|
|
|
|
==
|
2021-02-05 22:19:53 +03:00
|
|
|
[~ state]
|
2021-01-20 00:07:11 +03:00
|
|
|
:- (send-diff [%add ship contact] =(ship our.bowl))
|
2021-01-08 01:49:24 +03:00
|
|
|
state(rolodex (~(put by rolodex) ship contact))
|
|
|
|
::
|
|
|
|
++ handle-remove
|
|
|
|
|= =ship
|
|
|
|
^- (quip card _state)
|
2021-02-05 22:19:53 +03:00
|
|
|
?. (~(has by rolodex) ship)
|
|
|
|
[~ state]
|
2021-01-20 00:07:11 +03:00
|
|
|
:- (send-diff [%remove ship] =(ship our.bowl))
|
2021-01-27 00:22:33 +03:00
|
|
|
?: =(ship our.bowl)
|
2021-01-27 00:41:34 +03:00
|
|
|
state(rolodex (~(put by rolodex) our.bowl *contact:store))
|
2021-01-08 01:49:24 +03:00
|
|
|
state(rolodex (~(del by rolodex) ship))
|
|
|
|
::
|
|
|
|
++ handle-edit
|
2021-02-12 03:52:26 +03:00
|
|
|
|= [=ship =edit-field:store timestamp=@da]
|
2021-01-12 00:09:41 +03:00
|
|
|
|^
|
2021-01-08 01:49:24 +03:00
|
|
|
^- (quip card _state)
|
2021-02-18 20:51:15 +03:00
|
|
|
=/ old (fall (~(get by rolodex) ship) *contact:store)
|
2021-02-12 03:56:52 +03:00
|
|
|
?: (lte timestamp last-updated.old)
|
2021-02-12 03:42:46 +03:00
|
|
|
[~ state]
|
2021-02-05 22:19:53 +03:00
|
|
|
=/ contact (edit-contact old edit-field)
|
|
|
|
?: =(old contact)
|
|
|
|
[~ state]
|
2021-02-12 03:47:36 +03:00
|
|
|
=. last-updated.contact timestamp
|
2021-02-12 03:52:26 +03:00
|
|
|
:- (send-diff [%edit ship edit-field timestamp] =(ship our.bowl))
|
2021-01-08 01:49:24 +03:00
|
|
|
state(rolodex (~(put by rolodex) ship contact))
|
2021-01-12 00:09:41 +03:00
|
|
|
::
|
|
|
|
++ edit-contact
|
|
|
|
|= [=contact:store edit=edit-field:store]
|
|
|
|
^- contact:store
|
|
|
|
?- -.edit
|
2021-01-27 00:22:33 +03:00
|
|
|
%nickname contact(nickname nickname.edit)
|
|
|
|
%bio contact(bio bio.edit)
|
|
|
|
%status contact(status status.edit)
|
|
|
|
%color contact(color color.edit)
|
|
|
|
%avatar contact(avatar avatar.edit)
|
|
|
|
%cover contact(cover cover.edit)
|
|
|
|
::
|
|
|
|
%add-group
|
|
|
|
contact(groups (~(put in groups.contact) resource.edit))
|
|
|
|
::
|
|
|
|
%remove-group
|
|
|
|
contact(groups (~(del in groups.contact) resource.edit))
|
2021-01-12 00:09:41 +03:00
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ handle-allow
|
|
|
|
|= =beings:store
|
|
|
|
^- (quip card _state)
|
2021-01-20 00:07:11 +03:00
|
|
|
:- (send-diff [%allow beings] %.n)
|
2021-01-12 00:09:41 +03:00
|
|
|
?- -.beings
|
|
|
|
%group state(allowed-groups (~(put in allowed-groups) resource.beings))
|
|
|
|
%ships state(allowed-ships (~(uni in allowed-ships) ships.beings))
|
|
|
|
==
|
2021-01-08 01:49:24 +03:00
|
|
|
::
|
2021-01-12 00:09:41 +03:00
|
|
|
++ handle-disallow
|
|
|
|
|= =beings:store
|
|
|
|
^- (quip card _state)
|
2021-01-20 00:07:11 +03:00
|
|
|
:- (send-diff [%disallow beings] %.y)
|
2021-01-12 00:09:41 +03:00
|
|
|
?- -.beings
|
|
|
|
%group state(allowed-groups (~(del in allowed-groups) resource.beings))
|
|
|
|
%ships state(allowed-ships (~(dif in allowed-ships) ships.beings))
|
2019-12-10 02:13:52 +03:00
|
|
|
==
|
|
|
|
::
|
2021-01-28 02:20:42 +03:00
|
|
|
++ handle-set-public
|
|
|
|
|= public=?
|
|
|
|
^- (quip card _state)
|
|
|
|
:_ state(is-public public)
|
|
|
|
(send-diff [%set-public public] %.n)
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ send-diff
|
2021-01-20 00:07:11 +03:00
|
|
|
|= [=update:store our=?]
|
2019-12-10 02:13:52 +03:00
|
|
|
^- (list card)
|
2021-01-20 00:07:11 +03:00
|
|
|
=/ paths=(list path)
|
|
|
|
?: our
|
2021-01-27 01:18:01 +03:00
|
|
|
[/updates /our /all ~]
|
|
|
|
[/updates /all ~]
|
2021-01-20 00:07:11 +03:00
|
|
|
[%give %fact paths %contact-update !>(update)]~
|
2019-12-10 02:13:52 +03:00
|
|
|
--
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ import
|
|
|
|
|= arc=*
|
|
|
|
^- (quip card _state)
|
2021-01-11 22:39:36 +03:00
|
|
|
:: note: we are purposefully wiping all state before state-4
|
2021-01-08 01:49:24 +03:00
|
|
|
[~ *state-4]
|
2019-12-10 02:13:52 +03:00
|
|
|
--
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ on-peek
|
2019-12-10 02:13:52 +03:00
|
|
|
|= =path
|
2021-01-08 01:49:24 +03:00
|
|
|
^- (unit (unit cage))
|
|
|
|
?+ path (on-peek:def path)
|
|
|
|
[%x %all ~] ``noun+!>(rolodex)
|
|
|
|
::
|
|
|
|
[%x %contact @ ~]
|
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
=/ contact=(unit contact:store) (~(get by rolodex) ship)
|
2021-01-12 00:09:41 +03:00
|
|
|
?~ contact [~ ~]
|
2021-01-08 01:49:24 +03:00
|
|
|
:- ~ :- ~ :- %contact-update
|
|
|
|
!> ^- update:store
|
|
|
|
[%add ship u.contact]
|
2021-01-20 00:07:11 +03:00
|
|
|
::
|
|
|
|
[%x %allowed-ship @ ~]
|
|
|
|
=/ =ship (slav %p i.t.t.path)
|
|
|
|
``noun+!>((~(has in allowed-ships) ship))
|
2021-02-02 22:36:05 +03:00
|
|
|
::
|
|
|
|
[%x %is-public ~]
|
|
|
|
``noun+!>(is-public)
|
2021-01-20 00:07:11 +03:00
|
|
|
::
|
|
|
|
[%x %allowed-groups ~]
|
|
|
|
``noun+!>(allowed-groups)
|
2021-02-03 02:04:28 +03:00
|
|
|
|
|
|
|
::
|
2021-02-03 04:13:33 +03:00
|
|
|
[%x %is-allowed @ @ @ @ ~]
|
|
|
|
=/ is-personal =(i.t.t.t.t.t.path 'true')
|
|
|
|
=/ =resource
|
|
|
|
?: is-personal
|
|
|
|
[our.bowl %'']
|
|
|
|
[(slav %p i.t.t.path) i.t.t.t.path]
|
2021-02-03 02:29:42 +03:00
|
|
|
=/ =ship (slav %p i.t.t.t.t.path)
|
|
|
|
``json+!>(`json`b+(is-allowed:con resource ship))
|
2019-11-19 01:41:08 +03:00
|
|
|
==
|
|
|
|
::
|
2021-01-08 01:49:24 +03:00
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-agent on-agent:def
|
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
2019-11-19 01:41:08 +03:00
|
|
|
--
|