- Accept DMs and chat invites on the backend

- Added seperate structure for DM messages in collections
- Added another print to hall
This commit is contained in:
Isaac Visintainer 2019-01-03 21:09:31 -08:00
parent 75c2ccf6ed
commit 7629c7b212
5 changed files with 62 additions and 13 deletions

View File

@ -53,17 +53,17 @@
=< ta-done
(~(ta-hall-create-circle ta ~ bol) /c 'collections')
::
:* [ost.bol %peer /circles [our.bol %hall] /circles/[(scot %p our.bol)]]
:~ [ost.bol %peer /circles [our.bol %hall] /circles/[(scot %p our.bol)]]
[ost.bol %peer /inbox [our.bol %hall] /circle/inbox/config/grams]
[ost.bol %peer /invites [our.bol %hall] /circle/i/grams]
::
?. =(%duke (clan:title our.bol))
~
:_ ~
:* ost.bol %poke /client-action [our.bol %hall]
%hall-action %source %inbox &
(sy [[(^sein:title our.bol) %urbit-meta] ~]~)
==
:: ?. =(%duke (clan:title our.bol))
:: ~
:: :_ ~
:: :* ost.bol %poke /client-action [our.bol %hall]
:: %hall-action %source %inbox &
:: (sy [[(^sein:title our.bol) %urbit-meta] ~]~)
:: ==
==
==
?- -.u.old
@ -288,6 +288,11 @@
%circles
~& %circles
?> ?=(%circles -.rum)
=? dms.str.sta
?& (is-dm-circle our.bol cir.rum)
!(~(has by dms.str.sta) cir.rum)
==
(~(put by dms.str.sta) cir.rum our.bol ~)
?: add.rum
:_ this(our-circles.str.sta (~(put in our-circles.str.sta) cir.rum))
[ost.bol %peer /our/[cir.rum] [our.bol %hall] /circle/[cir.rum]/config]~
@ -315,6 +320,15 @@
~& %inbox-gram
:: XX TODO: handle stack trace message when foreign circle is killed?
::
?: (is-dm-circle src.rum.rum)
=/ dms=[ini=ship env=(list envelope:hall)]
(~(got by dms.str.sta) nom.src.rum.rum)
=. env.dms [nev.rum.rum env.dms]
:- ~
%= this
env.inbox.str.sta [nev.rum.rum env.inbox.str.sta]
dms.str.sta (~(put by dms.str.sta) nom.src.rum.rum dms)
==
:- ~ ::(send-rumor [%new-msg %inbox nev.rum.rum])
this(env.inbox.str.sta [nev.rum.rum env.inbox.str.sta])
::
@ -405,7 +419,18 @@
~& %invites
?> ?=(%circle -.rum)
?> ?=(%gram -.rum.rum)
:- ~ ::(send-rumor [%new-msg %invites nev.rum.rum])
?> ?=(%inv -.sep.gam.nev.rum.rum)
=/ circ=circle:hall cir.sep.gam.nev.rum.rum
?: (is-dm-circle circ)
=/ who=(set ship) (sy (rash nom.circ (more dot fed:ag)))
=/ act=poke [%hall-action %newdm who]
:- [ost.bol %poke /join-dm [our.bol %hall] act]~
%= this
invites.str.sta [nev.rum.rum invites.str.sta]
dms.str.sta (~(put by dms.str.sta) nom.circ hos.circ ~)
==
=/ act=poke [%hall-action %source %inbox & (sy [circ ~] ~)]
:- [ost.bol %poke /join-chat [our.bol %hall] act]~
this(invites.str.sta [nev.rum.rum invites.str.sta])
::
:: %our:
@ -482,6 +507,12 @@
~& str.sta
[~ this]
[~ this]
::
++ is-dm-circle
|= circ=circle:hall
^- ?
?= ^
(rush nom.circ (more dot fed:ag))
--

View File

@ -3324,5 +3324,11 @@
~& shape:(~(got by stories) %inbox)
[~ +>]
::
?: =(a 'print all')
~& %+ turn ~(tap by stories)
|= [n=name s=story]
[n shape:s]
[~ +>]
::
[~ +>]
--

View File

@ -44,6 +44,9 @@
:: names of all circles we own
::
our-circles=(set name:hall)
:: list of messages in all our DM circles
::
dms=(map name:hall [ini=ship env=(list envelope:hall)])
:: all the DM invites we've received
::
invites=(list envelope:hall)
@ -59,6 +62,9 @@
:: names of all circles we own
::
our-circles=(set name:hall)
:: list of messages in all our DM circles
::
dms=(map name:hall [ini=ship env=(list envelope:hall)])
:: all the DM invites we've received
::
invites=(list envelope:hall)

View File

@ -32,6 +32,16 @@
%+ turn ~(tap in our-circles.piz)
|= nom=name:hall
[%s nom]
::
:- %dms
%- pairs
%+ turn ~(tap by dms.piz)
|= [nom=name:hall ini=@p env=(list envelope:hall)]
:- nom
%- pairs
:~ [%initiator (ship ini)]
[%messages %a (turn env enve:enjs:hall-json)]
==
::
[%invites %a (turn invites.piz enve:enjs:hall-json)]
==

View File

@ -83,10 +83,6 @@
/circle/i/grams
==
::
:* prep-bone %poke /client-action [our-ship %hall]
%hall-action %source %inbox &
(sy [[(^sein:title our-ship) %urbit-meta] ~]~)
==
==
!> (sort moves aor)
==