diff --git a/pkg/arvo/app/hark-chat-hook.hoon b/pkg/arvo/app/hark-chat-hook.hoon index a030de7a6c..8810d7c5e0 100644 --- a/pkg/arvo/app/hark-chat-hook.hoon +++ b/pkg/arvo/app/hark-chat-hook.hoon @@ -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)] diff --git a/pkg/arvo/lib/hark/chat-hook.hoon b/pkg/arvo/lib/hark/chat-hook.hoon index 93ea9675a5..db62ff5631 100644 --- a/pkg/arvo/lib/hark/chat-hook.hoon +++ b/pkg/arvo/lib/hark/chat-hook.hoon @@ -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) == -- diff --git a/pkg/arvo/lib/hark/store.hoon b/pkg/arvo/lib/hark/store.hoon index 834d64b711..54fb37817e 100644 --- a/pkg/arvo/lib/hark/store.hoon +++ b/pkg/arvo/lib/hark/store.hoon @@ -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] diff --git a/pkg/arvo/sur/hark-chat-hook.hoon b/pkg/arvo/sur/hark-chat-hook.hoon index 8812057373..07762baa8f 100644 --- a/pkg/arvo/sur/hark-chat-hook.hoon +++ b/pkg/arvo/sur/hark-chat-hook.hoon @@ -3,6 +3,7 @@ :: +$ action $% [?(%listen %ignore) chat=path] + [%set-mentions mentions=?] == :: +$ update diff --git a/pkg/arvo/sur/hark-store.hoon b/pkg/arvo/sur/hark-store.hoon index 4649b0e38b..3463bb5a29 100644 --- a/pkg/arvo/sur/hark-store.hoon +++ b/pkg/arvo/sur/hark-store.hoon @@ -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