group-push-hook: kick members who are not subscribed

If a ship breaches, it may no longer be subscribed to the group, but
still be in it. This causes DM breakage amongst other things. To fix it,
we loop over the incoming subscriptions and kick everyone who is a part
of a group, but not subscribed to it.
This commit is contained in:
Liam Fitzgerald 2020-12-03 15:58:32 +10:00
parent f552492414
commit 2caf1dac24
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
2 changed files with 63 additions and 1 deletions

View File

@ -36,7 +36,68 @@
++ on-init on-init:def
++ on-save !>(~)
++ on-load on-load:def
++ on-poke on-poke:def
++ on-poke
|= [=mark =vase]
^- (quip card _this)
|^
?. =(mark %sane)
(on-poke:def mark vase)
[sane this]
::
++ scry-sharing
.^ (set resource)
%gx
(scot %p our.bowl)
%group-push-hook
(scot %da now.bowl)
/sharing/noun
==
::
++ sane
^- (list card)
%+ murn
~(tap in scry-sharing)
|= rid=resource
^- (unit card)
=/ u-g=(unit group)
(scry-group:grp rid)
?~ u-g
`(poke-us %remove rid)
=* group u.u-g
=/ subs=(set ship)
(get-subscribers-for-group rid)
=/ to-remove=(set ship)
(~(dif in members.group) subs)
?~ to-remove ~
`(poke-store %remove-members rid to-remove)
::
++ poke-us
|= =action:push-hook
^- card
=- [%pass / %agent [our.bowl %group-push-hook] %poke -]
push-hook-action+!>(action)
::
++ poke-store
|= =update:store
^- card
=+ group-update+!>(update)
[%pass /sane %agent [our.bowl %group-store] %poke -]
::
++ get-subscribers-for-group
|= rid=resource
^- (set ship)
=/ target=path
(en-path:resource rid)
%- ~(gas in *(set ship))
%+ murn
~(val by sup.bowl)
|= [her=ship =path]
^- (unit ship)
?. =(path resource+target)
~
`her
--
++ on-agent on-agent:def
++ on-watch on-watch:def
++ on-leave on-leave:def

View File

@ -8,6 +8,7 @@
^- (list term)
:~ %graph-pull-hook
%group-pull-hook
%group-push-hook
==
::
++ poke-all-sane