chat-hook: added invite functionality

This commit is contained in:
Logan Allen 2019-10-31 11:38:45 -07:00
parent 656f264f96
commit 40b6579873

View File

@ -2,7 +2,7 @@
:: mirror chat data from foreign to local based on read permissions :: mirror chat data from foreign to local based on read permissions
:: allow sending chat messages to foreign paths based on write perms :: allow sending chat messages to foreign paths based on write perms
:: ::
/- *permission-store, *chat-hook /- *permission-store, *chat-hook, *invite-store
/+ *chat-json /+ *chat-json
|% |%
+$ move [bone card] +$ move [bone card]
@ -27,6 +27,8 @@
+$ poke +$ poke
$% [%chat-action chat-action] $% [%chat-action chat-action]
[%permission-action permission-action] [%permission-action permission-action]
[%invite-action invite-action]
[%chat-view-action chat-view-action]
== ==
:: ::
-- --
@ -38,10 +40,11 @@
++ prep ++ prep
|= old=(unit state) |= old=(unit state)
^- (quip move _this) ^- (quip move _this)
?~ old :_ ?~(old this this(+<+ u.old))
:_ this :~ (invite-poke [%create /chat])
[ost.bol %peer /permissions [our.bol %permission-store] /updates]~ [ost.bol %peer /invites [our.bol %invite-store] /invitatory/chat]
[~ this(+<+ u.old)] [ost.bol %peer /permissions [our.bol %permission-store] /updates]
==
:: ::
++ poke-json ++ poke-json
|= jon=json |= jon=json
@ -139,6 +142,17 @@
:_ this :_ this
[ost.bol %diff %chat-update [%create (slav %p i.pax) pax]]~ [ost.bol %diff %chat-update [%create (slav %p i.pax) pax]]~
:: ::
++ diff-invite-update
|= [wir=wire diff=invite-update]
^- (quip move _this)
?+ -.diff
[~ this]
::
%accepted
:_ this
[(chat-view-poke [%join ship.invite.diff path.invite.diff])]~
==
::
++ diff-permission-update ++ diff-permission-update
|= [wir=wire diff=permission-update] |= [wir=wire diff=permission-update]
^- (quip move _this) ^- (quip move _this)
@ -271,11 +285,21 @@
^- move ^- move
[ost.bol %poke / [our.bol %chat-store] [%chat-action act]] [ost.bol %poke / [our.bol %chat-store] [%chat-action act]]
:: ::
++ chat-view-poke
|= act=chat-view-action
^- move
[ost.bol %poke / [our.bol %chat-view] [%chat-view-action act]]
::
++ permission-poke ++ permission-poke
|= act=permission-action |= act=permission-action
^- move ^- move
[ost.bol %poke / [our.bol %permission-store] [%permission-action act]] [ost.bol %poke / [our.bol %permission-store] [%permission-action act]]
:: ::
++ invite-poke
|= act=invite-action
^- move
[ost.bol %poke / [our.bol %invite-store] [%invite-action act]]
::
++ create-permission ++ create-permission
|= [pax=path sec=chat-security] |= [pax=path sec=chat-security]
^- (list move) ^- (list move)
@ -323,6 +347,13 @@
=. 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) .^((unit mailbox) %gx pax)
:: ::
++ invite-scry
|= uid=serial
^- (unit invite)
=/ pax
(weld /=invite-store/(scot %da now.bol)/invite/(scot %uv uid) /chat/noun)
.^((unit invite) %gx pax)
::
++ permitted-scry ++ permitted-scry
|= pax=path |= pax=path
^- ? ^- ?