chat-hook: on %remove, try our best to pull subs

Previously, we were removing the relevant entry from the `synced` map
before calling `+pull-wire`, which requires an entry to still be there.
This lead to subscriptions not actually being pulled, commonly leading
to "subscribe wire not unique" errors on re-join.

In addition to fixing that, `%remove` actions now try to pull the
subscription regardless of whether they have an entry in the `synced`
map or not. `%leave` is always safe, and we might want to clean up
subscriptions that shouldn't be there anymore in the first place.
This commit is contained in:
Fang 2020-04-15 16:29:26 +02:00
parent b978d4f824
commit 084ce356a8
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972

View File

@ -363,15 +363,22 @@
== ==
:: ::
%remove %remove
=/ ship (~(get by synced) path.act) =/ ship=(unit ship)
?~ ship [~ state] =/ ship (~(get by synced) path.act)
?^ ship ship
=? path.act ?=([%'~' *] path.act) t.path.act
?~ path.act ~
(slaw %p i.path.act)
?~ ship
~& [dap.bol %unknown-host-cannot-leave path.act]
[~ state]
?: &(!=(u.ship src.bol) ?!((team:title our.bol src.bol))) ?: &(!=(u.ship src.bol) ?!((team:title our.bol src.bol)))
[~ state] [~ state]
=. synced (~(del by synced) path.act) =. synced (~(del by synced) path.act)
:_ state :_ state
%- zing %- zing
:~ (pull-wire [%backlog (weld path.act /0)]) :~ (pull-wire u.ship [%backlog (weld path.act /0)])
(pull-wire [%mailbox path.act]) (pull-wire u.ship [%mailbox path.act])
[%give %kick ~[[%mailbox path.act]] ~]~ [%give %kick ~[[%mailbox path.act]] ~]~
[%give %fact [/synced]~ %chat-hook-update !>([%initial synced])]~ [%give %fact [/synced]~ %chat-hook-update !>([%initial synced])]~
== ==
@ -709,12 +716,9 @@
== ==
:: ::
++ pull-wire ++ pull-wire
|= pax=path |= [=ship =wire]
^- (list card) ^- (list card)
?> ?=(^ pax) ?: =(ship our.bol)
=/ shp (~(get by synced) t.pax) [%pass wire %agent [our.bol %chat-store] %leave ~]~
?~ shp ~ [%pass wire %agent [ship %chat-hook] %leave ~]~
?: =(u.shp our.bol)
[%pass pax %agent [our.bol %chat-store] %leave ~]~
[%pass pax %agent [u.shp %chat-hook] %leave ~]~
-- --