mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-09-02 07:02:12 +00:00
Ensure the upstream is online before asking for terms
This commit is contained in:
parent
c52d9f3907
commit
3831f2f7bc
@ -11,6 +11,7 @@ import { LogService } from "matrix-js-snippets";
|
|||||||
import { ScalarClient } from "../../scalar/ScalarClient";
|
import { ScalarClient } from "../../scalar/ScalarClient";
|
||||||
import { md5 } from "../../utils/hashing";
|
import { md5 } from "../../utils/hashing";
|
||||||
import TermsUpstreamRecord from "../../db/models/TermsUpstreamRecord";
|
import TermsUpstreamRecord from "../../db/models/TermsUpstreamRecord";
|
||||||
|
import { ScalarStore } from "../../db/ScalarStore";
|
||||||
|
|
||||||
export interface ILanguagePolicy {
|
export interface ILanguagePolicy {
|
||||||
name: string;
|
name: string;
|
||||||
@ -98,6 +99,12 @@ export default class TermsController {
|
|||||||
const upstreamTokens = tokensForUser.filter(t => t.upstream);
|
const upstreamTokens = tokensForUser.filter(t => t.upstream);
|
||||||
for (const upstreamToken of upstreamTokens) {
|
for (const upstreamToken of upstreamTokens) {
|
||||||
try {
|
try {
|
||||||
|
const online = await ScalarStore.isUpstreamOnline(upstreamToken.upstream, ScalarClient.KIND_MATRIX_V1);
|
||||||
|
if (!online) {
|
||||||
|
LogService.warn("TermsController", `Upstream ${upstreamToken.upstream.id} is offline - skipping terms check`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const scalarClient = new ScalarClient(upstreamToken.upstream, ScalarClient.KIND_MATRIX_V1);
|
const scalarClient = new ScalarClient(upstreamToken.upstream, ScalarClient.KIND_MATRIX_V1);
|
||||||
await scalarClient.getAccount(upstreamToken.scalarToken);
|
await scalarClient.getAccount(upstreamToken.scalarToken);
|
||||||
// 200 OK means we're fine
|
// 200 OK means we're fine
|
||||||
|
Loading…
Reference in New Issue
Block a user