mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-14 17:41:33 +03:00
Merge 'odyssey-wip' into odyssey-chat-cli
This commit is contained in:
commit
b2365c1668
@ -39,13 +39,15 @@
|
||||
|= old=(unit state)
|
||||
^- (quip move _this)
|
||||
?~ old
|
||||
[~ this]
|
||||
:_ this
|
||||
[ost.bol %peer /permissions [our.bol %permission-store] /updates]~
|
||||
[~ this(+<+ u.old)]
|
||||
::
|
||||
++ poke-noun
|
||||
|= a=*
|
||||
^- (quip move _this)
|
||||
~& synced
|
||||
~& boned
|
||||
[~ this]
|
||||
::
|
||||
++ poke-json
|
||||
@ -58,25 +60,25 @@
|
||||
^- (quip move _this)
|
||||
?> ?=(%message -.act)
|
||||
:: local
|
||||
:_ this
|
||||
?: (team:title our.bol src.bol)
|
||||
?. (~(has by synced) path.act)
|
||||
[~ this]
|
||||
~
|
||||
=/ ship (~(got by synced) path.act)
|
||||
=/ appl ?:(=(ship our.bol) %chat-store %chat-hook)
|
||||
:_ this
|
||||
[ost.bol %poke / [ship appl] [%chat-action act]]~
|
||||
:: foreign
|
||||
=/ ship (~(get by synced) path.act)
|
||||
?~ ship
|
||||
[~ this]
|
||||
:_ this
|
||||
~
|
||||
?. =(u.ship our.bol)
|
||||
~
|
||||
:: scry permissions to check if write is permitted
|
||||
?. (permitted-scry [(scot %p src.bol) %chat (weld path.act /write)])
|
||||
~
|
||||
=. author.envelope.act src.bol
|
||||
=. when.envelope.act now.bol
|
||||
=: author.envelope.act src.bol
|
||||
when.envelope.act now.bol
|
||||
==
|
||||
[ost.bol %poke / [our.bol %chat-store] [%chat-action act]]~
|
||||
::
|
||||
++ poke-chat-hook-action
|
||||
@ -86,24 +88,22 @@
|
||||
%add-owned
|
||||
?> (team:title our.bol src.bol)
|
||||
=/ chat-path [%mailbox path.act]
|
||||
=/ chat-wire [(scot %p our.bol) chat-path]
|
||||
?: (~(has by synced) path.act)
|
||||
[~ this]
|
||||
=. synced (~(put by synced) path.act our.bol)
|
||||
:_ (track-bone chat-wire)
|
||||
:_ (track-bone chat-path)
|
||||
%+ 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)
|
||||
::
|
||||
%add-synced
|
||||
?> (team:title our.bol src.bol)
|
||||
=/ chat-path [%mailbox path.act]
|
||||
=/ chat-wire [(scot %p ship.act) chat-path]
|
||||
?: (~(has by synced) path.act)
|
||||
=/ chat-path [%mailbox (scot %p ship.act) path.act]
|
||||
?: (~(has by synced) [(scot %p ship.act) path.act])
|
||||
[~ this]
|
||||
=. synced (~(put by synced) path.act ship.act)
|
||||
:_ (track-bone chat-wire)
|
||||
[ost.bol %peer chat-wire [ship.act %chat-hook] chat-path]~
|
||||
=. synced (~(put by synced) [(scot %p ship.act) path.act] ship.act)
|
||||
:_ (track-bone chat-path)
|
||||
[ost.bol %peer chat-path [ship.act %chat-hook] chat-path]~
|
||||
::
|
||||
%remove
|
||||
=/ ship (~(get by synced) path.act)
|
||||
@ -111,14 +111,12 @@
|
||||
[~ this]
|
||||
?: &(=(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
|
||||
synced (~(del by synced) path.act)
|
||||
boned (~(del by boned) chat-wire)
|
||||
==
|
||||
:_ %_ this
|
||||
synced (~(del by synced) path.act)
|
||||
boned (~(del by boned) [%mailbox path.act])
|
||||
==
|
||||
%- zing
|
||||
:~ (pull-wire chat-wire path.act)
|
||||
:~ (pull-wire [%mailbox path.act])
|
||||
(delete-permission [%chat path.act])
|
||||
^- (list move)
|
||||
%+ turn (prey:pubsub:userlib [%mailbox path.act] bol)
|
||||
@ -126,32 +124,63 @@
|
||||
^- move
|
||||
[bone %quit ~]
|
||||
==
|
||||
?: |(=(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]
|
||||
:_
|
||||
%_ this
|
||||
synced (~(del by synced) path.act)
|
||||
boned (~(del by boned) chat-wire)
|
||||
==
|
||||
(pull-wire chat-wire path.act)
|
||||
:: don't allow
|
||||
[~ this]
|
||||
::
|
||||
?. |(=(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
|
||||
:- (pull-wire [%mailbox path.act])
|
||||
%_ this
|
||||
synced (~(del by synced) path.act)
|
||||
boned (~(del by boned) [%mailbox path.act])
|
||||
==
|
||||
==
|
||||
::
|
||||
++ peer-mailbox
|
||||
|= pax=path
|
||||
^- (quip move _this)
|
||||
?~ pax !!
|
||||
?. (~(has by synced) pax) !!
|
||||
?> ?=([* ^] pax)
|
||||
?> (~(has by synced) pax)
|
||||
:: scry permissions to check if read is permitted
|
||||
?. (permitted-scry [(scot %p src.bol) %chat (weld pax /read)])
|
||||
!!
|
||||
=/ box=(unit mailbox) (chat-scry pax)
|
||||
?> (permitted-scry [(scot %p src.bol) %chat (weld pax /read)])
|
||||
=/ box (chat-scry pax)
|
||||
?~ box !!
|
||||
:_ 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
|
||||
|= [wir=wire diff=chat-update]
|
||||
@ -164,25 +193,16 @@
|
||||
|= diff=chat-update
|
||||
^- (quip move _this)
|
||||
?- -.diff
|
||||
%keys
|
||||
[~ this]
|
||||
::
|
||||
%config
|
||||
[~ this]
|
||||
::
|
||||
%create
|
||||
[~ this]
|
||||
::
|
||||
%read
|
||||
[~ this]
|
||||
::
|
||||
%keys [~ this]
|
||||
%config [~ this]
|
||||
%create [~ this]
|
||||
%read [~ this]
|
||||
%delete
|
||||
?. (~(has by synced) path.diff)
|
||||
[~ this]
|
||||
=/ chat-wire [(scot %p our.bol) %mailbox path.diff]
|
||||
:_ this(synced (~(del by synced) path.diff))
|
||||
:- (chat-poke diff)
|
||||
[ost.bol %pull chat-wire [our.bol %chat-store] ~]~
|
||||
[ost.bol %pull [%mailbox path.diff] [our.bol %chat-store] ~]~
|
||||
::
|
||||
%message
|
||||
:_ this
|
||||
@ -190,86 +210,66 @@
|
||||
|= [=bone *]
|
||||
^- move
|
||||
[bone %diff [%chat-update diff]]
|
||||
::
|
||||
==
|
||||
::
|
||||
++ handle-foreign
|
||||
|= diff=chat-update
|
||||
^- (quip move _this)
|
||||
?- -.diff
|
||||
%keys
|
||||
[~ this]
|
||||
::
|
||||
%config
|
||||
[~ this]
|
||||
::
|
||||
%read
|
||||
[~ this]
|
||||
::
|
||||
%keys [~ this]
|
||||
%config [~ this]
|
||||
%read [~ this]
|
||||
%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
|
||||
:~ (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
|
||||
:: send a delete poke to local chat
|
||||
?~ path.diff
|
||||
[~ this]
|
||||
?> ?=([* ^] path.diff)
|
||||
=/ shp (~(get by synced) path.diff)
|
||||
?~ shp
|
||||
[~ this]
|
||||
?. (team:title u.shp src.bol)
|
||||
?. =(u.shp src.bol)
|
||||
[~ this]
|
||||
=/ chat-wire [(scot %p src.bol) %mailbox path.diff]
|
||||
:_ this(synced (~(del by synced) path.diff))
|
||||
:- (chat-poke diff)
|
||||
[ost.bol %pull chat-wire [src.bol %chat-hook] ~]~
|
||||
[ost.bol %pull [%mailbox path.diff] [src.bol %chat-hook] ~]~
|
||||
::
|
||||
%message
|
||||
?~ path.diff
|
||||
[~ this]
|
||||
=/ sync (~(get by synced) path.diff)
|
||||
?~ sync
|
||||
[~ this]
|
||||
?. =(src.bol u.sync)
|
||||
[~ this]
|
||||
:_ this
|
||||
:~ (chat-poke diff)
|
||||
==
|
||||
::
|
||||
?> ?=([* ^] path.diff)
|
||||
=/ shp (~(get by synced) path.diff)
|
||||
?~ shp ~
|
||||
?. =(src.bol u.shp) ~
|
||||
[(chat-poke diff)]~
|
||||
==
|
||||
::
|
||||
++ quit
|
||||
|= wir=wire
|
||||
^- (quip move _this)
|
||||
=^ =ship wir
|
||||
?> ?=([* ^] wir)
|
||||
[(slav %p i.wir) t.t.wir]
|
||||
?. (~(has by synced) wir)
|
||||
~& chat-hook-quit+wir
|
||||
?: =(wir /permissions)
|
||||
:_ this
|
||||
[ost.bol %peer /permissions [our.bol %permission-store] /updates]~
|
||||
?> ?=([* ^] wir)
|
||||
?. (~(has by synced) t.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]~
|
||||
~& %chat-hook-resubscribe
|
||||
:_ (track-bone wir)
|
||||
[ost.bol %peer wir [(slav %p i.t.wir) %chat-hook] wir]~
|
||||
::
|
||||
++ reap
|
||||
|= [wir=wire saw=(unit tang)]
|
||||
^- (quip move _this)
|
||||
?~ saw
|
||||
[~ this]
|
||||
=^ =ship wir
|
||||
?> ?=([* ^] wir)
|
||||
[(slav %p i.wir) t.t.wir]
|
||||
[~ this(synced (~(del by synced) wir))]
|
||||
?> ?=(^ wir)
|
||||
~& %chat-hook-reap
|
||||
[((slog u.saw) ~) this(synced (~(del by synced) t.wir))]
|
||||
::
|
||||
++ chat-poke
|
||||
|= act=chat-action
|
||||
@ -306,7 +306,6 @@
|
||||
:~ (permission-poke (sec-to-perm read-perm %white))
|
||||
(permission-poke (sec-to-perm write-perm %black))
|
||||
==
|
||||
::
|
||||
==
|
||||
::
|
||||
++ delete-permission
|
||||
@ -326,7 +325,7 @@
|
||||
++ chat-scry
|
||||
|= pax=path
|
||||
^- (unit mailbox)
|
||||
=. pax ;:(weld /=chat-store/(scot %da now.bol)/mailbox pax /noun)
|
||||
=. pax ;:(weld /=chat-store/(scot %da now.bol)/mailbox pax /noun)
|
||||
.^((unit mailbox) %gx pax)
|
||||
::
|
||||
++ permitted-scry
|
||||
@ -343,19 +342,18 @@
|
||||
this(boned (~(put by boned) wir [ost.bol]~))
|
||||
::
|
||||
++ pull-wire
|
||||
|= [wir=wire pax=path]
|
||||
|= pax=path
|
||||
^- (list move)
|
||||
=/ bnd (~(get by boned) wir)
|
||||
?~ bnd
|
||||
~
|
||||
=/ shp (~(get by synced) pax)
|
||||
?~ shp
|
||||
~
|
||||
?> ?=([* ^] pax)
|
||||
=/ bnd (~(get by boned) pax)
|
||||
?~ bnd ~
|
||||
=/ shp (~(get by synced) t.pax)
|
||||
?~ shp ~
|
||||
%+ turn u.bnd
|
||||
|= ost=bone
|
||||
|= =bone
|
||||
^- move
|
||||
?: =(u.shp our.bol)
|
||||
[ost %pull wir [our.bol %chat-store] ~]
|
||||
[ost %pull wir [u.shp %chat-hook] ~]
|
||||
[bone %pull pax [our.bol %chat-store] ~]
|
||||
[bone %pull pax [u.shp %chat-hook] ~]
|
||||
::
|
||||
--
|
||||
|
@ -31,9 +31,7 @@
|
||||
++ prep
|
||||
|= old=(unit state)
|
||||
^- (quip move _this)
|
||||
?~ old
|
||||
[~ this]
|
||||
[~ this(+<+ u.old)]
|
||||
[~ ?~(old this this(+<+ u.old))]
|
||||
::
|
||||
++ peek-x-all
|
||||
|= pax=path
|
||||
@ -54,28 +52,23 @@
|
||||
++ peek-x-mailbox
|
||||
|= pax=path
|
||||
^- (unit (unit [%noun (unit mailbox)]))
|
||||
?~ pax
|
||||
~
|
||||
?~ pax ~
|
||||
=/ mailbox=(unit mailbox) (~(get by inbox) pax)
|
||||
[~ ~ %noun mailbox]
|
||||
::
|
||||
++ peek-x-config
|
||||
|= pax=path
|
||||
^- (unit (unit [%noun config]))
|
||||
?~ pax
|
||||
~
|
||||
?~ pax ~
|
||||
=/ mailbox (~(get by inbox) pax)
|
||||
?~ mailbox
|
||||
~
|
||||
?~ mailbox ~
|
||||
:^ ~ ~ %noun
|
||||
config.u.mailbox
|
||||
::
|
||||
++ peek-x-envelopes
|
||||
|= pax=path
|
||||
^- (unit (unit [%noun (list envelope)]))
|
||||
?+ pax
|
||||
~
|
||||
::
|
||||
?+ pax ~
|
||||
[@ @ *]
|
||||
=/ mail-path t.t.pax
|
||||
=/ mailbox (~(get by inbox) mail-path)
|
||||
@ -143,10 +136,18 @@
|
||||
|= pax=path
|
||||
^- (quip move _this)
|
||||
?> (team:title our.bol src.bol)
|
||||
=/ box=(unit mailbox) (~(get by inbox) pax)
|
||||
?~ box !!
|
||||
:_ this
|
||||
[ost.bol %diff %chat-update [%create pax owner.config.u.box]]~
|
||||
?> (~(has by inbox) pax)
|
||||
=^ =ship pax
|
||||
?> ?=([* ^] pax)
|
||||
[(slav %p i.pax) t.pax]
|
||||
:_ this
|
||||
[ost.bol %diff %chat-update [%create ship pax]]~
|
||||
::
|
||||
++ poke-noun
|
||||
|= a=*
|
||||
^- (quip move _this)
|
||||
~& inbox
|
||||
[~ this]
|
||||
::
|
||||
++ poke-json
|
||||
|= jon=json
|
||||
@ -159,31 +160,21 @@
|
||||
^- (quip move _this)
|
||||
?> (team:title our.bol src.bol)
|
||||
?- -.action
|
||||
%create
|
||||
(handle-create action)
|
||||
::
|
||||
%delete
|
||||
(handle-delete action)
|
||||
::
|
||||
%message
|
||||
(handle-message action)
|
||||
::
|
||||
%read
|
||||
(handle-read action)
|
||||
::
|
||||
%create (handle-create action)
|
||||
%delete (handle-delete action)
|
||||
%message (handle-message action)
|
||||
%read (handle-read action)
|
||||
==
|
||||
::
|
||||
++ handle-create
|
||||
|= act=chat-action
|
||||
^- (quip move _this)
|
||||
?> ?=(%create -.act)
|
||||
?: (~(has by inbox) path.act)
|
||||
=/ pax [(scot %p ship.act) path.act]
|
||||
?: (~(has by inbox) pax)
|
||||
[~ this]
|
||||
=/ mailbox *mailbox
|
||||
=. owner.config.mailbox owner.act
|
||||
=. inbox (~(put by inbox) path.act mailbox)
|
||||
:_ this(inbox inbox)
|
||||
(send-diff path.act act)
|
||||
:- (send-diff pax act)
|
||||
this(inbox (~(put by inbox) pax *mailbox))
|
||||
::
|
||||
++ handle-delete
|
||||
|= act=chat-action
|
||||
@ -192,9 +183,8 @@
|
||||
=/ mailbox=(unit mailbox) (~(get by inbox) path.act)
|
||||
?~ mailbox
|
||||
[~ this]
|
||||
=. inbox (~(del by inbox) path.act)
|
||||
:_ this(inbox inbox)
|
||||
(send-diff path.act act)
|
||||
:- (send-diff path.act act)
|
||||
this(inbox (~(del by inbox) path.act))
|
||||
::
|
||||
++ handle-message
|
||||
|= act=chat-action
|
||||
@ -203,10 +193,11 @@
|
||||
=/ mailbox=(unit mailbox) (~(get by inbox) path.act)
|
||||
?~ mailbox
|
||||
[~ this]
|
||||
=. 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)
|
||||
=: 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)
|
||||
==
|
||||
:_ this(inbox inbox)
|
||||
(send-diff path.act act)
|
||||
::
|
||||
@ -217,8 +208,9 @@
|
||||
=/ mailbox=(unit mailbox) (~(get by inbox) path.act)
|
||||
?~ mailbox
|
||||
[~ this]
|
||||
=. read.config.u.mailbox length.config.u.mailbox
|
||||
=. inbox (~(put by inbox) path.act u.mailbox)
|
||||
=: read.config.u.mailbox length.config.u.mailbox
|
||||
inbox (~(put by inbox) path.act u.mailbox)
|
||||
==
|
||||
:_ this(inbox inbox)
|
||||
(send-diff path.act act)
|
||||
::
|
||||
|
@ -151,18 +151,19 @@
|
||||
?- -.act
|
||||
%create
|
||||
:: TODO: add invites
|
||||
=/ group-read=path [%chat (weld path.act /read)]
|
||||
=/ group-write=path [%chat (weld path.act /write)]
|
||||
=/ pax [(scot %p our.bol) path.act]
|
||||
=/ group-read=path [%chat (weld pax /read)]
|
||||
=/ group-write=path [%chat (weld pax /write)]
|
||||
:_ this
|
||||
%+ weld
|
||||
:~ (chat-poke [%create path.act our.bol])
|
||||
:~ (chat-poke [%create our.bol path.act])
|
||||
(group-poke [%bundle group-read])
|
||||
(group-poke [%bundle group-write])
|
||||
(group-poke [%add read.act group-read])
|
||||
(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
|
||||
=/ group-read [%chat (weld path.act /read)]
|
||||
@ -179,7 +180,7 @@
|
||||
++ peer-initial
|
||||
|= pax=path
|
||||
^- (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
|
||||
:: then quit the subscription
|
||||
:_ this
|
||||
@ -190,14 +191,14 @@
|
||||
++ peer-updates
|
||||
|= pax=path
|
||||
^- (quip move _this)
|
||||
?. =(src.bol our.bol) !!
|
||||
?> (team:title our.bol src.bol)
|
||||
:: send along all subsequent updates
|
||||
[~ this]
|
||||
::
|
||||
++ peer-configs
|
||||
|= pax=path
|
||||
^- (quip move _this)
|
||||
?. =(src.bol our.bol) !!
|
||||
?> (team:title our.bol src.bol)
|
||||
:_ this
|
||||
[ost.bol %diff %json *json]~
|
||||
::
|
||||
|
File diff suppressed because one or more lines are too long
@ -73,15 +73,14 @@
|
||||
(pull-wire group-wire path.act)
|
||||
:: don't allow
|
||||
[~ this]
|
||||
::
|
||||
==
|
||||
::
|
||||
++ peer-group
|
||||
|= pax=path
|
||||
^- (quip move _this)
|
||||
?~ pax !!
|
||||
?. (~(has by synced) pax) !!
|
||||
=/ grp=(unit group) (group-scry pax)
|
||||
?> (~(has by synced) pax)
|
||||
=/ grp (group-scry pax)
|
||||
?~ grp !!
|
||||
:_ this
|
||||
[ost.bol %diff [%group-update [%path u.grp pax]]]~
|
||||
@ -100,34 +99,17 @@
|
||||
%keys [~ this]
|
||||
%path [~ this]
|
||||
%bundle [~ this]
|
||||
%add
|
||||
:_ 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]]
|
||||
%add [(update-subscribers [%group pax.diff] diff) this]
|
||||
%remove [(update-subscribers [%group pax.diff] diff) this]
|
||||
::
|
||||
%unbundle
|
||||
:_ this(synced (~(del by synced) pax.diff))
|
||||
%+ weld
|
||||
(update-subscribers [%group pax.diff] diff)
|
||||
^- (list move)
|
||||
%+ turn (prey:pubsub:userlib [%group pax.diff] bol)
|
||||
|= [=bone *]
|
||||
^- move
|
||||
[bone %diff [%group-update diff]]
|
||||
^- (list move)
|
||||
%+ turn (prey:pubsub:userlib [%group pax.diff] bol)
|
||||
|= [=bone *]
|
||||
^- move
|
||||
[bone %quit ~]
|
||||
::
|
||||
==
|
||||
::
|
||||
++ handle-foreign
|
||||
@ -138,42 +120,31 @@
|
||||
%bundle [~ this]
|
||||
::
|
||||
%path
|
||||
?~ pax.diff
|
||||
[~ this]
|
||||
=/ ship (~(get by synced) pax.diff)
|
||||
?~ ship
|
||||
[~ this]
|
||||
?. =(src.bol u.ship)
|
||||
[~ 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 [%bundle pax.diff])
|
||||
(group-poke pax.diff [%add members.diff pax.diff])
|
||||
==
|
||||
::
|
||||
%add
|
||||
?~ pax.diff
|
||||
[~ this]
|
||||
=/ ship (~(get by synced) pax.diff)
|
||||
?~ ship
|
||||
[~ this]
|
||||
?. =(src.bol u.ship)
|
||||
[~ 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
|
||||
?~ pax.diff
|
||||
[~ this]
|
||||
=/ ship (~(get by synced) pax.diff)
|
||||
?~ ship
|
||||
[~ this]
|
||||
?. =(src.bol u.ship)
|
||||
[~ 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
|
||||
?~ pax.diff
|
||||
@ -184,9 +155,7 @@
|
||||
?. =(src.bol u.ship)
|
||||
[~ this]
|
||||
:_ this(synced (~(del by synced) pax.diff))
|
||||
:~ (group-poke pax.diff diff)
|
||||
==
|
||||
::
|
||||
[(group-poke pax.diff diff)]~
|
||||
==
|
||||
::
|
||||
++ quit
|
||||
@ -196,7 +165,6 @@
|
||||
?> ?=([* ^] 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]
|
||||
@ -224,6 +192,14 @@
|
||||
^- (unit group)
|
||||
.^((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
|
||||
|= wir=wire
|
||||
^+ this
|
||||
|
@ -25,9 +25,7 @@
|
||||
++ prep
|
||||
|= old=(unit state)
|
||||
^- (quip move _this)
|
||||
?~ old
|
||||
[~ this]
|
||||
[~ this(+<+ u.old)]
|
||||
[~ ?~(old this this(+<+ u.old))]
|
||||
::
|
||||
++ peek-x
|
||||
|= pax=path
|
||||
@ -57,10 +55,9 @@
|
||||
|= pax=path
|
||||
^- (quip move _this)
|
||||
?> (team:title our.bol src.bol)
|
||||
=/ grp=(unit group) (~(get by groups) pax)
|
||||
?~ grp !!
|
||||
=/ grp (~(got by groups) pax)
|
||||
:_ this
|
||||
[ost.bol %diff %group-update [%path u.grp pax]]~
|
||||
[ost.bol %diff %group-update [%path grp pax]]~
|
||||
::
|
||||
++ poke-group-action
|
||||
|= action=group-action
|
||||
@ -81,7 +78,7 @@
|
||||
[~ this]
|
||||
?. (~(has by groups) pax.act)
|
||||
[~ this]
|
||||
=/ members=group (~(got by groups) pax.act)
|
||||
=/ members (~(got by groups) pax.act)
|
||||
=. members (~(uni in members) members.act)
|
||||
?: =(members (~(got by groups) pax.act))
|
||||
[~ this]
|
||||
|
@ -38,9 +38,7 @@
|
||||
++ prep
|
||||
|= old=(unit state)
|
||||
^- (quip move _this)
|
||||
?~ old
|
||||
[~ this]
|
||||
[~ this(+<+ u.old)]
|
||||
[~ ?~(old this this(+<+ u.old))]
|
||||
::
|
||||
++ poke-json
|
||||
|= =json
|
||||
@ -62,9 +60,8 @@
|
||||
^- (quip move _this)
|
||||
=/ perms (~(get by relation) group)
|
||||
:: if relation does not exist, create it and subscribe.
|
||||
=/ permissions
|
||||
%- silt
|
||||
%+ turn ~(tap in permission-paths)
|
||||
=/ permissions=(set path)
|
||||
%- ~(run in permission-paths)
|
||||
|=([=path =kind] path)
|
||||
?~ perms
|
||||
=/ group-path [%group group]
|
||||
@ -144,7 +141,6 @@
|
||||
%+ turn ~(tap in u.perms)
|
||||
|= =path
|
||||
(permission-poke path [%delete path])
|
||||
::
|
||||
==
|
||||
::
|
||||
++ quit
|
||||
|
@ -30,12 +30,19 @@
|
||||
:_ this
|
||||
[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
|
||||
|= =path
|
||||
^- (quip move _this)
|
||||
?~ path !!
|
||||
?> (team:title our.bol src.bol)
|
||||
?. (~(has by permissions) path) !!
|
||||
?> (~(has by permissions) path)
|
||||
:_ this
|
||||
[ost.bol %diff %permission-update [%create path (~(got by permissions) path)]]~
|
||||
::
|
||||
@ -170,6 +177,7 @@
|
||||
^- (list move)
|
||||
%- zing
|
||||
:~ (update-subscribers /all upd)
|
||||
(update-subscribers /updates upd)
|
||||
(update-subscribers [%permission pax] upd)
|
||||
==
|
||||
::
|
||||
|
@ -81,8 +81,7 @@
|
||||
^- json
|
||||
=, enjs:format
|
||||
%- pairs
|
||||
:~ [%owner (ship owner.config)]
|
||||
[%length (numb length.config)]
|
||||
:~ [%length (numb length.config)]
|
||||
[%read (numb read.config)]
|
||||
==
|
||||
::
|
||||
@ -147,8 +146,8 @@
|
||||
?> ?=(%create -.upd)
|
||||
:- %create
|
||||
%- pairs
|
||||
:~ [%path (path path.upd)]
|
||||
[%owner (ship owner.upd)]
|
||||
:~ [%ship (ship ship.upd)]
|
||||
[%path (path path.upd)]
|
||||
==
|
||||
::
|
||||
:: %delete
|
||||
@ -185,8 +184,8 @@
|
||||
::
|
||||
++ create
|
||||
%- ot
|
||||
:~ [%path pa]
|
||||
[%owner (su ;~(pfix sig fed:ag))]
|
||||
:~ [%ship (su ;~(pfix sig fed:ag))]
|
||||
[%path pa]
|
||||
==
|
||||
::
|
||||
++ delete
|
||||
|
@ -1,9 +1,9 @@
|
||||
|%
|
||||
+$ chat-security
|
||||
$? $channel :: blacklist
|
||||
$village :: whitelist
|
||||
$journal :: pub r, whitelist w
|
||||
$mailbox :: our r, blacklist w
|
||||
$? $channel :: black r, black w
|
||||
$village :: white r, white w
|
||||
$journal :: black r, white w
|
||||
$mailbox :: white r, black w
|
||||
==
|
||||
::
|
||||
+$ chat-hook-action
|
||||
|
@ -17,8 +17,7 @@
|
||||
==
|
||||
::
|
||||
+$ config
|
||||
$: owner=ship
|
||||
length=@
|
||||
$: length=@
|
||||
read=@
|
||||
==
|
||||
::
|
||||
@ -32,7 +31,7 @@
|
||||
+$ chat-configs (map path config)
|
||||
::
|
||||
+$ 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
|
||||
[%message =path =envelope] :: %message: append a message to mailbox
|
||||
[%read =path] :: %read: set mailbox to read
|
||||
|
@ -1,9 +1,9 @@
|
||||
|%
|
||||
+$ chat-security
|
||||
$? $channel :: blacklist
|
||||
$village :: whitelist
|
||||
$journal :: pub r, whitelist w
|
||||
$mailbox :: our r, blacklist w
|
||||
$? $channel :: black r, black w
|
||||
$village :: white r, white w
|
||||
$journal :: black r, white w
|
||||
$mailbox :: white r, black w
|
||||
==
|
||||
::
|
||||
+$ chat-view-action
|
||||
|
@ -5,6 +5,7 @@ import _ from 'lodash';
|
||||
import { Message } from '/components/lib/message';
|
||||
import { ChatTabBar } from '/components/lib/chat-tabbar';
|
||||
import { ChatInput } from '/components/lib/chat-input';
|
||||
import { deSig } from '/lib/util';
|
||||
|
||||
|
||||
export class ChatScreen extends Component {
|
||||
@ -12,7 +13,7 @@ export class ChatScreen extends Component {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
station: '/' + props.match.params.station,
|
||||
station: `/${props.match.params.ship}/${props.match.params.station}`,
|
||||
numPages: 1,
|
||||
scrollLocked: false,
|
||||
};
|
||||
@ -40,13 +41,14 @@ export class ChatScreen extends Component {
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
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;
|
||||
|
||||
clearInterval(this.updateReadInterval);
|
||||
|
||||
this.setState({
|
||||
station: "/" + props.match.params.station,
|
||||
station: `/${props.match.params.ship}/${props.match.params.station}`,
|
||||
scrollLocked: false
|
||||
}, () => {
|
||||
this.scrollToBottom();
|
||||
@ -56,7 +58,7 @@ export class ChatScreen extends Component {
|
||||
);
|
||||
this.updateReadNumber();
|
||||
});
|
||||
} else if (Object.keys(props.inbox) > 0 && props.owner === '') {
|
||||
} else if (Object.keys(props.inbox) > 0) {
|
||||
props.history.push('/~chat');
|
||||
} else if (props.envelopes.length - prevProps.envelopes.length >= 200) {
|
||||
this.hasAskedForMessages = false;
|
||||
@ -197,7 +199,7 @@ export class ChatScreen extends Component {
|
||||
<ChatTabBar {...props}
|
||||
station={state.station}
|
||||
numPeers={group.length}
|
||||
isOwner={props.owner === window.ship} />
|
||||
isOwner={deSig(props.match.params.ship) === window.ship} />
|
||||
</div>
|
||||
<div
|
||||
className="overflow-y-scroll pt3 pb2 flex flex-column-reverse"
|
||||
@ -210,7 +212,7 @@ export class ChatScreen extends Component {
|
||||
api={props.api}
|
||||
numMsgs={lastMsgNum}
|
||||
station={state.station}
|
||||
owner={props.owner}
|
||||
owner={deSig(props.match.params.ship)}
|
||||
permissions={props.permissions}
|
||||
placeholder='Message...' />
|
||||
</div>
|
||||
|
@ -10,7 +10,7 @@ export class JoinScreen extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
const { props } = this;
|
||||
let station = '/' + props.match.params.station;
|
||||
let station = `${props.match.params.ship}/${props.match.params.station}`;
|
||||
|
||||
if (station in props.inbox) {
|
||||
props.history.push(`/~chat/room${station}`);
|
||||
@ -30,7 +30,7 @@ export class JoinScreen extends Component {
|
||||
const { props } = this;
|
||||
|
||||
let ship = props.match.params.ship;
|
||||
let station = '/' + props.match.params.station;
|
||||
let station = `/${props.match.params.station}`;
|
||||
|
||||
props.api.chatHook.addSynced(ship, station);
|
||||
this.props.history.push('/~chat');
|
||||
|
@ -66,7 +66,7 @@ export class SidebarItem extends Component {
|
||||
<div className={'pa3 ' + selectedCss} onClick={this.onClick.bind(this)}>
|
||||
<div className='w-100 v-mid'>
|
||||
{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 className="w-100">
|
||||
<p className='dib gray label-small-mono mr3 lh-16'>{props.ship}</p>
|
||||
|
@ -13,7 +13,7 @@ export class MemberScreen extends Component {
|
||||
super(props);
|
||||
|
||||
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 (
|
||||
<MemberElement
|
||||
key={mem}
|
||||
owner={props.owner}
|
||||
owner={deSig(props.match.params.ship)}
|
||||
ship={mem}
|
||||
path={`/chat${state.station}/write`}
|
||||
kind={props.write.kind}
|
||||
@ -61,7 +61,7 @@ export class MemberScreen extends Component {
|
||||
return (
|
||||
<MemberElement
|
||||
key={mem}
|
||||
owner={props.owner}
|
||||
owner={deSig(props.match.params.ship)}
|
||||
ship={mem}
|
||||
path={`/chat${state.station}/read`}
|
||||
kind={props.read.kind}
|
||||
@ -77,7 +77,7 @@ export class MemberScreen extends Component {
|
||||
{...props}
|
||||
station={state.station}
|
||||
numPeers={writeGroup.length}
|
||||
isOwner={props.owner === window.ship} />
|
||||
isOwner={deSig(props.match.params.ship) === window.ship} />
|
||||
</div>
|
||||
<div className="w-100 cf">
|
||||
<div className="w-50 fl pa2 pr3">
|
||||
@ -90,7 +90,7 @@ export class MemberScreen extends Component {
|
||||
<p className="label-regular gray mb3">
|
||||
{modWriteText}
|
||||
</p>
|
||||
{ window.ship === props.owner ? (
|
||||
{ window.ship === deSig(props.match.params.ship) ? (
|
||||
<InviteElement
|
||||
path={`/chat${state.station}/write`}
|
||||
station={state.station}
|
||||
@ -108,12 +108,13 @@ export class MemberScreen extends Component {
|
||||
<p className="label-regular gray mb3">
|
||||
{modReadText}
|
||||
</p>
|
||||
{ window.ship === props.owner ? (
|
||||
<InviteElement
|
||||
path={`/chat${state.station}/read`}
|
||||
permissions={props.read}
|
||||
api={props.api}/>
|
||||
) : null }
|
||||
{ window.ship === deSig(props.match.params.ship) ?
|
||||
( <InviteElement
|
||||
path={`/chat${state.station}/read`}
|
||||
permissions={props.read}
|
||||
api={props.api}/>
|
||||
) : null
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -26,7 +26,7 @@ export class NewScreen extends Component {
|
||||
const { props, state } = this;
|
||||
|
||||
if (prevProps !== props) {
|
||||
let station = `/${state.idName}`;
|
||||
let station = `/~${window.ship}/${state.idName}`;
|
||||
if (station in props.inbox) {
|
||||
props.history.push('/~chat/room' + station);
|
||||
}
|
||||
|
@ -107,12 +107,12 @@ export class Root extends Component {
|
||||
</Skeleton>
|
||||
);
|
||||
}} />
|
||||
<Route exact path="/~chat/room/:station"
|
||||
<Route exact path="/~chat/room/:ship/:station"
|
||||
render={ (props) => {
|
||||
let station = '/' + props.match.params.station;
|
||||
let station =
|
||||
`/${props.match.params.ship}/${props.match.params.station}`;
|
||||
let mailbox = state.inbox[station] || {
|
||||
config: {
|
||||
owner: '',
|
||||
read: -1,
|
||||
length: 0
|
||||
},
|
||||
@ -126,7 +126,6 @@ export class Root extends Component {
|
||||
<ChatScreen
|
||||
api={api}
|
||||
subscription={subscription}
|
||||
owner={mailbox.config.owner}
|
||||
read={mailbox.config.read}
|
||||
envelopes={mailbox.envelopes}
|
||||
inbox={state.inbox}
|
||||
@ -138,10 +137,10 @@ export class Root extends Component {
|
||||
</Skeleton>
|
||||
);
|
||||
}} />
|
||||
<Route exact path="/~chat/room/:station/members"
|
||||
<Route exact path="/~chat/room/:ship/:station/members"
|
||||
render={ (props) => {
|
||||
let station = '/' + props.match.params.station;
|
||||
let owner = state.inbox[station] || { config: { owner: '' } };
|
||||
let station =
|
||||
`/${props.match.params.ship}/${props.match.params.station}`;
|
||||
let read = state.permissions[`/chat${station}/read`] || {
|
||||
kind: '',
|
||||
who: new Set([])
|
||||
@ -158,16 +157,15 @@ export class Root extends Component {
|
||||
api={api}
|
||||
read={read}
|
||||
write={write}
|
||||
owner={owner.config.owner}
|
||||
permissions={state.permissions}
|
||||
/>
|
||||
</Skeleton>
|
||||
);
|
||||
}} />
|
||||
<Route exact path="/~chat/room/:station/settings"
|
||||
<Route exact path="/~chat/room/:ship/:station/settings"
|
||||
render={ (props) => {
|
||||
let station = '/' + props.match.params.station;
|
||||
let owner = state.inbox[station] || { config: { owner: '' } };
|
||||
let station =
|
||||
`/${props.match.params.ship}/${props.match.params.station}`;
|
||||
let write = state.groups[`/chat${station}/write`] || new Set([]);
|
||||
|
||||
return (
|
||||
@ -178,7 +176,6 @@ export class Root extends Component {
|
||||
{...props}
|
||||
setSpinner={this.setSpinner}
|
||||
api={api}
|
||||
owner={owner.config.owner}
|
||||
group={write}
|
||||
inbox={state.inbox}
|
||||
/>
|
||||
|
@ -1,5 +1,6 @@
|
||||
import React, { Component } from 'react';
|
||||
import classnames from 'classnames';
|
||||
import { deSig } from '/lib/util';
|
||||
|
||||
import { ChatTabBar } from '/components/lib/chat-tabbar';
|
||||
|
||||
@ -9,7 +10,7 @@ export class SettingsScreen extends Component {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
station: "/" + props.match.params.station,
|
||||
station: `/${props.match.params.ship}/${props.match.params.station}`,
|
||||
isLoading: false
|
||||
};
|
||||
|
||||
@ -46,7 +47,7 @@ export class SettingsScreen extends Component {
|
||||
let descriptionText = "Permanently delete this chat.";
|
||||
let buttonText = "-> Delete";
|
||||
|
||||
if (props.owner !== window.ship) {
|
||||
if (deSig(props.match.params.ship) !== window.ship) {
|
||||
titleText = "Leave Chat"
|
||||
descriptionText = "You will no longer have access to this chat."
|
||||
buttonText = "-> Leave";
|
||||
@ -69,7 +70,7 @@ export class SettingsScreen extends Component {
|
||||
|
||||
if (!!state.isLoading) {
|
||||
let text = "Deleting...";
|
||||
if (props.owner !== window.ship) {
|
||||
if (deSig(props.match.params.ship) !== window.ship) {
|
||||
text = "Leaving...";
|
||||
}
|
||||
|
||||
@ -97,7 +98,7 @@ export class SettingsScreen extends Component {
|
||||
{...props}
|
||||
station={state.station}
|
||||
numPeers={writeGroup.length}
|
||||
isOwner={props.owner === window.ship} />
|
||||
isOwner={deSig(props.match.params.ship) === window.ship} />
|
||||
</div>
|
||||
<div className="w-100 cf pa3">
|
||||
<h2>Settings</h2>
|
||||
|
@ -36,7 +36,7 @@ export class Sidebar extends Component {
|
||||
author,
|
||||
letter,
|
||||
box,
|
||||
title: box.split('/')[1],
|
||||
title: box,
|
||||
selected: station === box
|
||||
};
|
||||
})
|
||||
|
@ -41,12 +41,11 @@ export class ChatUpdateReducer {
|
||||
create(json, state) {
|
||||
let data = _.get(json, 'create', false);
|
||||
if (data) {
|
||||
state.inbox[data.path] = {
|
||||
state.inbox[`/~${data.ship}${data.path}`] = {
|
||||
envelopes: [],
|
||||
config: {
|
||||
read:0,
|
||||
length: 0,
|
||||
owner: data.owner
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user