Merge 'odyssey-wip' into odyssey-chat-cli

This commit is contained in:
Fang 2019-10-08 13:04:49 +02:00
commit b2365c1668
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
21 changed files with 257 additions and 291 deletions

View File

@ -39,13 +39,15 @@
|= old=(unit state) |= old=(unit state)
^- (quip move _this) ^- (quip move _this)
?~ old ?~ old
[~ this] :_ this
[ost.bol %peer /permissions [our.bol %permission-store] /updates]~
[~ this(+<+ u.old)] [~ this(+<+ u.old)]
:: ::
++ poke-noun ++ poke-noun
|= a=* |= a=*
^- (quip move _this) ^- (quip move _this)
~& synced ~& synced
~& boned
[~ this] [~ this]
:: ::
++ poke-json ++ poke-json
@ -58,25 +60,25 @@
^- (quip move _this) ^- (quip move _this)
?> ?=(%message -.act) ?> ?=(%message -.act)
:: local :: local
:_ this
?: (team:title our.bol src.bol) ?: (team:title our.bol src.bol)
?. (~(has by synced) path.act) ?. (~(has by synced) path.act)
[~ this] ~
=/ ship (~(got by synced) path.act) =/ ship (~(got by synced) path.act)
=/ appl ?:(=(ship our.bol) %chat-store %chat-hook) =/ appl ?:(=(ship our.bol) %chat-store %chat-hook)
:_ this
[ost.bol %poke / [ship appl] [%chat-action act]]~ [ost.bol %poke / [ship appl] [%chat-action act]]~
:: foreign :: foreign
=/ ship (~(get by synced) path.act) =/ ship (~(get by synced) path.act)
?~ ship ?~ ship
[~ this] ~
:_ this
?. =(u.ship our.bol) ?. =(u.ship our.bol)
~ ~
:: scry permissions to check if write is permitted :: scry permissions to check if write is permitted
?. (permitted-scry [(scot %p src.bol) %chat (weld path.act /write)]) ?. (permitted-scry [(scot %p src.bol) %chat (weld path.act /write)])
~ ~
=. author.envelope.act src.bol =: author.envelope.act src.bol
=. when.envelope.act now.bol when.envelope.act now.bol
==
[ost.bol %poke / [our.bol %chat-store] [%chat-action act]]~ [ost.bol %poke / [our.bol %chat-store] [%chat-action act]]~
:: ::
++ poke-chat-hook-action ++ poke-chat-hook-action
@ -86,24 +88,22 @@
%add-owned %add-owned
?> (team:title our.bol src.bol) ?> (team:title our.bol src.bol)
=/ chat-path [%mailbox path.act] =/ chat-path [%mailbox path.act]
=/ chat-wire [(scot %p our.bol) chat-path]
?: (~(has by synced) path.act) ?: (~(has by synced) path.act)
[~ this] [~ this]
=. synced (~(put by synced) path.act our.bol) =. synced (~(put by synced) path.act our.bol)
:_ (track-bone chat-wire) :_ (track-bone chat-path)
%+ weld %+ weld
[ost.bol %peer chat-wire [our.bol %chat-store] chat-path]~ [ost.bol %peer chat-path [our.bol %chat-store] chat-path]~
(create-permission [%chat path.act] security.act) (create-permission [%chat path.act] security.act)
:: ::
%add-synced %add-synced
?> (team:title our.bol src.bol) ?> (team:title our.bol src.bol)
=/ chat-path [%mailbox path.act] =/ chat-path [%mailbox (scot %p ship.act) path.act]
=/ chat-wire [(scot %p ship.act) chat-path] ?: (~(has by synced) [(scot %p ship.act) path.act])
?: (~(has by synced) path.act)
[~ this] [~ this]
=. synced (~(put by synced) path.act ship.act) =. synced (~(put by synced) [(scot %p ship.act) path.act] ship.act)
:_ (track-bone chat-wire) :_ (track-bone chat-path)
[ost.bol %peer chat-wire [ship.act %chat-hook] chat-path]~ [ost.bol %peer chat-path [ship.act %chat-hook] chat-path]~
:: ::
%remove %remove
=/ ship (~(get by synced) path.act) =/ ship (~(get by synced) path.act)
@ -111,14 +111,12 @@
[~ this] [~ this]
?: &(=(u.ship our.bol) (team:title our.bol src.bol)) ?: &(=(u.ship our.bol) (team:title our.bol src.bol))
:: delete one of our.bol own paths :: delete one of our.bol own paths
=/ chat-wire [(scot %p our.bol) %mailbox path.act] :_ %_ this
:_
%_ this
synced (~(del by synced) path.act) synced (~(del by synced) path.act)
boned (~(del by boned) chat-wire) boned (~(del by boned) [%mailbox path.act])
== ==
%- zing %- zing
:~ (pull-wire chat-wire path.act) :~ (pull-wire [%mailbox path.act])
(delete-permission [%chat path.act]) (delete-permission [%chat path.act])
^- (list move) ^- (list move)
%+ turn (prey:pubsub:userlib [%mailbox path.act] bol) %+ turn (prey:pubsub:userlib [%mailbox path.act] bol)
@ -126,32 +124,63 @@
^- move ^- move
[bone %quit ~] [bone %quit ~]
== ==
?: |(=(u.ship src.bol) (team:title our.bol src.bol)) ?. |(=(u.ship src.bol) (team:title our.bol src.bol))
:: if neither ship = source or source = us, do nothing
[~ this]
:: delete a foreign ship's path :: delete a foreign ship's path
=/ chat-wire [(scot %p u.ship) %mailbox path.act] :- (pull-wire [%mailbox path.act])
:_
%_ this %_ this
synced (~(del by synced) path.act) synced (~(del by synced) path.act)
boned (~(del by boned) chat-wire) boned (~(del by boned) [%mailbox path.act])
== ==
(pull-wire chat-wire path.act)
:: don't allow
[~ this]
::
== ==
:: ::
++ peer-mailbox ++ peer-mailbox
|= pax=path |= pax=path
^- (quip move _this) ^- (quip move _this)
?~ pax !! ?> ?=([* ^] pax)
?. (~(has by synced) pax) !! ?> (~(has by synced) pax)
:: scry permissions to check if read is permitted :: scry permissions to check if read is permitted
?. (permitted-scry [(scot %p src.bol) %chat (weld pax /read)]) ?> (permitted-scry [(scot %p src.bol) %chat (weld pax /read)])
!! =/ box (chat-scry pax)
=/ box=(unit mailbox) (chat-scry pax)
?~ box !! ?~ box !!
:_ this :_ this
[ost.bol %diff [%chat-update [%create pax owner.config.u.box]]]~ [ost.bol %diff %chat-update [%create (slav %p i.pax) pax]]~
::
++ diff-permission-update
|= [wir=wire diff=permission-update]
^- (quip move _this)
:_ this
?- -.diff
%create ~
%delete ~
%add (handle-permissions [%add path.diff who.diff])
%remove (handle-permissions [%remove path.diff who.diff])
==
::
++ handle-permissions
|= [kind=?(%add %remove) pax=path who=(set ship)]
^- (list move)
?> ?=([* *] pax)
?. =(%chat i.pax) ~
:: check path to see if this is a %read permission
?. =(%read (snag (dec (lent pax)) `(list @t)`pax))
~
=/ sup
%- ~(gas by *(map [ship path] bone))
%+ turn ~(tap by sup.bol)
|=([=bone anchor=[ship path]] [anchor bone])
%- zing
%+ turn ~(tap in who)
|= check-ship=ship
?: (permitted-scry [(scot %p check-ship) pax])
:: if ship is permitted to be subscribed, do nothing
~
:: if ship is not permitted, quit their subscription
=/ mail-path
(oust [(dec (lent t.pax)) (lent t.pax)] `(list @t)`t.pax)
=/ bne (~(get by sup) [check-ship [%mailbox mail-path]])
?~(bne ~ [u.bne %quit ~]~)
:: ::
++ diff-chat-update ++ diff-chat-update
|= [wir=wire diff=chat-update] |= [wir=wire diff=chat-update]
@ -164,25 +193,16 @@
|= diff=chat-update |= diff=chat-update
^- (quip move _this) ^- (quip move _this)
?- -.diff ?- -.diff
%keys %keys [~ this]
[~ this] %config [~ this]
:: %create [~ this]
%config %read [~ this]
[~ this]
::
%create
[~ this]
::
%read
[~ this]
::
%delete %delete
?. (~(has by synced) path.diff) ?. (~(has by synced) path.diff)
[~ this] [~ this]
=/ chat-wire [(scot %p our.bol) %mailbox path.diff]
:_ this(synced (~(del by synced) path.diff)) :_ this(synced (~(del by synced) path.diff))
:- (chat-poke diff) :- (chat-poke diff)
[ost.bol %pull chat-wire [our.bol %chat-store] ~]~ [ost.bol %pull [%mailbox path.diff] [our.bol %chat-store] ~]~
:: ::
%message %message
:_ this :_ this
@ -190,86 +210,66 @@
|= [=bone *] |= [=bone *]
^- move ^- move
[bone %diff [%chat-update diff]] [bone %diff [%chat-update diff]]
::
== ==
:: ::
++ handle-foreign ++ handle-foreign
|= diff=chat-update |= diff=chat-update
^- (quip move _this) ^- (quip move _this)
?- -.diff ?- -.diff
%keys %keys [~ this]
[~ this] %config [~ this]
:: %read [~ this]
%config
[~ this]
::
%read
[~ this]
::
%create %create
:: send a create poke to local chat
?~ path.diff
[~ this]
=/ shp (~(get by synced) path.diff)
?~ shp
[~ this]
?. (team:title u.shp src.bol)
[~ this]
:_ this :_ this
:~ (chat-poke diff) ?> ?=([* ^] path.diff)
== =/ shp (~(get by synced) path.diff)
?~ shp ~
?. =(src.bol u.shp) ~
[(chat-poke [%create ship.diff t.path.diff])]~
:: ::
%delete %delete
:: send a delete poke to local chat ?> ?=([* ^] path.diff)
?~ path.diff
[~ this]
=/ shp (~(get by synced) path.diff) =/ shp (~(get by synced) path.diff)
?~ shp ?~ shp
[~ this] [~ this]
?. (team:title u.shp src.bol) ?. =(u.shp src.bol)
[~ this] [~ this]
=/ chat-wire [(scot %p src.bol) %mailbox path.diff]
:_ this(synced (~(del by synced) path.diff)) :_ this(synced (~(del by synced) path.diff))
:- (chat-poke diff) :- (chat-poke diff)
[ost.bol %pull chat-wire [src.bol %chat-hook] ~]~ [ost.bol %pull [%mailbox path.diff] [src.bol %chat-hook] ~]~
:: ::
%message %message
?~ path.diff
[~ this]
=/ sync (~(get by synced) path.diff)
?~ sync
[~ this]
?. =(src.bol u.sync)
[~ this]
:_ this :_ this
:~ (chat-poke diff) ?> ?=([* ^] path.diff)
== =/ shp (~(get by synced) path.diff)
:: ?~ shp ~
?. =(src.bol u.shp) ~
[(chat-poke diff)]~
== ==
:: ::
++ quit ++ quit
|= wir=wire |= wir=wire
^- (quip move _this) ^- (quip move _this)
=^ =ship wir ~& chat-hook-quit+wir
?: =(wir /permissions)
:_ this
[ost.bol %peer /permissions [our.bol %permission-store] /updates]~
?> ?=([* ^] wir) ?> ?=([* ^] wir)
[(slav %p i.wir) t.t.wir] ?. (~(has by synced) t.wir)
?. (~(has by synced) wir)
:: no-op :: no-op
[~ this] [~ this]
=/ chat-path [%mailbox wir] ~& %chat-hook-resubscribe
=/ chat-wire [(scot %p ship) chat-path] :_ (track-bone wir)
:_ (track-bone chat-wire) [ost.bol %peer wir [(slav %p i.t.wir) %chat-hook] wir]~
[ost.bol %peer chat-wire [ship %chat-hook] chat-path]~
:: ::
++ reap ++ reap
|= [wir=wire saw=(unit tang)] |= [wir=wire saw=(unit tang)]
^- (quip move _this) ^- (quip move _this)
?~ saw ?~ saw
[~ this] [~ this]
=^ =ship wir ?> ?=(^ wir)
?> ?=([* ^] wir) ~& %chat-hook-reap
[(slav %p i.wir) t.t.wir] [((slog u.saw) ~) this(synced (~(del by synced) t.wir))]
[~ this(synced (~(del by synced) wir))]
:: ::
++ chat-poke ++ chat-poke
|= act=chat-action |= act=chat-action
@ -306,7 +306,6 @@
:~ (permission-poke (sec-to-perm read-perm %white)) :~ (permission-poke (sec-to-perm read-perm %white))
(permission-poke (sec-to-perm write-perm %black)) (permission-poke (sec-to-perm write-perm %black))
== ==
::
== ==
:: ::
++ delete-permission ++ delete-permission
@ -343,19 +342,18 @@
this(boned (~(put by boned) wir [ost.bol]~)) this(boned (~(put by boned) wir [ost.bol]~))
:: ::
++ pull-wire ++ pull-wire
|= [wir=wire pax=path] |= pax=path
^- (list move) ^- (list move)
=/ bnd (~(get by boned) wir) ?> ?=([* ^] pax)
?~ bnd =/ bnd (~(get by boned) pax)
~ ?~ bnd ~
=/ shp (~(get by synced) pax) =/ shp (~(get by synced) t.pax)
?~ shp ?~ shp ~
~
%+ turn u.bnd %+ turn u.bnd
|= ost=bone |= =bone
^- move ^- move
?: =(u.shp our.bol) ?: =(u.shp our.bol)
[ost %pull wir [our.bol %chat-store] ~] [bone %pull pax [our.bol %chat-store] ~]
[ost %pull wir [u.shp %chat-hook] ~] [bone %pull pax [u.shp %chat-hook] ~]
:: ::
-- --

View File

@ -31,9 +31,7 @@
++ prep ++ prep
|= old=(unit state) |= old=(unit state)
^- (quip move _this) ^- (quip move _this)
?~ old [~ ?~(old this this(+<+ u.old))]
[~ this]
[~ this(+<+ u.old)]
:: ::
++ peek-x-all ++ peek-x-all
|= pax=path |= pax=path
@ -54,28 +52,23 @@
++ peek-x-mailbox ++ peek-x-mailbox
|= pax=path |= pax=path
^- (unit (unit [%noun (unit mailbox)])) ^- (unit (unit [%noun (unit mailbox)]))
?~ pax ?~ pax ~
~
=/ mailbox=(unit mailbox) (~(get by inbox) pax) =/ mailbox=(unit mailbox) (~(get by inbox) pax)
[~ ~ %noun mailbox] [~ ~ %noun mailbox]
:: ::
++ peek-x-config ++ peek-x-config
|= pax=path |= pax=path
^- (unit (unit [%noun config])) ^- (unit (unit [%noun config]))
?~ pax ?~ pax ~
~
=/ mailbox (~(get by inbox) pax) =/ mailbox (~(get by inbox) pax)
?~ mailbox ?~ mailbox ~
~
:^ ~ ~ %noun :^ ~ ~ %noun
config.u.mailbox config.u.mailbox
:: ::
++ peek-x-envelopes ++ peek-x-envelopes
|= pax=path |= pax=path
^- (unit (unit [%noun (list envelope)])) ^- (unit (unit [%noun (list envelope)]))
?+ pax ?+ pax ~
~
::
[@ @ *] [@ @ *]
=/ mail-path t.t.pax =/ mail-path t.t.pax
=/ mailbox (~(get by inbox) mail-path) =/ mailbox (~(get by inbox) mail-path)
@ -143,10 +136,18 @@
|= pax=path |= pax=path
^- (quip move _this) ^- (quip move _this)
?> (team:title our.bol src.bol) ?> (team:title our.bol src.bol)
=/ box=(unit mailbox) (~(get by inbox) pax) ?> (~(has by inbox) pax)
?~ box !! =^ =ship pax
?> ?=([* ^] pax)
[(slav %p i.pax) t.pax]
:_ this :_ this
[ost.bol %diff %chat-update [%create pax owner.config.u.box]]~ [ost.bol %diff %chat-update [%create ship pax]]~
::
++ poke-noun
|= a=*
^- (quip move _this)
~& inbox
[~ this]
:: ::
++ poke-json ++ poke-json
|= jon=json |= jon=json
@ -159,31 +160,21 @@
^- (quip move _this) ^- (quip move _this)
?> (team:title our.bol src.bol) ?> (team:title our.bol src.bol)
?- -.action ?- -.action
%create %create (handle-create action)
(handle-create action) %delete (handle-delete action)
:: %message (handle-message action)
%delete %read (handle-read action)
(handle-delete action)
::
%message
(handle-message action)
::
%read
(handle-read action)
::
== ==
:: ::
++ handle-create ++ handle-create
|= act=chat-action |= act=chat-action
^- (quip move _this) ^- (quip move _this)
?> ?=(%create -.act) ?> ?=(%create -.act)
?: (~(has by inbox) path.act) =/ pax [(scot %p ship.act) path.act]
?: (~(has by inbox) pax)
[~ this] [~ this]
=/ mailbox *mailbox :- (send-diff pax act)
=. owner.config.mailbox owner.act this(inbox (~(put by inbox) pax *mailbox))
=. inbox (~(put by inbox) path.act mailbox)
:_ this(inbox inbox)
(send-diff path.act act)
:: ::
++ handle-delete ++ handle-delete
|= act=chat-action |= act=chat-action
@ -192,9 +183,8 @@
=/ mailbox=(unit mailbox) (~(get by inbox) path.act) =/ mailbox=(unit mailbox) (~(get by inbox) path.act)
?~ mailbox ?~ mailbox
[~ this] [~ this]
=. inbox (~(del by inbox) path.act) :- (send-diff path.act act)
:_ this(inbox inbox) this(inbox (~(del by inbox) path.act))
(send-diff path.act act)
:: ::
++ handle-message ++ handle-message
|= act=chat-action |= act=chat-action
@ -203,10 +193,11 @@
=/ mailbox=(unit mailbox) (~(get by inbox) path.act) =/ mailbox=(unit mailbox) (~(get by inbox) path.act)
?~ mailbox ?~ mailbox
[~ this] [~ this]
=. length.config.u.mailbox +(length.config.u.mailbox) =: length.config.u.mailbox +(length.config.u.mailbox)
=. number.envelope.act length.config.u.mailbox number.envelope.act length.config.u.mailbox
=. envelopes.u.mailbox (snoc envelopes.u.mailbox envelope.act) envelopes.u.mailbox (snoc envelopes.u.mailbox envelope.act)
=. inbox (~(put by inbox) path.act u.mailbox) inbox (~(put by inbox) path.act u.mailbox)
==
:_ this(inbox inbox) :_ this(inbox inbox)
(send-diff path.act act) (send-diff path.act act)
:: ::
@ -217,8 +208,9 @@
=/ mailbox=(unit mailbox) (~(get by inbox) path.act) =/ mailbox=(unit mailbox) (~(get by inbox) path.act)
?~ mailbox ?~ mailbox
[~ this] [~ this]
=. read.config.u.mailbox length.config.u.mailbox =: read.config.u.mailbox length.config.u.mailbox
=. inbox (~(put by inbox) path.act u.mailbox) inbox (~(put by inbox) path.act u.mailbox)
==
:_ this(inbox inbox) :_ this(inbox inbox)
(send-diff path.act act) (send-diff path.act act)
:: ::

View File

@ -151,18 +151,19 @@
?- -.act ?- -.act
%create %create
:: TODO: add invites :: TODO: add invites
=/ group-read=path [%chat (weld path.act /read)] =/ pax [(scot %p our.bol) path.act]
=/ group-write=path [%chat (weld path.act /write)] =/ group-read=path [%chat (weld pax /read)]
=/ group-write=path [%chat (weld pax /write)]
:_ this :_ this
%+ weld %+ weld
:~ (chat-poke [%create path.act our.bol]) :~ (chat-poke [%create our.bol path.act])
(group-poke [%bundle group-read]) (group-poke [%bundle group-read])
(group-poke [%bundle group-write]) (group-poke [%bundle group-write])
(group-poke [%add read.act group-read]) (group-poke [%add read.act group-read])
(group-poke [%add write.act group-write]) (group-poke [%add write.act group-write])
(chat-hook-poke [%add-owned path.act security.act]) (chat-hook-poke [%add-owned pax security.act])
== ==
(create-security [%chat path.act] security.act) (create-security [%chat pax] security.act)
:: ::
%delete %delete
=/ group-read [%chat (weld path.act /read)] =/ group-read [%chat (weld path.act /read)]
@ -179,7 +180,7 @@
++ peer-initial ++ peer-initial
|= pax=path |= pax=path
^- (quip move _this) ^- (quip move _this)
?. =(src.bol our.bol) !! ?> (team:title our.bol src.bol)
:: create inbox with 100 messages max per mailbox and send that along :: create inbox with 100 messages max per mailbox and send that along
:: then quit the subscription :: then quit the subscription
:_ this :_ this
@ -190,14 +191,14 @@
++ peer-updates ++ peer-updates
|= pax=path |= pax=path
^- (quip move _this) ^- (quip move _this)
?. =(src.bol our.bol) !! ?> (team:title our.bol src.bol)
:: send along all subsequent updates :: send along all subsequent updates
[~ this] [~ this]
:: ::
++ peer-configs ++ peer-configs
|= pax=path |= pax=path
^- (quip move _this) ^- (quip move _this)
?. =(src.bol our.bol) !! ?> (team:title our.bol src.bol)
:_ this :_ this
[ost.bol %diff %json *json]~ [ost.bol %diff %json *json]~
:: ::

File diff suppressed because one or more lines are too long

View File

@ -73,15 +73,14 @@
(pull-wire group-wire path.act) (pull-wire group-wire path.act)
:: don't allow :: don't allow
[~ this] [~ this]
::
== ==
:: ::
++ peer-group ++ peer-group
|= pax=path |= pax=path
^- (quip move _this) ^- (quip move _this)
?~ pax !! ?~ pax !!
?. (~(has by synced) pax) !! ?> (~(has by synced) pax)
=/ grp=(unit group) (group-scry pax) =/ grp (group-scry pax)
?~ grp !! ?~ grp !!
:_ this :_ this
[ost.bol %diff [%group-update [%path u.grp pax]]]~ [ost.bol %diff [%group-update [%path u.grp pax]]]~
@ -100,34 +99,17 @@
%keys [~ this] %keys [~ this]
%path [~ this] %path [~ this]
%bundle [~ this] %bundle [~ this]
%add %add [(update-subscribers [%group pax.diff] diff) this]
:_ this %remove [(update-subscribers [%group pax.diff] diff) this]
%+ turn (prey:pubsub:userlib [%group pax.diff] bol)
|= [=bone *]
^- move
[bone %diff [%group-update diff]]
::
%remove
:_ this
%+ turn (prey:pubsub:userlib [%group pax.diff] bol)
|= [=bone *]
^- move
[bone %diff [%group-update diff]]
:: ::
%unbundle %unbundle
:_ this(synced (~(del by synced) pax.diff)) :_ this(synced (~(del by synced) pax.diff))
%+ weld %+ weld
(update-subscribers [%group pax.diff] diff)
^- (list move) ^- (list move)
%+ turn (prey:pubsub:userlib [%group pax.diff] bol) %+ turn (prey:pubsub:userlib [%group pax.diff] bol)
|= [=bone *] |= [=bone *]
^- move
[bone %diff [%group-update diff]]
^- (list move)
%+ turn (prey:pubsub:userlib [%group pax.diff] bol)
|= [=bone *]
^- move
[bone %quit ~] [bone %quit ~]
::
== ==
:: ::
++ handle-foreign ++ handle-foreign
@ -138,42 +120,31 @@
%bundle [~ this] %bundle [~ this]
:: ::
%path %path
?~ pax.diff
[~ this]
=/ ship (~(get by synced) pax.diff)
?~ ship
[~ this]
?. =(src.bol u.ship)
[~ this]
:_ this :_ this
?~ pax.diff ~
=/ ship (~(get by synced) pax.diff)
?~ ship ~
?. =(src.bol u.ship) ~
:~ (group-poke pax.diff [%unbundle pax.diff]) :~ (group-poke pax.diff [%unbundle pax.diff])
(group-poke pax.diff [%bundle pax.diff]) (group-poke pax.diff [%bundle pax.diff])
(group-poke pax.diff [%add members.diff pax.diff]) (group-poke pax.diff [%add members.diff pax.diff])
== ==
:: ::
%add %add
?~ pax.diff
[~ this]
=/ ship (~(get by synced) pax.diff)
?~ ship
[~ this]
?. =(src.bol u.ship)
[~ this]
:_ this :_ this
:~ (group-poke pax.diff diff) ?~ pax.diff ~
== =/ ship (~(get by synced) pax.diff)
?~ ship ~
?. =(src.bol u.ship) ~
[(group-poke pax.diff diff)]~
:: ::
%remove %remove
?~ pax.diff
[~ this]
=/ ship (~(get by synced) pax.diff)
?~ ship
[~ this]
?. =(src.bol u.ship)
[~ this]
:_ this :_ this
:~ (group-poke pax.diff diff) ?~ pax.diff ~
== =/ ship (~(get by synced) pax.diff)
?~ ship ~
?. =(src.bol u.ship) ~
[(group-poke pax.diff diff)]~
:: ::
%unbundle %unbundle
?~ pax.diff ?~ pax.diff
@ -184,9 +155,7 @@
?. =(src.bol u.ship) ?. =(src.bol u.ship)
[~ this] [~ this]
:_ this(synced (~(del by synced) pax.diff)) :_ this(synced (~(del by synced) pax.diff))
:~ (group-poke pax.diff diff) [(group-poke pax.diff diff)]~
==
::
== ==
:: ::
++ quit ++ quit
@ -196,7 +165,6 @@
?> ?=([* ^] wir) ?> ?=([* ^] wir)
[(slav %p i.wir) t.t.wir] [(slav %p i.wir) t.t.wir]
?. (~(has by synced) wir) ?. (~(has by synced) wir)
:: no-op
[~ this] [~ this]
=/ group-path [%group wir] =/ group-path [%group wir]
=/ group-wire [(scot %p ship) group-path] =/ group-wire [(scot %p ship) group-path]
@ -224,6 +192,14 @@
^- (unit group) ^- (unit group)
.^((unit group) %gx ;:(weld /=group-store/(scot %da now.bol) pax /noun)) .^((unit group) %gx ;:(weld /=group-store/(scot %da now.bol) pax /noun))
:: ::
++ update-subscribers
|= [pax=path diff=group-update]
^- (list move)
%+ turn (prey:pubsub:userlib pax bol)
|= [=bone *]
^- move
[bone %diff [%group-update diff]]
::
++ track-bone ++ track-bone
|= wir=wire |= wir=wire
^+ this ^+ this

View File

@ -25,9 +25,7 @@
++ prep ++ prep
|= old=(unit state) |= old=(unit state)
^- (quip move _this) ^- (quip move _this)
?~ old [~ ?~(old this this(+<+ u.old))]
[~ this]
[~ this(+<+ u.old)]
:: ::
++ peek-x ++ peek-x
|= pax=path |= pax=path
@ -57,10 +55,9 @@
|= pax=path |= pax=path
^- (quip move _this) ^- (quip move _this)
?> (team:title our.bol src.bol) ?> (team:title our.bol src.bol)
=/ grp=(unit group) (~(get by groups) pax) =/ grp (~(got by groups) pax)
?~ grp !!
:_ this :_ this
[ost.bol %diff %group-update [%path u.grp pax]]~ [ost.bol %diff %group-update [%path grp pax]]~
:: ::
++ poke-group-action ++ poke-group-action
|= action=group-action |= action=group-action
@ -81,7 +78,7 @@
[~ this] [~ this]
?. (~(has by groups) pax.act) ?. (~(has by groups) pax.act)
[~ this] [~ this]
=/ members=group (~(got by groups) pax.act) =/ members (~(got by groups) pax.act)
=. members (~(uni in members) members.act) =. members (~(uni in members) members.act)
?: =(members (~(got by groups) pax.act)) ?: =(members (~(got by groups) pax.act))
[~ this] [~ this]

View File

@ -38,9 +38,7 @@
++ prep ++ prep
|= old=(unit state) |= old=(unit state)
^- (quip move _this) ^- (quip move _this)
?~ old [~ ?~(old this this(+<+ u.old))]
[~ this]
[~ this(+<+ u.old)]
:: ::
++ poke-json ++ poke-json
|= =json |= =json
@ -62,9 +60,8 @@
^- (quip move _this) ^- (quip move _this)
=/ perms (~(get by relation) group) =/ perms (~(get by relation) group)
:: if relation does not exist, create it and subscribe. :: if relation does not exist, create it and subscribe.
=/ permissions =/ permissions=(set path)
%- silt %- ~(run in permission-paths)
%+ turn ~(tap in permission-paths)
|=([=path =kind] path) |=([=path =kind] path)
?~ perms ?~ perms
=/ group-path [%group group] =/ group-path [%group group]
@ -144,7 +141,6 @@
%+ turn ~(tap in u.perms) %+ turn ~(tap in u.perms)
|= =path |= =path
(permission-poke path [%delete path]) (permission-poke path [%delete path])
::
== ==
:: ::
++ quit ++ quit

View File

@ -30,12 +30,19 @@
:_ this :_ this
[ost.bol %diff %permission-initial permissions]~ [ost.bol %diff %permission-initial permissions]~
:: ::
++ peer-updates
|= =path
^- (quip move _this)
?> (team:title our.bol src.bol)
:: we now proxy all events to this path
[~ this]
::
++ peer-permission ++ peer-permission
|= =path |= =path
^- (quip move _this) ^- (quip move _this)
?~ path !! ?~ path !!
?> (team:title our.bol src.bol) ?> (team:title our.bol src.bol)
?. (~(has by permissions) path) !! ?> (~(has by permissions) path)
:_ this :_ this
[ost.bol %diff %permission-update [%create path (~(got by permissions) path)]]~ [ost.bol %diff %permission-update [%create path (~(got by permissions) path)]]~
:: ::
@ -170,6 +177,7 @@
^- (list move) ^- (list move)
%- zing %- zing
:~ (update-subscribers /all upd) :~ (update-subscribers /all upd)
(update-subscribers /updates upd)
(update-subscribers [%permission pax] upd) (update-subscribers [%permission pax] upd)
== ==
:: ::

View File

@ -81,8 +81,7 @@
^- json ^- json
=, enjs:format =, enjs:format
%- pairs %- pairs
:~ [%owner (ship owner.config)] :~ [%length (numb length.config)]
[%length (numb length.config)]
[%read (numb read.config)] [%read (numb read.config)]
== ==
:: ::
@ -147,8 +146,8 @@
?> ?=(%create -.upd) ?> ?=(%create -.upd)
:- %create :- %create
%- pairs %- pairs
:~ [%path (path path.upd)] :~ [%ship (ship ship.upd)]
[%owner (ship owner.upd)] [%path (path path.upd)]
== ==
:: ::
:: %delete :: %delete
@ -185,8 +184,8 @@
:: ::
++ create ++ create
%- ot %- ot
:~ [%path pa] :~ [%ship (su ;~(pfix sig fed:ag))]
[%owner (su ;~(pfix sig fed:ag))] [%path pa]
== ==
:: ::
++ delete ++ delete

View File

@ -1,9 +1,9 @@
|% |%
+$ chat-security +$ chat-security
$? $channel :: blacklist $? $channel :: black r, black w
$village :: whitelist $village :: white r, white w
$journal :: pub r, whitelist w $journal :: black r, white w
$mailbox :: our r, blacklist w $mailbox :: white r, black w
== ==
:: ::
+$ chat-hook-action +$ chat-hook-action

View File

@ -17,8 +17,7 @@
== ==
:: ::
+$ config +$ config
$: owner=ship $: length=@
length=@
read=@ read=@
== ==
:: ::
@ -32,7 +31,7 @@
+$ chat-configs (map path config) +$ chat-configs (map path config)
:: ::
+$ chat-action +$ chat-action
$% [%create =path owner=ship] :: %create: create a mailbox at path $% [%create =ship =path] :: %create: create a mailbox at ~ship/path
[%delete =path] :: %delete: delete a mailbox at path [%delete =path] :: %delete: delete a mailbox at path
[%message =path =envelope] :: %message: append a message to mailbox [%message =path =envelope] :: %message: append a message to mailbox
[%read =path] :: %read: set mailbox to read [%read =path] :: %read: set mailbox to read

View File

@ -1,9 +1,9 @@
|% |%
+$ chat-security +$ chat-security
$? $channel :: blacklist $? $channel :: black r, black w
$village :: whitelist $village :: white r, white w
$journal :: pub r, whitelist w $journal :: black r, white w
$mailbox :: our r, blacklist w $mailbox :: white r, black w
== ==
:: ::
+$ chat-view-action +$ chat-view-action

View File

@ -5,6 +5,7 @@ import _ from 'lodash';
import { Message } from '/components/lib/message'; import { Message } from '/components/lib/message';
import { ChatTabBar } from '/components/lib/chat-tabbar'; import { ChatTabBar } from '/components/lib/chat-tabbar';
import { ChatInput } from '/components/lib/chat-input'; import { ChatInput } from '/components/lib/chat-input';
import { deSig } from '/lib/util';
export class ChatScreen extends Component { export class ChatScreen extends Component {
@ -12,7 +13,7 @@ export class ChatScreen extends Component {
super(props); super(props);
this.state = { this.state = {
station: '/' + props.match.params.station, station: `/${props.match.params.ship}/${props.match.params.station}`,
numPages: 1, numPages: 1,
scrollLocked: false, scrollLocked: false,
}; };
@ -40,13 +41,14 @@ export class ChatScreen extends Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
const { props, state } = this; const { props, state } = this;
if (prevProps.match.params.station !== props.match.params.station) { if ((prevProps.match.params.station !== props.match.params.station) ||
(prevProps.match.params.ship !== props.match.params.ship)) {
this.hasAskedForMessages = false; this.hasAskedForMessages = false;
clearInterval(this.updateReadInterval); clearInterval(this.updateReadInterval);
this.setState({ this.setState({
station: "/" + props.match.params.station, station: `/${props.match.params.ship}/${props.match.params.station}`,
scrollLocked: false scrollLocked: false
}, () => { }, () => {
this.scrollToBottom(); this.scrollToBottom();
@ -56,7 +58,7 @@ export class ChatScreen extends Component {
); );
this.updateReadNumber(); this.updateReadNumber();
}); });
} else if (Object.keys(props.inbox) > 0 && props.owner === '') { } else if (Object.keys(props.inbox) > 0) {
props.history.push('/~chat'); props.history.push('/~chat');
} else if (props.envelopes.length - prevProps.envelopes.length >= 200) { } else if (props.envelopes.length - prevProps.envelopes.length >= 200) {
this.hasAskedForMessages = false; this.hasAskedForMessages = false;
@ -197,7 +199,7 @@ export class ChatScreen extends Component {
<ChatTabBar {...props} <ChatTabBar {...props}
station={state.station} station={state.station}
numPeers={group.length} numPeers={group.length}
isOwner={props.owner === window.ship} /> isOwner={deSig(props.match.params.ship) === window.ship} />
</div> </div>
<div <div
className="overflow-y-scroll pt3 pb2 flex flex-column-reverse" className="overflow-y-scroll pt3 pb2 flex flex-column-reverse"
@ -210,7 +212,7 @@ export class ChatScreen extends Component {
api={props.api} api={props.api}
numMsgs={lastMsgNum} numMsgs={lastMsgNum}
station={state.station} station={state.station}
owner={props.owner} owner={deSig(props.match.params.ship)}
permissions={props.permissions} permissions={props.permissions}
placeholder='Message...' /> placeholder='Message...' />
</div> </div>

View File

@ -10,7 +10,7 @@ export class JoinScreen extends Component {
componentDidMount() { componentDidMount() {
const { props } = this; const { props } = this;
let station = '/' + props.match.params.station; let station = `${props.match.params.ship}/${props.match.params.station}`;
if (station in props.inbox) { if (station in props.inbox) {
props.history.push(`/~chat/room${station}`); props.history.push(`/~chat/room${station}`);
@ -30,7 +30,7 @@ export class JoinScreen extends Component {
const { props } = this; const { props } = this;
let ship = props.match.params.ship; let ship = props.match.params.ship;
let station = '/' + props.match.params.station; let station = `/${props.match.params.station}`;
props.api.chatHook.addSynced(ship, station); props.api.chatHook.addSynced(ship, station);
this.props.history.push('/~chat'); this.props.history.push('/~chat');

View File

@ -66,7 +66,7 @@ export class SidebarItem extends Component {
<div className={'pa3 ' + selectedCss} onClick={this.onClick.bind(this)}> <div className={'pa3 ' + selectedCss} onClick={this.onClick.bind(this)}>
<div className='w-100 v-mid'> <div className='w-100 v-mid'>
{unreadElem} {unreadElem}
<p className="dib body-regular lh-16">{props.title}</p> <p className="dib body-regular lh-16">{props.title.substr(1)}</p>
</div> </div>
<div className="w-100"> <div className="w-100">
<p className='dib gray label-small-mono mr3 lh-16'>{props.ship}</p> <p className='dib gray label-small-mono mr3 lh-16'>{props.ship}</p>

View File

@ -13,7 +13,7 @@ export class MemberScreen extends Component {
super(props); super(props);
this.state = { this.state = {
station: "/" + props.match.params.station, station: `/${props.match.params.ship}/${props.match.params.station}`,
}; };
} }
@ -49,7 +49,7 @@ export class MemberScreen extends Component {
return ( return (
<MemberElement <MemberElement
key={mem} key={mem}
owner={props.owner} owner={deSig(props.match.params.ship)}
ship={mem} ship={mem}
path={`/chat${state.station}/write`} path={`/chat${state.station}/write`}
kind={props.write.kind} kind={props.write.kind}
@ -61,7 +61,7 @@ export class MemberScreen extends Component {
return ( return (
<MemberElement <MemberElement
key={mem} key={mem}
owner={props.owner} owner={deSig(props.match.params.ship)}
ship={mem} ship={mem}
path={`/chat${state.station}/read`} path={`/chat${state.station}/read`}
kind={props.read.kind} kind={props.read.kind}
@ -77,7 +77,7 @@ export class MemberScreen extends Component {
{...props} {...props}
station={state.station} station={state.station}
numPeers={writeGroup.length} numPeers={writeGroup.length}
isOwner={props.owner === window.ship} /> isOwner={deSig(props.match.params.ship) === window.ship} />
</div> </div>
<div className="w-100 cf"> <div className="w-100 cf">
<div className="w-50 fl pa2 pr3"> <div className="w-50 fl pa2 pr3">
@ -90,7 +90,7 @@ export class MemberScreen extends Component {
<p className="label-regular gray mb3"> <p className="label-regular gray mb3">
{modWriteText} {modWriteText}
</p> </p>
{ window.ship === props.owner ? ( { window.ship === deSig(props.match.params.ship) ? (
<InviteElement <InviteElement
path={`/chat${state.station}/write`} path={`/chat${state.station}/write`}
station={state.station} station={state.station}
@ -108,12 +108,13 @@ export class MemberScreen extends Component {
<p className="label-regular gray mb3"> <p className="label-regular gray mb3">
{modReadText} {modReadText}
</p> </p>
{ window.ship === props.owner ? ( { window.ship === deSig(props.match.params.ship) ?
<InviteElement ( <InviteElement
path={`/chat${state.station}/read`} path={`/chat${state.station}/read`}
permissions={props.read} permissions={props.read}
api={props.api}/> api={props.api}/>
) : null } ) : null
}
</div> </div>
</div> </div>
</div> </div>

View File

@ -26,7 +26,7 @@ export class NewScreen extends Component {
const { props, state } = this; const { props, state } = this;
if (prevProps !== props) { if (prevProps !== props) {
let station = `/${state.idName}`; let station = `/~${window.ship}/${state.idName}`;
if (station in props.inbox) { if (station in props.inbox) {
props.history.push('/~chat/room' + station); props.history.push('/~chat/room' + station);
} }

View File

@ -107,12 +107,12 @@ export class Root extends Component {
</Skeleton> </Skeleton>
); );
}} /> }} />
<Route exact path="/~chat/room/:station" <Route exact path="/~chat/room/:ship/:station"
render={ (props) => { render={ (props) => {
let station = '/' + props.match.params.station; let station =
`/${props.match.params.ship}/${props.match.params.station}`;
let mailbox = state.inbox[station] || { let mailbox = state.inbox[station] || {
config: { config: {
owner: '',
read: -1, read: -1,
length: 0 length: 0
}, },
@ -126,7 +126,6 @@ export class Root extends Component {
<ChatScreen <ChatScreen
api={api} api={api}
subscription={subscription} subscription={subscription}
owner={mailbox.config.owner}
read={mailbox.config.read} read={mailbox.config.read}
envelopes={mailbox.envelopes} envelopes={mailbox.envelopes}
inbox={state.inbox} inbox={state.inbox}
@ -138,10 +137,10 @@ export class Root extends Component {
</Skeleton> </Skeleton>
); );
}} /> }} />
<Route exact path="/~chat/room/:station/members" <Route exact path="/~chat/room/:ship/:station/members"
render={ (props) => { render={ (props) => {
let station = '/' + props.match.params.station; let station =
let owner = state.inbox[station] || { config: { owner: '' } }; `/${props.match.params.ship}/${props.match.params.station}`;
let read = state.permissions[`/chat${station}/read`] || { let read = state.permissions[`/chat${station}/read`] || {
kind: '', kind: '',
who: new Set([]) who: new Set([])
@ -158,16 +157,15 @@ export class Root extends Component {
api={api} api={api}
read={read} read={read}
write={write} write={write}
owner={owner.config.owner}
permissions={state.permissions} permissions={state.permissions}
/> />
</Skeleton> </Skeleton>
); );
}} /> }} />
<Route exact path="/~chat/room/:station/settings" <Route exact path="/~chat/room/:ship/:station/settings"
render={ (props) => { render={ (props) => {
let station = '/' + props.match.params.station; let station =
let owner = state.inbox[station] || { config: { owner: '' } }; `/${props.match.params.ship}/${props.match.params.station}`;
let write = state.groups[`/chat${station}/write`] || new Set([]); let write = state.groups[`/chat${station}/write`] || new Set([]);
return ( return (
@ -178,7 +176,6 @@ export class Root extends Component {
{...props} {...props}
setSpinner={this.setSpinner} setSpinner={this.setSpinner}
api={api} api={api}
owner={owner.config.owner}
group={write} group={write}
inbox={state.inbox} inbox={state.inbox}
/> />

View File

@ -1,5 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import classnames from 'classnames'; import classnames from 'classnames';
import { deSig } from '/lib/util';
import { ChatTabBar } from '/components/lib/chat-tabbar'; import { ChatTabBar } from '/components/lib/chat-tabbar';
@ -9,7 +10,7 @@ export class SettingsScreen extends Component {
super(props); super(props);
this.state = { this.state = {
station: "/" + props.match.params.station, station: `/${props.match.params.ship}/${props.match.params.station}`,
isLoading: false isLoading: false
}; };
@ -46,7 +47,7 @@ export class SettingsScreen extends Component {
let descriptionText = "Permanently delete this chat."; let descriptionText = "Permanently delete this chat.";
let buttonText = "-> Delete"; let buttonText = "-> Delete";
if (props.owner !== window.ship) { if (deSig(props.match.params.ship) !== window.ship) {
titleText = "Leave Chat" titleText = "Leave Chat"
descriptionText = "You will no longer have access to this chat." descriptionText = "You will no longer have access to this chat."
buttonText = "-> Leave"; buttonText = "-> Leave";
@ -69,7 +70,7 @@ export class SettingsScreen extends Component {
if (!!state.isLoading) { if (!!state.isLoading) {
let text = "Deleting..."; let text = "Deleting...";
if (props.owner !== window.ship) { if (deSig(props.match.params.ship) !== window.ship) {
text = "Leaving..."; text = "Leaving...";
} }
@ -97,7 +98,7 @@ export class SettingsScreen extends Component {
{...props} {...props}
station={state.station} station={state.station}
numPeers={writeGroup.length} numPeers={writeGroup.length}
isOwner={props.owner === window.ship} /> isOwner={deSig(props.match.params.ship) === window.ship} />
</div> </div>
<div className="w-100 cf pa3"> <div className="w-100 cf pa3">
<h2>Settings</h2> <h2>Settings</h2>

View File

@ -36,7 +36,7 @@ export class Sidebar extends Component {
author, author,
letter, letter,
box, box,
title: box.split('/')[1], title: box,
selected: station === box selected: station === box
}; };
}) })

View File

@ -41,12 +41,11 @@ export class ChatUpdateReducer {
create(json, state) { create(json, state) {
let data = _.get(json, 'create', false); let data = _.get(json, 'create', false);
if (data) { if (data) {
state.inbox[data.path] = { state.inbox[`/~${data.ship}${data.path}`] = {
envelopes: [], envelopes: [],
config: { config: {
read:0, read:0,
length: 0, length: 0,
owner: data.owner
} }
}; };
} }