mirror of
https://github.com/urbit/shrub.git
synced 2024-12-02 21:34:04 +03:00
chat: fix issues with [ship path] to path change and support contacts
This commit is contained in:
parent
543420b68e
commit
b51ae958ec
@ -163,15 +163,14 @@
|
|||||||
::
|
::
|
||||||
%add-synced
|
%add-synced
|
||||||
?> (team:title our.bol src.bol)
|
?> (team:title our.bol src.bol)
|
||||||
?: (~(has by synced) [(scot %p ship.act) path.act])
|
?: (~(has by synced) path.act) [~ state]
|
||||||
[~ state]
|
=. synced (~(put by synced) path.act ship.act)
|
||||||
=. synced (~(put by synced) [(scot %p ship.act) path.act] ship.act)
|
|
||||||
?. ask-history.act
|
?. ask-history.act
|
||||||
=/ chat-path [%mailbox (scot %p ship.act) path.act]
|
=/ chat-path [%mailbox path.act]
|
||||||
:_ state
|
:_ state
|
||||||
[%pass chat-path %agent [ship.act %chat-hook] %watch chat-path]~
|
[%pass chat-path %agent [ship.act %chat-hook] %watch chat-path]~
|
||||||
:: TODO: only ask for backlog from previous point
|
:: TODO: only ask for backlog from previous point
|
||||||
=/ chat-history [%backlog (scot %p ship.act) (weld path.act /0)]
|
=/ chat-history [%backlog (weld path.act /0)]
|
||||||
:_ state
|
:_ state
|
||||||
[%pass chat-history %agent [ship.act %chat-hook] %watch chat-history]~
|
[%pass chat-history %agent [ship.act %chat-hook] %watch chat-history]~
|
||||||
::
|
::
|
||||||
@ -221,15 +220,11 @@
|
|||||||
?> (~(has by synced) pas)
|
?> (~(has by synced) pas)
|
||||||
:: scry permissions to check if read is permitted
|
:: scry permissions to check if read is permitted
|
||||||
?> (permitted-scry [(scot %p src.bol) pas])
|
?> (permitted-scry [(scot %p src.bol) pas])
|
||||||
=/ box (chat-scry pas)
|
|
||||||
?~ box !!
|
|
||||||
:- [%give %fact ~ %chat-update !>([%create pas])]
|
|
||||||
%- zing
|
%- zing
|
||||||
:~
|
:~ [%give %fact ~ %chat-update !>([%create pas])]~
|
||||||
?: ?&(?=(^ backlog-start) (~(got by allow-history) pas))
|
?. ?&(?=(^ backlog-start) (~(has by allow-history) pas)) ~
|
||||||
(paginate-messages pas u.box u.backlog-start)
|
(paginate-messages pas (need (chat-scry pas)) u.backlog-start)
|
||||||
~
|
[%give %kick [%backlog pax]~ `src.bol]~
|
||||||
[%give %kick [%backlog pax]~ `src.bol]~
|
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ paginate-messages
|
++ paginate-messages
|
||||||
@ -267,10 +262,7 @@
|
|||||||
[~ state]
|
[~ state]
|
||||||
::
|
::
|
||||||
%accepted
|
%accepted
|
||||||
=/ ask-history
|
=/ ask-history ?~((chat-scry path.invite.fact) %.y %.n)
|
||||||
?~ (chat-scry [(scot %p ship.invite.fact) path.invite.fact])
|
|
||||||
%.y
|
|
||||||
%.n
|
|
||||||
:_ state
|
:_ state
|
||||||
[(chat-view-poke [%join ship.invite.fact path.invite.fact ask-history])]~
|
[(chat-view-poke [%join ship.invite.fact path.invite.fact ask-history])]~
|
||||||
==
|
==
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
/- *permission-store,
|
/- *permission-store,
|
||||||
*permission-hook,
|
*permission-hook,
|
||||||
*group-store,
|
*group-store,
|
||||||
|
*invite-store,
|
||||||
*permission-group-hook,
|
*permission-group-hook,
|
||||||
*chat-hook
|
*chat-hook
|
||||||
/+ *server, *chat-json, default-agent
|
/+ *server, *chat-json, default-agent
|
||||||
@ -186,42 +187,36 @@
|
|||||||
++ poke-json
|
++ poke-json
|
||||||
|= jon=json
|
|= jon=json
|
||||||
^- (list card)
|
^- (list card)
|
||||||
?. =(src.bol our.bol)
|
?> (team:title our.bol src.bol)
|
||||||
~
|
|
||||||
(poke-chat-view-action (json-to-view-action jon))
|
(poke-chat-view-action (json-to-view-action jon))
|
||||||
::
|
::
|
||||||
++ poke-chat-view-action
|
++ poke-chat-view-action
|
||||||
|= act=chat-view-action
|
|= act=chat-view-action
|
||||||
~& [%action act]
|
|
||||||
^- (list card)
|
^- (list card)
|
||||||
|^
|
|^
|
||||||
?. =(src.bol our.bol)
|
?> (team:title our.bol src.bol)
|
||||||
~
|
|
||||||
?- -.act
|
?- -.act
|
||||||
%create
|
%create
|
||||||
:: we used to append /chat/(scot %p our) to paths
|
?^ (chat-scry path.act)
|
||||||
:: we're moving this logic into front end
|
~& %chat-already-exists
|
||||||
:: to accomodate "slash paths" (chat circles not associated with groups)
|
~
|
||||||
%- zing
|
%- zing
|
||||||
:~ :: if group doesn't exist, create it
|
:~ (create-chat path.act security.act allow-history.act)
|
||||||
?^ (group-scry path.act) ~
|
(create-managed-group path.act security.act members.act)
|
||||||
:~ (group-poke [%bundle path.act])
|
|
||||||
(group-poke [%add members.act path.act])
|
|
||||||
==
|
|
||||||
(create-chat path.act security.act allow-history.act)
|
|
||||||
(create-security path.act security.act)
|
(create-security path.act security.act)
|
||||||
~[(permission-hook-poke [%add-owned path.act path.act])]
|
~[(permission-hook-poke [%add-owned path.act path.act])]
|
||||||
|
%+ turn ~(tap in members.act)
|
||||||
|
|= =ship
|
||||||
|
(send-invite-poke path.act ship)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
%delete
|
%delete
|
||||||
:~ (chat-hook-poke [%remove path.act])
|
:~ (chat-hook-poke [%remove path.act])
|
||||||
(permission-hook-poke [%remove path.act])
|
(permission-hook-poke [%remove path.act])
|
||||||
(group-poke [%unbundle path.act])
|
|
||||||
(chat-poke [%delete path.act])
|
(chat-poke [%delete path.act])
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
%join
|
%join
|
||||||
:: same as above, assume that the entire path is being passed
|
|
||||||
:~ (chat-hook-poke [%add-synced ship.act path.act ask-history.act])
|
:~ (chat-hook-poke [%add-synced ship.act path.act ask-history.act])
|
||||||
(permission-hook-poke [%add-synced ship.act path.act])
|
(permission-hook-poke [%add-synced ship.act path.act])
|
||||||
==
|
==
|
||||||
@ -234,6 +229,21 @@
|
|||||||
[(chat-hook-poke [%add-owned path security history])]
|
[(chat-hook-poke [%add-owned path security history])]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
|
++ create-managed-group
|
||||||
|
|= [=path security=rw-security ships=(set ship)]
|
||||||
|
^- (list card)
|
||||||
|
~& [path security ships]
|
||||||
|
?. =(security %village)
|
||||||
|
:: if blacklist, do nothing but create the group if it isn't there
|
||||||
|
::
|
||||||
|
?~((group-scry path) ~[(group-poke [%bundle path])] ~)
|
||||||
|
:: if whitelist, check if group exists already. if yes, do nothing
|
||||||
|
::
|
||||||
|
?^ (group-scry path) ~
|
||||||
|
:: if group does not exist, send contact-view %create
|
||||||
|
::
|
||||||
|
~[(contact-view-poke [%create path ships])]
|
||||||
|
::
|
||||||
++ create-security
|
++ create-security
|
||||||
|= [pax=path sec=rw-security]
|
|= [pax=path sec=rw-security]
|
||||||
^- (list card)
|
^- (list card)
|
||||||
@ -244,6 +254,27 @@
|
|||||||
%village
|
%village
|
||||||
~[(perm-group-hook-poke [%associate pax [[pax %white] ~ ~]])]
|
~[(perm-group-hook-poke [%associate pax [[pax %white] ~ ~]])]
|
||||||
==
|
==
|
||||||
|
::
|
||||||
|
++ contact-view-poke
|
||||||
|
|= act=[%create =path ships=(set ship)]
|
||||||
|
^- card
|
||||||
|
[%pass / %agent [our.bol %contact-view] %poke %contact-view-action !>(act)]
|
||||||
|
::
|
||||||
|
++ send-invite-poke
|
||||||
|
|= [=path =ship]
|
||||||
|
^- card
|
||||||
|
=/ =invite
|
||||||
|
:* our.bol %chat-hook
|
||||||
|
path ship ''
|
||||||
|
==
|
||||||
|
=/ act=invite-action [%invite /chat (shaf %msg-uid eny.bol) invite]
|
||||||
|
[%pass / %agent [our.bol %invite-hook] %poke %invite-action !>(act)]
|
||||||
|
::
|
||||||
|
++ chat-scry
|
||||||
|
|= pax=path
|
||||||
|
^- (unit mailbox)
|
||||||
|
=. pax ;:(weld /=chat-store/(scot %da now.bol)/mailbox pax /noun)
|
||||||
|
.^((unit mailbox) %gx pax)
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
++ diff-chat-update
|
++ diff-chat-update
|
||||||
|
File diff suppressed because one or more lines are too long
@ -67,6 +67,9 @@
|
|||||||
?> (team:title our.bowl src.bowl)
|
?> (team:title our.bowl src.bowl)
|
||||||
?+ mark (on-poke:def mark vase)
|
?+ mark (on-poke:def mark vase)
|
||||||
%json [(poke-json:cc !<(json vase)) this]
|
%json [(poke-json:cc !<(json vase)) this]
|
||||||
|
%contact-view-action
|
||||||
|
[(poke-contact-view-action:cc !<(contact-view-action vase)) this]
|
||||||
|
::
|
||||||
%handle-http-request
|
%handle-http-request
|
||||||
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
|
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
|
||||||
:_ this
|
:_ this
|
||||||
|
@ -116,6 +116,7 @@
|
|||||||
(snoc (recreate-permissions perm-paths associate) (watch-group group))
|
(snoc (recreate-permissions perm-paths associate) (watch-group group))
|
||||||
::
|
::
|
||||||
=/ grp (group-scry group)
|
=/ grp (group-scry group)
|
||||||
|
~& associate+grp
|
||||||
=. u.perms (~(uni in u.perms) perm-paths)
|
=. u.perms (~(uni in u.perms) perm-paths)
|
||||||
:_ state(relation (~(put by relation) group u.perms))
|
:_ state(relation (~(put by relation) group u.perms))
|
||||||
%+ weld
|
%+ weld
|
||||||
|
@ -19,7 +19,7 @@ export class SidebarInvite extends Component {
|
|||||||
<div className='pa3'>
|
<div className='pa3'>
|
||||||
<div className='w-100 v-mid'>
|
<div className='w-100 v-mid'>
|
||||||
<p className="dib f8 mono gray4-d">
|
<p className="dib f8 mono gray4-d">
|
||||||
{props.invite.text}
|
{props.invite.path}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<a
|
<a
|
||||||
|
@ -133,21 +133,12 @@ export class NewScreen extends Component {
|
|||||||
}
|
}
|
||||||
}, () => {
|
}, () => {
|
||||||
props.setSpinner(true);
|
props.setSpinner(true);
|
||||||
// we append the ship name here instead of on the back end
|
// if we want a "proper group" that can be managed from the contacts UI,
|
||||||
// if we want a group-channel, we do /~zod/cool-group
|
// we make a path of the form /~zod/cool-group
|
||||||
// if not (DMs) we do /~/~zod/free-chat
|
// if not, we make a path of the form /~/~zod/free-chat
|
||||||
// this latter should toggle off of a UI affordance that is not here at present
|
|
||||||
props.api.chatView.create(
|
props.api.chatView.create(
|
||||||
`/~${window.ship}${station}`, state.security, aud, state.allowHistory
|
`/~${window.ship}${station}`, state.security, aud, state.allowHistory
|
||||||
);
|
);
|
||||||
// this should also be slightly altered to accomodate sending invites to a pre-existing group
|
|
||||||
// perhaps better just to do this on back end
|
|
||||||
// this latter should toggle off of a UI affordance that is not here at present (in designs, though)
|
|
||||||
aud.forEach((ship) => {
|
|
||||||
if (ship !== `~${window.ship}`) {
|
|
||||||
props.api.invite.invite(station, ship);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ export class Sidebar extends Component {
|
|||||||
})
|
})
|
||||||
.map((obj) => {
|
.map((obj) => {
|
||||||
let unread = props.unreads[obj.box];
|
let unread = props.unreads[obj.box];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarItem
|
<SidebarItem
|
||||||
key={obj.box + '/' + obj.when}
|
key={obj.box + '/' + obj.when}
|
||||||
|
@ -44,7 +44,7 @@ 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.ship}${data.path}`] = {
|
state.inbox[data.path] = {
|
||||||
envelopes: [],
|
envelopes: [],
|
||||||
config: {
|
config: {
|
||||||
read: 0,
|
read: 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user