chat-hook: fall back if metadata-store not live

This temporary, upgrade-oriented logic depends on two assumptions:
- If the metadata-store is not running, we are still in the process of
  applying the upgrade.
- If the above is true, all chats are /~host/name, all groups are
  /~/~host/name, and they have a strict one-to-one relation.

Armed with those assumptions, we can deduce groups from chats and vice
versa without depending on the metadata-store, allowing us to carry on
as if it were already running.
This commit is contained in:
Fang 2020-02-21 20:51:20 +01:00
parent 337dc03f6b
commit c3becc9f5f
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972

View File

@ -598,6 +598,17 @@
++ chats-of-group
|= =group-path
^- (list path)
:: if metadata-store isn't running yet, we're still in the upgrade ota phase.
:: we can't get chats from the metadata-store, but can make assumptions
:: about group path shape, and the chat that would match it.
::TODO remove me at some point.
::
?. .^(? %gu (scot %p our.bol) %metadata-store (scot %da now.bol) ~)
?: ?=([%'~' @ ^] group-path)
~& [%assuming-ported-legacy-group group-path]
[t.group-path]~
~& [%weird-group group-path]
~
%+ murn
^- (list resource)
=- ~(tap in (~(gut by -) group-path ~))
@ -616,6 +627,17 @@
++ groups-of-chat
|= chat=path
^- (list group-path)
:: if metadata-store isn't running yet, we're still in the upgrade ota phase.
:: we can't get groups from the metadata-store, but can make assumptions
:: about chat path shape, and the chat that would match it.
::TODO remove me at some point.
::
?. .^(? %gu (scot %p our.bol) %metadata-store (scot %da now.bol) ~)
?: ?=([@ ^] chat)
~& [%assuming-ported-legacy-chat chat]
[%'~' chat]~
~& [%weird-chat chat]
~
=- ~(tap in (~(gut by -) [%chat chat] ~))
.^ (jug resource group-path)
%gy