hark-store, hark-chat-hook: support mentions in chat

This commit is contained in:
Liam Fitzgerald 2020-11-06 14:18:43 +10:00
parent 62409ca94d
commit fa3fe2b17d
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
5 changed files with 45 additions and 7 deletions

View File

@ -13,6 +13,7 @@
+$ state-0
$: %0
watching=(set path)
mentions=_&
==
::
--
@ -75,6 +76,7 @@
?- -.action
%listen (listen +.action)
%ignore (ignore +.action)
%set-mentions (set-mentions +.action)
==
++ listen
|= chat=path
@ -87,6 +89,12 @@
^- (quip card _state)
:- (give:ha ~[/updates] [%ignore chat])
state(watching (~(del in watching) chat))
::
++ set-mentions
|= ment=?
^- (quip card _state)
:- (give:ha ~[/updates] [%set-mentions ment])
state(mentions ment)
--
--
::
@ -121,16 +129,29 @@
%- zing
(turn envelopes.update (cury process-envelope path.update))
==
++ is-mention
|= [=path =envelope:chat-store]
?. ?=(%text -.letter.envelope) %.n
?& mentions
?= ^
(find (scow %p our.bowl) (trip text.letter.envelope))
==
::
++ is-notification
|= [=path =envelope:chat-store]
?& (~(has in watching) path)
!=(author.envelope our.bowl)
==
::
++ process-envelope
|= [=path =envelope:chat-store]
^- (list card)
?. ?& (~(has in watching) path)
!=(author.envelope our.bowl)
==
=/ mention=?
(is-mention path envelope)
?. ?|(mention (is-notification path envelope))
~
=/ =index:store
[%chat path]
[%chat path mention]
=/ =contents:store
[%chat ~[envelope]]
~[(poke-store %add index when.envelope %.n contents)]

View File

@ -12,6 +12,7 @@
%- of
:~ listen+pa
ignore+pa
set-mentions+bo
==
--
::
@ -24,6 +25,7 @@
%+ frond -.upd
?- -.upd
?(%listen %ignore) (path chat.upd)
%set-mentions b+mentions.upd
%initial a+(turn ~(tap in watching.upd) path)
==
--

View File

@ -11,7 +11,13 @@
%- of
:~ graph+graph-index
group+group-index
chat+pa
chat+chat-index
==
::
++ chat-index
%- ot
:~ chat+pa
mention+bo
==
::
++ group-index
@ -107,8 +113,16 @@
?- -.index
%graph (graph-index +.index)
%group (group-index +.index)
%chat (path chat.index)
%chat (chat-index +.index)
==
::
++ chat-index
|= [chat=^path mention=?]
^- json
%- pairs
:~ chat+(path chat)
mention+b+mention
==
::
++ graph-index
|= [group=resource graph=resource module=@t description=@t]

View File

@ -3,6 +3,7 @@
::
+$ action
$% [?(%listen %ignore) chat=path]
[%set-mentions mentions=?]
==
::
+$ update

View File

@ -5,7 +5,7 @@
+$ index
$% [%graph group=resource graph=resource module=@t description=@t]
[%group group=resource description=@t]
[%chat chat=path]
[%chat chat=path mention=?]
==
::
+$ group-contents