apps: updated style and added moon support

This commit is contained in:
Logan Allen 2019-10-02 14:58:38 -07:00
parent 8b74a674f3
commit 2625efd485
7 changed files with 115 additions and 181 deletions

View File

@ -54,7 +54,7 @@
^- (quip move _this)
?> ?=(%message -.act)
:: local
?: =(src.bol our.bol)
?: (team:title our.bol src.bol)
?. (~(has by synced) path.act)
[~ this]
=/ ship (~(got by synced) path.act)
@ -80,8 +80,7 @@
^- (quip move _this)
?- -.act
%add-owned
?. =(src.bol our.bol)
[~ this]
?> (team:title our.bol src.bol)
=/ chat-path [%mailbox path.act]
=/ chat-wire [(scot %p our.bol) chat-path]
?: (~(has by synced) path.act)
@ -93,8 +92,7 @@
(create-permission [%chat path.act] security.act)
::
%add-synced
?. =(src.bol our.bol)
[~ this]
?> (team:title our.bol src.bol)
=/ chat-path [%mailbox path.act]
=/ chat-wire [(scot %p ship.act) chat-path]
?: (~(has by synced) path.act)
@ -107,8 +105,8 @@
=/ ship (~(get by synced) path.act)
?~ ship
[~ this]
?: &(=(u.ship our.bol) =(our.bol src.bol))
:: delete one of our own paths
?: &(=(u.ship our.bol) (team:title our.bol src.bol))
:: delete one of our.bol own paths
=/ chat-wire [(scot %p our.bol) %mailbox path.act]
:_
%_ this
@ -126,7 +124,7 @@
^- move
[bone %quit ~]
==
?: |(=(u.ship src.bol) =(our.bol src.bol))
?: |(=(u.ship src.bol) (team:title our.bol src.bol))
:: delete a foreign ship's path
=/ chat-wire [(scot %p u.ship) %mailbox path.act]
:_
@ -156,7 +154,7 @@
++ diff-chat-update
|= [wir=wire diff=chat-update]
^- (quip move _this)
?: =(src.bol our.bol)
?: (team:title our.bol src.bol)
(handle-local diff)
(handle-foreign diff)
::
@ -210,10 +208,10 @@
:: send a create poke to local chat
?~ path.diff
[~ this]
=/ sync (~(get by synced) path.diff)
?~ sync
=/ shp (~(get by synced) path.diff)
?~ shp
[~ this]
?. =(src.bol u.sync)
?. (team:title u.shp src.bol)
[~ this]
:_ this
:~ (chat-poke diff)
@ -223,10 +221,10 @@
:: send a delete poke to local chat
?~ path.diff
[~ this]
=/ sync (~(get by synced) path.diff)
?~ sync
=/ shp (~(get by synced) path.diff)
?~ shp
[~ this]
?. =(src.bol u.sync)
?. (team:title u.shp src.bol)
[~ this]
=/ chat-wire [(scot %p src.bol) %mailbox path.diff]
:_ this(synced (~(del by synced) path.diff))
@ -250,27 +248,25 @@
++ quit
|= wir=wire
^- (quip move _this)
=/ wir `(list @tas)`wir
=/ =ship (slav %p &1:wir)
=. wir ?^ wir t.wir ~
=. wir ?^ wir t.wir ~
?: (~(has by synced) wir)
=^ =ship wir
?> ?=([* ^] wir)
[(slav %p i.wir) t.t.wir]
?. (~(has by synced) wir)
:: no-op
[~ this]
=/ chat-path [%mailbox wir]
=/ chat-wire [(scot %p ship) chat-path]
:_ (track-bone chat-wire)
[ost.bol %peer chat-wire [ship %chat-hook] chat-path]~
:: no-op
[~ this]
::
++ reap
|= [wir=wire saw=(unit tang)]
^- (quip move _this)
?~ saw
[~ this]
=/ wir `(list @tas)`wir
=/ =ship (slav %p &1:wir)
=. wir ?^ wir t.wir ~
=. wir ?^ wir t.wir ~
=^ =ship wir
?> ?=([* ^] wir)
[(slav %p i.wir) t.t.wir]
[~ this(synced (~(del by synced) wir))]
::
++ chat-poke
@ -328,22 +324,13 @@
++ chat-scry
|= pax=path
^- (unit mailbox)
=. pax ;: weld
`path`/=chat-store/(scot %da now.bol)/mailbox
pax
`path`/noun
==
=. pax ;:(weld /=chat-store/(scot %da now.bol)/mailbox pax /noun)
.^((unit mailbox) %gx pax)
::
++ permitted-scry
|= pax=path
^- ?
=. pax ;: weld
`path`/=permission-store/(scot %da now.bol)/permitted
pax
`path`/noun
==
.^(? %gx pax)
.^(? %gx ;:(weld /=permission-store/(scot %da now.bol)/permitted pax /noun))
::
++ track-bone
|= wir=wire

View File

@ -111,7 +111,7 @@
++ peer-keys
|= pax=path
^- (quip move _this)
?. =(src.bol our.bol) !!
?> (team:title our.bol src.bol)
:: we send the list of keys then send events when they change
:_ this
[ost.bol %diff %chat-update [%keys ~(key by inbox)]]~
@ -119,28 +119,28 @@
++ peer-all
|= pax=path
^- (quip move _this)
?. =(src.bol our.bol) !!
?> (team:title our.bol src.bol)
:_ this
[ost.bol %diff %chat-initial inbox]~
::
++ peer-configs
|= pax=path
^- (quip move _this)
?. =(src.bol our.bol) !!
?> (team:title our.bol src.bol)
:_ this
[ost.bol %diff %chat-configs (inbox-to-configs inbox)]~
::
++ peer-updates
|= pax=path
^- (quip move _this)
?. =(src.bol our.bol) !!
?> (team:title our.bol src.bol)
:: we now proxy all events to this path
[~ this]
::
++ peer-mailbox
|= pax=path
^- (quip move _this)
?. =(src.bol our.bol) !!
?> (team:title our.bol src.bol)
=/ box=(unit mailbox) (~(get by inbox) pax)
?~ box !!
:_ this
@ -149,15 +149,13 @@
++ poke-json
|= jon=json
^- (quip move _this)
?. =(src.bol our.bol)
[~ this]
?> (team:title our.bol src.bol)
(poke-chat-action (json-to-action jon))
::
++ poke-chat-action
|= action=chat-action
^- (quip move _this)
?. =(src.bol our.bol)
[~ this]
?> (team:title our.bol src.bol)
?- -.action
%create
(handle-create action)
@ -203,7 +201,7 @@
=/ mailbox=(unit mailbox) (~(get by inbox) path.act)
?~ mailbox
[~ this]
=. length.config.u.mailbox (add 1 length.config.u.mailbox)
=. length.config.u.mailbox +(length.config.u.mailbox)
=. number.envelope.act length.config.u.mailbox
=. envelopes.u.mailbox (snoc envelopes.u.mailbox envelope.act)
=. inbox (~(put by inbox) path.act u.mailbox)
@ -222,38 +220,26 @@
:_ this(inbox inbox)
(send-diff path.act act)
::
++ update-subscribers
|= [pax=path act=chat-action]
^- (list move)
%+ turn (prey:pubsub:userlib pax bol)
|= [=bone *]
[bone %diff %chat-update act]
::
++ send-diff
|= [pax=path act=chat-action]
^- (list move)
;: weld
^- (list move)
%+ turn (prey:pubsub:userlib /all bol)
|= [=bone *]
[bone %diff %chat-update act]
::
^- (list move)
%+ turn (prey:pubsub:userlib /updates bol)
|= [=bone *]
[bone %diff %chat-update act]
::
%- zing
:~ (update-subscribers /all act)
(update-subscribers /updates act)
(update-subscribers [%mailbox pax] act)
?. |(=(%read -.act) =(%message -.act))
~
^- (list move)
%+ turn (prey:pubsub:userlib /configs bol)
|= [=bone *]
[bone %diff %chat-update act]
::
^- (list move)
%+ turn (prey:pubsub:userlib [%mailbox pax] bol)
|= [=bone *]
[bone %diff %chat-update act]
::
^- (list move)
(update-subscribers /configs act)
?. |(=(%create -.act) =(%delete -.act))
~
%+ turn (prey:pubsub:userlib /keys bol)
|= [=bone *]
[bone %diff %chat-update act]
(update-subscribers /keys act)
==
::
--

View File

@ -249,11 +249,7 @@
++ envelope-scry
|= pax=path
^- (list envelope)
=. pax ;: weld
`path`/=chat-store/(scot %da now.bol)/envelopes
pax
`path`/noun
==
=. pax ;:(weld /=chat-store/(scot %da now.bol)/envelopes pax /noun)
.^((list envelope) %gx pax)
::
++ all-scry

View File

@ -39,7 +39,7 @@
^- (quip move _this)
?- -.act
%add
?. =(src.bol our.bol)
?. (team:title our.bol src.bol)
[~ this]
=/ group-path [%group path.act]
=/ group-wire [(scot %p ship.act) group-path]
@ -55,7 +55,7 @@
=/ ship (~(get by synced) path.act)
?~ ship
[~ this]
?: &(=(u.ship our.bol) =(our.bol src.bol))
?: &(=(u.ship our.bol) (team:title our.bol src.bol))
:: delete one of our own paths
=/ group-wire [(scot %p our.bol) %group path.act]
:_ this(synced (~(del by synced) path.act))
@ -66,7 +66,7 @@
|= [=bone *]
^- move
[bone %quit ~]
?: |(=(u.ship src.bol) =(our.bol src.bol))
?: |(=(u.ship src.bol) (team:title our.bol src.bol))
:: delete a foreign ship's path
=/ group-wire [(scot %p u.ship) %group path.act]
:_ this(synced (~(del by synced) path.act))
@ -89,7 +89,7 @@
++ diff-group-update
|= [wir=wire diff=group-update]
^- (quip move _this)
?: =(src.bol our.bol)
?: (team:title our.bol src.bol)
(handle-local diff)
(handle-foreign diff)
::
@ -192,27 +192,25 @@
++ quit
|= wir=wire
^- (quip move _this)
=/ wir `(list @tas)`wir
=/ =ship (slav %p &1:wir)
=. wir ?^ wir t.wir ~
=. wir ?^ wir t.wir ~
?: (~(has by synced) wir)
=^ =ship wir
?> ?=([* ^] wir)
[(slav %p i.wir) t.t.wir]
?. (~(has by synced) wir)
:: no-op
[~ this]
=/ group-path [%group wir]
=/ group-wire [(scot %p ship) group-path]
:_ (track-bone group-wire)
[ost.bol %peer group-wire [ship %group-hook] group-path]~
:: no-op
[~ this]
::
++ reap
|= [wir=wire saw=(unit tang)]
^- (quip move _this)
?~ saw
[~ this]
=/ wir `(list @tas)`wir
=/ =ship (slav %p &1:wir)
=. wir ?^ wir t.wir ~
=. wir ?^ wir t.wir ~
=^ =ship wir
?> ?=([* ^] wir)
[(slav %p i.wir) t.t.wir]
~& %insufficient-permissions-for-group
[((slog u.saw) ~) this(synced (~(del by synced) wir))]
::
@ -224,12 +222,7 @@
++ group-scry
|= pax=path
^- (unit group)
=. pax ;: weld
`path`/=group-store/(scot %da now.bol)
pax
`path`/noun
==
.^((unit group) %gx pax)
.^((unit group) %gx ;:(weld /=group-store/(scot %da now.bol) pax /noun))
::
++ track-bone
|= wir=wire

View File

@ -40,7 +40,7 @@
++ peer-all
|= pax=path
^- (quip move _this)
?. =(src.bol our.bol) !!
?> (team:title our.bol src.bol)
:: we now proxy all events to this path
:_ this
[ost.bol %diff %group-initial groups]~
@ -48,7 +48,7 @@
++ peer-keys
|= pax=path
^- (quip move _this)
?. =(src.bol our.bol) !!
?> (team:title our.bol src.bol)
:: we send the list of keys then send events when they change
:_ this
[ost.bol %diff %group-update [%keys ~(key by groups)]]~
@ -56,7 +56,7 @@
++ peer-group
|= pax=path
^- (quip move _this)
?. =(src.bol our.bol) !!
?> (team:title our.bol src.bol)
=/ grp=(unit group) (~(get by groups) pax)
?~ grp !!
:_ this
@ -65,8 +65,7 @@
++ poke-group-action
|= action=group-action
^- (quip move _this)
?. =(src.bol our.bol)
[~ this]
?> (team:title our.bol src.bol)
?- -.action
%add (handle-add action)
%remove (handle-remove action)
@ -126,26 +125,22 @@
:- (send-diff pax.act act)
this(groups (~(del by groups) pax.act))
::
++ update-subscribers
|= [pax=path act=group-action]
^- (list move)
%+ turn (prey:pubsub:userlib pax bol)
|= [=bone *]
[bone %diff %group-update act]
::
++ send-diff
|= [pax=path action=group-action]
|= [pax=path act=group-action]
^- (list move)
;: weld
^- (list move)
%+ turn (prey:pubsub:userlib /all bol)
|= [=bone *]
[bone %diff %group-update action]
::
^- (list move)
%+ turn (prey:pubsub:userlib [%group pax] bol)
|= [=bone *]
[bone %diff %group-update action]
::
^- (list move)
?. |(=(%bundle -.action) =(%unbundle -.action))
%- zing
:~ (update-subscribers /all act)
(update-subscribers [%group pax] act)
?. |(=(%bundle -.act) =(%unbundle -.act))
~
%+ turn (prey:pubsub:userlib /keys bol)
|= [=bone *]
[bone %diff %group-update action]
(update-subscribers /keys act)
==
::
--

View File

@ -45,15 +45,13 @@
++ poke-json
|= =json
^- (quip move _this)
?. =(src.bol our.bol)
[~ this]
?> (team:title our.bol src.bol)
(poke-permission-group-hook-action (json-to-perm-group-hook-action json))
::
++ poke-permission-group-hook-action
|= act=permission-group-hook-action
^- (quip move _this)
?. =(src.bol our.bol)
[~ this]
?> (team:title our.bol src.bol)
?- -.act
%associate (handle-associate group.act permissions.act)
%dissociate (handle-dissociate group.act permissions.act)
@ -67,22 +65,19 @@
=/ permissions
%- silt
%+ turn ~(tap in permission-paths)
|= [=path =kind]
path
|=([=path =kind] path)
?~ perms
=/ group-path [%group group]
:_ this(relation (~(put by relation) group permissions))
[ost.bol %peer group-path [our.bol %group-store] group-path]~
::
=. u.perms (~(uni in u.perms) permissions)
:_ this(relation (~(put by relation) group u.perms))
%+ weld
%+ turn ~(tap in permissions)
|= =path
^- move
(permission-poke path [%delete path])
|=(=path (permission-poke path [%delete path]))
%+ turn ~(tap in permission-paths)
|= [=path =kind]
^- move
=/ pem *permission
=. kind.pem kind
(permission-poke path [%create path pem])
@ -93,13 +88,12 @@
=/ perms (~(get by relation) group)
?~ perms
[~ this]
::
=. permissions (~(del in u.perms) permissions)
?~ permissions
:_ this(relation (~(del by relation) group))
:~ (group-pull [%group group])
==
:- ~
this(relation (~(put by relation) group permissions))
[(group-pull [%group group])]~
[~ this(relation (~(put by relation) group permissions))]
::
++ diff-group-update
|= [wir=wire diff=group-update]
@ -117,7 +111,6 @@
:_ this
%+ turn ~(tap in u.perms)
|= =path
^- move
(permission-poke path [%add path members.diff])
::
%add
@ -128,7 +121,6 @@
:_ this
%+ turn ~(tap in u.perms)
|= =path
^- move
(permission-poke path [%add path members.diff])
::
%remove
@ -139,7 +131,6 @@
:_ this
%+ turn ~(tap in u.perms)
|= =path
^- move
(permission-poke path [%remove path members.diff])
::
%unbundle
@ -147,13 +138,11 @@
=/ perms (~(get by relation) pax.diff)
?~ perms
:_ this(relation (~(del by relation) pax.diff))
:~ (group-pull [%group pax.diff])
==
[(group-pull [%group pax.diff])]~
:_ this(relation (~(del by relation) pax.diff))
:- (group-pull [%group pax.diff])
%+ turn ~(tap in u.perms)
|= =path
^- move
(permission-poke path [%delete path])
::
==
@ -183,14 +172,4 @@
^- move
[ost.bol %pull [%group path] [our.bol %group-store] ~]
::
++ permission-scry
|= pax=path
^- (unit permission)
=. pax ;: weld
`path`/=permission-store/(scot %da now.bol)/permission
pax
`path`/noun
==
.^((unit permission) %gx pax)
::
--

View File

@ -25,7 +25,7 @@
++ peer-all
|= =path
^- (quip move _this)
?. =(src.bol our.bol) !!
?> (team:title our.bol src.bol)
:: we now proxy all events to this path
:_ this
[ost.bol %diff %permission-initial permissions]~
@ -34,7 +34,7 @@
|= =path
^- (quip move _this)
?~ path !!
?. =(src.bol our.bol) !!
?> (team:title our.bol src.bol)
?. (~(has by permissions) path) !!
:_ this
[ost.bol %diff %permission-update [%create path (~(got by permissions) path)]]~
@ -67,8 +67,7 @@
++ poke-permission-action
|= action=permission-action
^- (quip move _this)
?. =(src.bol our.bol)
[~ this]
?> (team:title our.bol src.bol)
?- -.action
%add (handle-add action)
%remove (handle-remove action)
@ -159,20 +158,19 @@
(handle-add [%add +.act])
(handle-remove [%remove +.act])
::
++ update-subscribers
|= [pax=path upd=permission-update]
^- (list move)
%+ turn (prey:pubsub:userlib pax bol)
|= [=bone *]
[bone %diff %permission-update upd]
::
++ send-diff
|= [pax=path update=permission-update]
|= [pax=path upd=permission-update]
^- (list move)
;: weld
^- (list move)
%+ turn (prey:pubsub:userlib /all bol)
|= [=bone *]
[bone %diff %permission-update update]
::
^- (list move)
%+ turn (prey:pubsub:userlib [%permission pax] bol)
|= [=bone *]
[bone %diff %permission-update update]
::
%- zing
:~ (update-subscribers /all upd)
(update-subscribers [%permission pax] upd)
==
::
--