chat: auto-invite on addition to group

This commit is contained in:
Logan Allen 2020-02-07 15:52:55 -08:00
parent deb3d26d3f
commit 3e94033196
5 changed files with 26 additions and 43 deletions

View File

@ -270,13 +270,14 @@
++ fact-permission-update ++ fact-permission-update
|= [wir=wire fact=permission-update] |= [wir=wire fact=permission-update]
^- (quip card _state) ^- (quip card _state)
|^
:_ state :_ state
?+ -.fact ~ ?+ -.fact ~
%add (handle-permissions [%add path.fact who.fact]) %add (handle-permissions [%add path.fact who.fact])
%remove (handle-permissions [%remove path.fact who.fact]) %remove (handle-permissions [%remove path.fact who.fact])
== ==
:: ::
++ handle-permissions ++ handle-permissions
|= [kind=?(%add %remove) pax=path who=(set ship)] |= [kind=?(%add %remove) pax=path who=(set ship)]
^- (list card) ^- (list card)
?> ?=([* *] pax) ?> ?=([* *] pax)
@ -284,11 +285,20 @@
%+ turn ~(tap in who) %+ turn ~(tap in who)
|= =ship |= =ship
?: (permitted-scry [(scot %p ship) pax]) ?: (permitted-scry [(scot %p ship) pax])
~ ?: ?|(=(kind %remove) =(ship our.bol)) ~
:: if ship has just been added to the permitted group,
:: send them an invite
~[(send-invite pax ship)]
:: if ship is not permitted, kick their subscription :: if ship is not permitted, kick their subscription
=/ mail-path [%give %kick [%mailbox pax]~ `ship]~
(oust [(dec (lent t.pax)) (lent t.pax)] `(list @t)`t.pax) ::
[%give %kick [%mailbox mail-path]~ `ship]~ ++ send-invite
|= [=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)]
--
:: ::
++ fact-chat-update ++ fact-chat-update
|= [wir=wire fact=chat-update] |= [wir=wire fact=chat-update]

View File

@ -206,9 +206,6 @@
(create-managed-group path.act security.act members.act) (create-managed-group path.act security.act members.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

File diff suppressed because one or more lines are too long

View File

@ -28,8 +28,7 @@ class UrbitApi {
this.invite = { this.invite = {
accept: this.inviteAccept.bind(this), accept: this.inviteAccept.bind(this),
decline: this.inviteDecline.bind(this), decline: this.inviteDecline.bind(this)
invite: this.inviteInvite.bind(this)
}; };
} }
@ -155,24 +154,6 @@ class UrbitApi {
this.action("invite-store", "json", data); this.action("invite-store", "json", data);
} }
inviteInvite(path, ship) {
this.action("invite-hook", "json",
{
invite: {
path: '/chat',
invite: {
path,
ship: `~${window.ship}`,
recipient: ship,
app: 'chat-hook',
text: `~${window.ship}${path}`,
},
uid: uuid()
}
}
);
}
inviteAccept(uid) { inviteAccept(uid) {
this.inviteAction({ this.inviteAction({
accept: { accept: {

View File

@ -52,11 +52,6 @@ export class InviteElement extends Component {
members: '' members: ''
}, () => { }, () => {
props.api.groups.add(aud, props.path); props.api.groups.add(aud, props.path);
if (props.permissions.kind === 'white') {
aud.forEach((ship) => {
props.api.invite.invite(props.path, ship);
});
}
}); });
} }