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
|
||||
?> (team:title our.bol src.bol)
|
||||
?: (~(has by synced) [(scot %p ship.act) path.act])
|
||||
[~ state]
|
||||
=. synced (~(put by synced) [(scot %p ship.act) path.act] ship.act)
|
||||
?: (~(has by synced) path.act) [~ state]
|
||||
=. synced (~(put by synced) path.act ship.act)
|
||||
?. ask-history.act
|
||||
=/ chat-path [%mailbox (scot %p ship.act) path.act]
|
||||
=/ chat-path [%mailbox path.act]
|
||||
:_ state
|
||||
[%pass chat-path %agent [ship.act %chat-hook] %watch chat-path]~
|
||||
:: 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
|
||||
[%pass chat-history %agent [ship.act %chat-hook] %watch chat-history]~
|
||||
::
|
||||
@ -221,15 +220,11 @@
|
||||
?> (~(has by synced) pas)
|
||||
:: scry permissions to check if read is permitted
|
||||
?> (permitted-scry [(scot %p src.bol) pas])
|
||||
=/ box (chat-scry pas)
|
||||
?~ box !!
|
||||
:- [%give %fact ~ %chat-update !>([%create pas])]
|
||||
%- zing
|
||||
:~
|
||||
?: ?&(?=(^ backlog-start) (~(got by allow-history) pas))
|
||||
(paginate-messages pas u.box u.backlog-start)
|
||||
~
|
||||
[%give %kick [%backlog pax]~ `src.bol]~
|
||||
:~ [%give %fact ~ %chat-update !>([%create pas])]~
|
||||
?. ?&(?=(^ backlog-start) (~(has by allow-history) pas)) ~
|
||||
(paginate-messages pas (need (chat-scry pas)) u.backlog-start)
|
||||
[%give %kick [%backlog pax]~ `src.bol]~
|
||||
==
|
||||
::
|
||||
++ paginate-messages
|
||||
@ -267,10 +262,7 @@
|
||||
[~ state]
|
||||
::
|
||||
%accepted
|
||||
=/ ask-history
|
||||
?~ (chat-scry [(scot %p ship.invite.fact) path.invite.fact])
|
||||
%.y
|
||||
%.n
|
||||
=/ ask-history ?~((chat-scry path.invite.fact) %.y %.n)
|
||||
:_ state
|
||||
[(chat-view-poke [%join ship.invite.fact path.invite.fact ask-history])]~
|
||||
==
|
||||
|
@ -4,6 +4,7 @@
|
||||
/- *permission-store,
|
||||
*permission-hook,
|
||||
*group-store,
|
||||
*invite-store,
|
||||
*permission-group-hook,
|
||||
*chat-hook
|
||||
/+ *server, *chat-json, default-agent
|
||||
@ -186,42 +187,36 @@
|
||||
++ poke-json
|
||||
|= jon=json
|
||||
^- (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
|
||||
|= act=chat-view-action
|
||||
~& [%action act]
|
||||
^- (list card)
|
||||
|^
|
||||
?. =(src.bol our.bol)
|
||||
~
|
||||
?> (team:title our.bol src.bol)
|
||||
?- -.act
|
||||
%create
|
||||
:: we used to append /chat/(scot %p our) to paths
|
||||
:: we're moving this logic into front end
|
||||
:: to accomodate "slash paths" (chat circles not associated with groups)
|
||||
?^ (chat-scry path.act)
|
||||
~& %chat-already-exists
|
||||
~
|
||||
%- zing
|
||||
:~ :: if group doesn't exist, create it
|
||||
?^ (group-scry path.act) ~
|
||||
:~ (group-poke [%bundle path.act])
|
||||
(group-poke [%add members.act path.act])
|
||||
==
|
||||
(create-chat path.act security.act allow-history.act)
|
||||
:~ (create-chat path.act security.act allow-history.act)
|
||||
(create-managed-group path.act security.act members.act)
|
||||
(create-security path.act security.act)
|
||||
~[(permission-hook-poke [%add-owned path.act path.act])]
|
||||
%+ turn ~(tap in members.act)
|
||||
|= =ship
|
||||
(send-invite-poke path.act ship)
|
||||
==
|
||||
::
|
||||
%delete
|
||||
:~ (chat-hook-poke [%remove path.act])
|
||||
(permission-hook-poke [%remove path.act])
|
||||
(group-poke [%unbundle path.act])
|
||||
(chat-poke [%delete path.act])
|
||||
==
|
||||
::
|
||||
%join
|
||||
:: same as above, assume that the entire path is being passed
|
||||
:~ (chat-hook-poke [%add-synced ship.act path.act ask-history.act])
|
||||
(permission-hook-poke [%add-synced ship.act path.act])
|
||||
==
|
||||
@ -234,6 +229,21 @@
|
||||
[(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
|
||||
|= [pax=path sec=rw-security]
|
||||
^- (list card)
|
||||
@ -244,6 +254,27 @@
|
||||
%village
|
||||
~[(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
|
||||
|
File diff suppressed because one or more lines are too long
@ -67,6 +67,9 @@
|
||||
?> (team:title our.bowl src.bowl)
|
||||
?+ mark (on-poke:def mark vase)
|
||||
%json [(poke-json:cc !<(json vase)) this]
|
||||
%contact-view-action
|
||||
[(poke-contact-view-action:cc !<(contact-view-action vase)) this]
|
||||
::
|
||||
%handle-http-request
|
||||
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
|
||||
:_ this
|
||||
|
@ -116,6 +116,7 @@
|
||||
(snoc (recreate-permissions perm-paths associate) (watch-group group))
|
||||
::
|
||||
=/ grp (group-scry group)
|
||||
~& associate+grp
|
||||
=. u.perms (~(uni in u.perms) perm-paths)
|
||||
:_ state(relation (~(put by relation) group u.perms))
|
||||
%+ weld
|
||||
|
@ -19,7 +19,7 @@ export class SidebarInvite extends Component {
|
||||
<div className='pa3'>
|
||||
<div className='w-100 v-mid'>
|
||||
<p className="dib f8 mono gray4-d">
|
||||
{props.invite.text}
|
||||
{props.invite.path}
|
||||
</p>
|
||||
</div>
|
||||
<a
|
||||
|
@ -133,21 +133,12 @@ export class NewScreen extends Component {
|
||||
}
|
||||
}, () => {
|
||||
props.setSpinner(true);
|
||||
// we append the ship name here instead of on the back end
|
||||
// if we want a group-channel, we do /~zod/cool-group
|
||||
// if not (DMs) we do /~/~zod/free-chat
|
||||
// this latter should toggle off of a UI affordance that is not here at present
|
||||
// if we want a "proper group" that can be managed from the contacts UI,
|
||||
// we make a path of the form /~zod/cool-group
|
||||
// if not, we make a path of the form /~/~zod/free-chat
|
||||
props.api.chatView.create(
|
||||
`/~${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) => {
|
||||
let unread = props.unreads[obj.box];
|
||||
|
||||
return (
|
||||
<SidebarItem
|
||||
key={obj.box + '/' + obj.when}
|
||||
|
@ -44,7 +44,7 @@ export class ChatUpdateReducer {
|
||||
create(json, state) {
|
||||
let data = _.get(json, 'create', false);
|
||||
if (data) {
|
||||
state.inbox[`/~${data.ship}${data.path}`] = {
|
||||
state.inbox[data.path] = {
|
||||
envelopes: [],
|
||||
config: {
|
||||
read: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user