2020-10-21 09:02:51 +03:00
|
|
|
:: hark-graph-hook: notifications for graph-store [landscape]
|
|
|
|
::
|
|
|
|
/- store=hark-store, post, group-store, metadata-store, hook=hark-graph-hook
|
|
|
|
/+ resource, metadata, default-agent, dbug, graph-store
|
|
|
|
::
|
|
|
|
~% %hark-graph-hook-top ..is ~
|
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
+$ versioned-state
|
|
|
|
$% state-0
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ state-0
|
|
|
|
$: %0
|
2020-11-10 04:41:19 +03:00
|
|
|
watching=(set [resource index:post])
|
2020-10-27 08:05:00 +03:00
|
|
|
mentions=_&
|
|
|
|
watch-on-self=_&
|
2020-10-21 09:02:51 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
--
|
|
|
|
::
|
|
|
|
=| state-0
|
|
|
|
=* state -
|
|
|
|
::
|
|
|
|
=<
|
|
|
|
%- agent:dbug
|
|
|
|
^- agent:gall
|
|
|
|
~% %hark-graph-hook-agent ..card ~
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
ha ~(. +> bowl)
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
met ~(. metadata bowl)
|
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
:_ this
|
|
|
|
~[watch-graph:ha]
|
|
|
|
::
|
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old=vase
|
|
|
|
^- (quip card _this)
|
|
|
|
`this(state !<(state-0 old))
|
|
|
|
::
|
2020-10-27 08:05:00 +03:00
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
2020-11-03 03:36:00 +03:00
|
|
|
?+ path (on-watch:def path)
|
|
|
|
::
|
|
|
|
[%updates ~]
|
|
|
|
:_ state
|
|
|
|
%+ give:ha ~
|
|
|
|
:* %initial
|
|
|
|
watching
|
|
|
|
mentions
|
|
|
|
watch-on-self
|
|
|
|
==
|
2020-10-27 08:05:00 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
2020-10-21 09:02:51 +03:00
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
~/ %hark-graph-hook-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
=^ cards state
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%hark-graph-hook-action
|
|
|
|
(hark-graph-hook-action !<(action:hook vase))
|
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ hark-graph-hook-action
|
|
|
|
|= =action:hook
|
|
|
|
^- (quip card _state)
|
|
|
|
|^
|
|
|
|
?- -.action
|
|
|
|
%listen (listen +.action)
|
|
|
|
%ignore (ignore +.action)
|
2020-10-27 08:05:00 +03:00
|
|
|
%set-mentions (set-mentions +.action)
|
|
|
|
%set-watch-on-self (set-watch-on-self +.action)
|
2020-10-21 09:02:51 +03:00
|
|
|
==
|
|
|
|
++ listen
|
2020-11-10 04:41:19 +03:00
|
|
|
|= [graph=resource =index:post]
|
2020-10-21 09:02:51 +03:00
|
|
|
^- (quip card _state)
|
2020-11-10 04:41:19 +03:00
|
|
|
:- (give:ha ~[/updates] [%listen graph index])
|
|
|
|
state(watching (~(put in watching) [graph index]))
|
2020-10-21 09:02:51 +03:00
|
|
|
::
|
|
|
|
++ ignore
|
2020-11-10 04:41:19 +03:00
|
|
|
|= [graph=resource =index:post]
|
2020-10-21 09:02:51 +03:00
|
|
|
^- (quip card _state)
|
2020-11-10 04:41:19 +03:00
|
|
|
:- (give:ha ~[/updates] [%ignore graph index])
|
|
|
|
state(watching (~(del in watching) [graph index]))
|
2020-10-21 09:02:51 +03:00
|
|
|
::
|
2020-10-27 08:05:00 +03:00
|
|
|
++ set-mentions
|
|
|
|
|= ment=?
|
|
|
|
^- (quip card _state)
|
|
|
|
:- (give:ha ~[/updates] %set-mentions ment)
|
|
|
|
state(mentions ment)
|
|
|
|
::
|
|
|
|
++ set-watch-on-self
|
|
|
|
|= self=?
|
|
|
|
^- (quip card _state)
|
|
|
|
:- (give:ha ~[/updates] %set-watch-on-self self)
|
|
|
|
state(watch-on-self self)
|
2020-10-21 09:02:51 +03:00
|
|
|
--
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-agent
|
|
|
|
~/ %hark-graph-hook-agent
|
|
|
|
|= [=wire =sign:agent:gall]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?+ -.sign (on-agent:def wire sign)
|
|
|
|
%kick
|
|
|
|
:_ this
|
|
|
|
?. ?=([%graph ~] wire)
|
|
|
|
~
|
|
|
|
~[watch-graph:ha]
|
|
|
|
::
|
|
|
|
%fact
|
|
|
|
?. ?=(%graph-update p.cage.sign)
|
|
|
|
(on-agent:def wire sign)
|
|
|
|
=^ cards state
|
|
|
|
(graph-update !<(update:graph-store q.cage.sign))
|
|
|
|
[cards this]
|
|
|
|
==
|
2020-11-10 04:41:19 +03:00
|
|
|
++ add-graph
|
|
|
|
|= rid=resource
|
|
|
|
^- (quip card _state)
|
|
|
|
?. &(watch-on-self =(our.bowl entity.rid))
|
|
|
|
[~ state]
|
|
|
|
`state(watching (~(put in watching) [rid ~]))
|
2020-10-21 09:02:51 +03:00
|
|
|
::
|
|
|
|
++ graph-update
|
|
|
|
|= =update:graph-store
|
|
|
|
^- (quip card _state)
|
2020-11-10 04:41:19 +03:00
|
|
|
?: ?=(%add-graph -.q.update)
|
|
|
|
(add-graph resource.q.update)
|
2020-10-21 09:02:51 +03:00
|
|
|
?. ?=(%add-nodes -.q.update)
|
|
|
|
[~ state]
|
|
|
|
=/ group=resource
|
|
|
|
(need (group-from-app-resource:met %graph resource.q.update))
|
|
|
|
=/ =metadata:metadata-store
|
|
|
|
(need (peek-metadata:met %graph group resource.q.update))
|
|
|
|
=* rid resource.q.update
|
2020-11-03 07:55:01 +03:00
|
|
|
=+ %+ scry:ha
|
2020-11-03 03:36:00 +03:00
|
|
|
,mark=(unit mark)
|
|
|
|
/gx/graph-store/graph-mark/(scot %p entity.rid)/[name.rid]/noun
|
2020-11-03 07:55:01 +03:00
|
|
|
=+ %+ scry:ha
|
2020-11-03 03:36:00 +03:00
|
|
|
,=tube:clay
|
|
|
|
/cc/[q.byk.bowl]/[(fall mark %graph-validator-link)]/notification-kind
|
2020-10-27 08:05:00 +03:00
|
|
|
=/ nodes=(list [p=index:graph-store q=node:graph-store])
|
|
|
|
~(tap by nodes.q.update)
|
|
|
|
=| cards=(list card)
|
2020-11-03 07:55:01 +03:00
|
|
|
|^
|
2020-10-27 08:05:00 +03:00
|
|
|
?~ nodes
|
|
|
|
[cards state]
|
|
|
|
=* index p.i.nodes
|
|
|
|
=* node q.i.nodes
|
2020-11-03 07:55:01 +03:00
|
|
|
=^ node-cards state
|
|
|
|
(check-node node tube)
|
2020-10-27 08:05:00 +03:00
|
|
|
%_ $
|
2020-11-03 07:55:01 +03:00
|
|
|
nodes t.nodes
|
|
|
|
cards (weld node-cards cards)
|
2020-10-27 08:05:00 +03:00
|
|
|
==
|
|
|
|
::
|
2020-11-03 07:55:01 +03:00
|
|
|
++ check-node-children
|
|
|
|
|= [=node:graph-store =tube:clay]
|
|
|
|
^- (quip card _state)
|
|
|
|
?: ?=(%empty -.children.node)
|
|
|
|
[~ state]
|
|
|
|
=/ children=(list [=atom =node:graph-store])
|
|
|
|
(tap:orm:graph-store p.children.node)
|
|
|
|
=| cards=(list card)
|
|
|
|
|- ^- (quip card _state)
|
|
|
|
?~ children
|
|
|
|
[cards state]
|
|
|
|
=^ new-cards state
|
|
|
|
(check-node node.i.children tube)
|
|
|
|
%_ $
|
|
|
|
cards (weld cards new-cards)
|
|
|
|
children t.children
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ check-node
|
|
|
|
|= [=node:graph-store =tube:clay]
|
|
|
|
^- (quip card _state)
|
|
|
|
=^ child-cards state
|
|
|
|
(check-node-children node tube)
|
|
|
|
?: =(our.bowl author.post.node)
|
|
|
|
=^ self-cards state
|
|
|
|
(self-post node)
|
|
|
|
:_ state
|
|
|
|
(weld child-cards self-cards)
|
2020-11-10 04:41:19 +03:00
|
|
|
=+ !< notif-kind=(unit [name=@t parent-lent=@ud])
|
|
|
|
(tube !>([0 post.node]))
|
2020-11-03 07:55:01 +03:00
|
|
|
?~ notif-kind
|
|
|
|
[child-cards state]
|
|
|
|
=/ desc=@t
|
|
|
|
?: (is-mention contents.post.node)
|
|
|
|
%mention
|
2020-11-10 04:41:19 +03:00
|
|
|
name.u.notif-kind
|
|
|
|
=/ parent=index:post
|
|
|
|
(scag parent-lent.u.notif-kind index.post.node)
|
|
|
|
~& parent
|
2020-11-03 07:55:01 +03:00
|
|
|
?. ?| =(desc %mention)
|
2020-11-10 04:41:19 +03:00
|
|
|
(~(has in watching) [rid parent])
|
2020-11-03 07:55:01 +03:00
|
|
|
==
|
|
|
|
[child-cards state]
|
|
|
|
=/ notif-index=index:store
|
|
|
|
[%graph group rid module.metadata desc]
|
|
|
|
=/ =contents:store
|
|
|
|
[%graph (limo post.node ~)]
|
|
|
|
:_ state
|
|
|
|
%+ snoc child-cards
|
|
|
|
(add-unread notif-index [time-sent.post.node %.n contents])
|
|
|
|
::
|
2020-10-27 08:05:00 +03:00
|
|
|
++ is-mention
|
|
|
|
|= contents=(list content:post)
|
|
|
|
^- ?
|
|
|
|
?. mentions %.n
|
|
|
|
?~ contents %.n
|
2020-11-03 03:41:40 +03:00
|
|
|
?. ?=(%mention -.i.contents)
|
2020-10-27 08:05:00 +03:00
|
|
|
$(contents t.contents)
|
2020-11-03 03:41:40 +03:00
|
|
|
?: =(our.bowl ship.i.contents)
|
2020-10-27 08:05:00 +03:00
|
|
|
%.y
|
|
|
|
$(contents t.contents)
|
|
|
|
::
|
|
|
|
++ self-post
|
2020-11-03 07:55:01 +03:00
|
|
|
|= =node:graph-store
|
2020-10-27 08:05:00 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
?. ?=(%.y watch-on-self)
|
|
|
|
[~ state]
|
2020-11-10 04:41:19 +03:00
|
|
|
`state(watching (~(put in watching) [rid index.post.node]))
|
2020-10-22 04:30:02 +03:00
|
|
|
::
|
|
|
|
++ add-unread
|
|
|
|
|= [=index:store =notification:store]
|
|
|
|
^- card
|
|
|
|
=- [%pass / %agent [our.bowl %hark-store] %poke -]
|
|
|
|
hark-action+!>([%add index notification])
|
|
|
|
::
|
|
|
|
--
|
2020-10-21 09:02:51 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-peek on-peek:def
|
|
|
|
::
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|
|
|
|
|_ =bowl:gall
|
|
|
|
::
|
2020-11-03 07:55:01 +03:00
|
|
|
++ scry
|
|
|
|
|* [=mold p=path]
|
|
|
|
?> ?=(^ p)
|
|
|
|
?> ?=(^ t.p)
|
|
|
|
.^(mold i.p (scot %p our.bowl) i.t.p (scot %da now.bowl) t.t.p)
|
|
|
|
::
|
2020-10-27 08:05:00 +03:00
|
|
|
++ give
|
|
|
|
|= [paths=(list path) =update:hook]
|
|
|
|
^- (list card)
|
|
|
|
[%give %fact paths hark-graph-hook-update+!>(update)]~
|
|
|
|
::
|
2020-10-21 09:02:51 +03:00
|
|
|
++ watch-graph
|
|
|
|
^- card
|
|
|
|
[%pass /graph %agent [our.bowl %graph-store] %watch /updates]
|
|
|
|
--
|