Don't fail to register for tokens when upstreams are offline

This commit is contained in:
Travis Ralston 2019-04-13 17:25:30 -06:00
parent 087d15eeaa
commit d36436eca4

View file

@ -72,6 +72,10 @@ export class ScalarService {
const upstreams = await Upstream.findAll();
await Promise.all(upstreams.map(async upstream => {
if (!await ScalarStore.isUpstreamOnline(upstream)) {
LogService.warn("ScalarService", `Skipping registration for ${mxUserId} on upstream ${upstream.id} (${upstream.name}) because it is offline`);
return null;
}
const tokens = await UserScalarToken.findAll({where: {userId: mxUserId, upstreamId: upstream.id}});
if (!tokens || tokens.length === 0) {
LogService.info("ScalarService", "Registering " + mxUserId + " for a token at upstream " + upstream.id + " (" + upstream.name + ")");
@ -84,7 +88,7 @@ export class ScalarService {
upstreamId: upstream.id,
});
}
}));
}).filter(token => !!token));
const dimensionToken = randomString({length: 25});
const dimensionScalarToken = await UserScalarToken.create({