2020-10-21 09:07:26 +03:00
|
|
|
:: hark-group-hook: notifications for groups [landscape]
|
|
|
|
::
|
2021-01-28 09:13:57 +03:00
|
|
|
/- store=hark-store, post, group-store, metadata=metadata-store, hook=hark-group-hook
|
|
|
|
/+ resource, mdl=metadata, default-agent, dbug, graph-store
|
2020-10-21 09:07:26 +03:00
|
|
|
::
|
2020-12-05 07:32:17 +03:00
|
|
|
~% %hark-group-hook-top ..part ~
|
2020-10-21 09:07:26 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
+$ versioned-state
|
|
|
|
$% state-0
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ state-0
|
|
|
|
$: %0
|
|
|
|
watching=(set resource)
|
|
|
|
==
|
2021-09-06 06:31:11 +03:00
|
|
|
+$ update
|
|
|
|
$>(?(%add-members %remove-members) update:group-store)
|
2020-10-21 09:07:26 +03:00
|
|
|
::
|
|
|
|
--
|
|
|
|
::
|
|
|
|
=| state-0
|
|
|
|
=* state -
|
|
|
|
::
|
|
|
|
=<
|
|
|
|
%- agent:dbug
|
|
|
|
^- agent:gall
|
|
|
|
~% %hark-group-hook-agent ..card ~
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
ha ~(. +> bowl)
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
2021-01-28 09:13:57 +03:00
|
|
|
met ~(. mdl bowl)
|
2020-10-21 09:07:26 +03:00
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
:_ this
|
|
|
|
:~ watch-metadata:ha
|
|
|
|
watch-groups:ha
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old=vase
|
|
|
|
^- (quip card _this)
|
2020-10-22 04:30:18 +03:00
|
|
|
`this(state !<(state-0 old))
|
|
|
|
::
|
2020-10-27 08:06:32 +03:00
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
?. ?=([%updates ~] path)
|
|
|
|
(on-watch:def path)
|
|
|
|
:_ this
|
|
|
|
=; =cage
|
2020-11-12 03:26:02 +03:00
|
|
|
[%give %fact ~ cage]~
|
2020-10-27 08:06:32 +03:00
|
|
|
:- %hark-group-hook-update
|
|
|
|
!> ^- update:hook
|
|
|
|
[%initial watching]
|
2020-10-21 09:07:26 +03:00
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
~/ %hark-group-hook-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
=^ cards state
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%hark-group-hook-action
|
|
|
|
(hark-group-hook-action !<(action:hook vase))
|
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ hark-group-hook-action
|
|
|
|
|= =action:hook
|
|
|
|
^- (quip card _state)
|
|
|
|
|^
|
|
|
|
?- -.action
|
|
|
|
%listen (listen +.action)
|
|
|
|
%ignore (ignore +.action)
|
|
|
|
==
|
|
|
|
++ listen
|
|
|
|
|= group=resource
|
|
|
|
^- (quip card _state)
|
2020-10-27 08:06:32 +03:00
|
|
|
:- (give %listen group)
|
|
|
|
state(watching (~(put in watching) group))
|
2020-10-21 09:07:26 +03:00
|
|
|
::
|
|
|
|
++ ignore
|
|
|
|
|= group=resource
|
|
|
|
^- (quip card _state)
|
2020-10-27 08:06:32 +03:00
|
|
|
:- (give %ignore group)
|
|
|
|
state(watching (~(del in watching) group))
|
|
|
|
::
|
|
|
|
++ give
|
|
|
|
|= =update:hook
|
|
|
|
^- (list card)
|
|
|
|
[%give %fact ~[/updates] %hark-group-hook-update !>(update)]~
|
2020-10-21 09:07:26 +03:00
|
|
|
--
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-agent
|
|
|
|
~/ %hark-group-hook-agent
|
|
|
|
|= [=wire =sign:agent:gall]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?+ -.sign (on-agent:def wire sign)
|
|
|
|
%kick
|
|
|
|
:_ this
|
|
|
|
?+ wire ~
|
|
|
|
[%group ~] ~[watch-groups:ha]
|
|
|
|
[%metadata ~] ~[watch-metadata:ha]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
%fact
|
|
|
|
?+ p.cage.sign (on-agent:def wire sign)
|
2021-03-11 07:14:25 +03:00
|
|
|
%group-update-0
|
2020-10-21 09:07:26 +03:00
|
|
|
=^ cards state
|
|
|
|
(group-update !<(update:group-store q.cage.sign))
|
|
|
|
[cards this]
|
|
|
|
::
|
2021-07-09 05:54:55 +03:00
|
|
|
%metadata-update-2
|
2020-10-21 09:07:26 +03:00
|
|
|
=^ cards state
|
2021-01-28 09:13:57 +03:00
|
|
|
(metadata-update !<(update:metadata q.cage.sign))
|
2020-10-21 09:07:26 +03:00
|
|
|
[cards this]
|
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ group-update
|
|
|
|
|= =update:group-store
|
|
|
|
^- (quip card _state)
|
|
|
|
?. ?=(?(%add-members %remove-members) -.update)
|
|
|
|
[~ state]
|
|
|
|
?. (~(has in watching) resource.update)
|
|
|
|
[~ state]
|
2021-09-06 06:31:11 +03:00
|
|
|
=/ body=(unit body:store)
|
|
|
|
(get-content:ha update)
|
|
|
|
?~ body `state
|
|
|
|
=/ =bin:store
|
|
|
|
(get-bin:ha resource.update -.update)
|
2020-10-21 09:07:26 +03:00
|
|
|
:_ state
|
2021-09-06 06:31:11 +03:00
|
|
|
~[(add-unread bin u.body)]
|
2020-10-21 09:07:26 +03:00
|
|
|
:: +metadata-update is stubbed for now, for the following reasons
|
|
|
|
:: - There's no semantic difference in metadata-store between
|
|
|
|
:: adding and editing a channel
|
|
|
|
:: - We have no way of retrieving old metadata to e.g. get a
|
|
|
|
:: channel's old name when it is renamed
|
|
|
|
++ metadata-update
|
2021-01-28 09:13:57 +03:00
|
|
|
|= =update:metadata
|
2020-10-21 09:07:26 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
[~ state]
|
2020-10-22 04:30:18 +03:00
|
|
|
::
|
|
|
|
++ add-unread
|
2021-09-06 06:31:11 +03:00
|
|
|
|= [=bin:store =body:store]
|
2020-10-22 04:30:18 +03:00
|
|
|
^- card
|
|
|
|
=- [%pass / %agent [our.bowl %hark-store] %poke -]
|
2021-01-07 23:03:03 +03:00
|
|
|
:- %hark-action
|
|
|
|
!> ^- action:store
|
2021-09-06 06:31:11 +03:00
|
|
|
[%add-note bin body]
|
2020-10-21 09:07:26 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-peek on-peek:def
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|
|
|
|
|_ =bowl:gall
|
2021-09-06 06:31:11 +03:00
|
|
|
+* met ~(. mdl bowl)
|
|
|
|
++ get-content
|
|
|
|
|= =update:group-store
|
|
|
|
^- (unit body:store)
|
|
|
|
?. ?=(?(%add-members %remove-members) -.update) ~
|
|
|
|
?~ meta=(peek-metadatum:met %groups resource.update)
|
|
|
|
~
|
|
|
|
=/ ships=(list content:store)
|
|
|
|
%+ turn ~(tap in ships.update)
|
|
|
|
|= =ship
|
|
|
|
^- content:store
|
|
|
|
ship+ship
|
|
|
|
=/ sep=content:store text+', '
|
|
|
|
=. ships
|
|
|
|
(join sep ships)
|
|
|
|
?- -.update
|
|
|
|
%add-members
|
|
|
|
:- ~
|
|
|
|
:* (snoc ships text+(rap 3 ' joined ' title.u.meta ~))
|
|
|
|
~
|
|
|
|
now.bowl
|
|
|
|
/
|
|
|
|
/
|
|
|
|
==
|
|
|
|
::
|
|
|
|
%remove-members
|
|
|
|
:- ~
|
|
|
|
:* (snoc ships text+(rap 3 ' joined ' title.u.meta ~))
|
|
|
|
~
|
|
|
|
now.bowl
|
|
|
|
/
|
|
|
|
/
|
|
|
|
==
|
|
|
|
==
|
|
|
|
++ get-bin
|
|
|
|
|= [rid=resource reason=@t]
|
|
|
|
^- bin:store
|
|
|
|
[/[reason] (get-place rid)]
|
|
|
|
++ get-place
|
|
|
|
|= rid=resource
|
|
|
|
^- place:store
|
|
|
|
[q.byk.bowl /(scot %p entity.rid)/[name.rid]]
|
2020-10-21 09:07:26 +03:00
|
|
|
::
|
|
|
|
++ watch-groups
|
|
|
|
^- card
|
|
|
|
[%pass /group %agent [our.bowl %group-store] %watch /groups]
|
|
|
|
::
|
|
|
|
++ watch-metadata
|
|
|
|
^- card
|
|
|
|
[%pass /metadata %agent [our.bowl %metadata-store] %watch /updates]
|
|
|
|
--
|