mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-09-15 13:32:28 +00:00
Handle offline integrations better
This commit is contained in:
parent
5aca4fde93
commit
77d652d6c0
@ -11,7 +11,6 @@ import { ComplexBot } from "../../integrations/ComplexBot";
|
|||||||
import { Bridge } from "../../integrations/Bridge";
|
import { Bridge } from "../../integrations/Bridge";
|
||||||
import { BridgeStore } from "../../db/BridgeStore";
|
import { BridgeStore } from "../../db/BridgeStore";
|
||||||
import { BotStore } from "../../db/BotStore";
|
import { BotStore } from "../../db/BotStore";
|
||||||
import { AdminService } from "../admin/AdminService";
|
|
||||||
|
|
||||||
export interface IntegrationsResponse {
|
export interface IntegrationsResponse {
|
||||||
widgets: Widget[],
|
widgets: Widget[],
|
||||||
@ -66,11 +65,6 @@ export class DimensionIntegrationsService {
|
|||||||
.map(b => SimpleBot.fromCached(b));
|
.map(b => SimpleBot.fromCached(b));
|
||||||
const bots = [...nebs, ...custom];
|
const bots = [...nebs, ...custom];
|
||||||
Cache.for(CACHE_INTEGRATIONS).put("simple_bots", bots);
|
Cache.for(CACHE_INTEGRATIONS).put("simple_bots", bots);
|
||||||
|
|
||||||
if (!AdminService.isAdmin(userId)) {
|
|
||||||
return bots.filter(b => b.isOnline);
|
|
||||||
}
|
|
||||||
|
|
||||||
return bots;
|
return bots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,11 +80,6 @@ export class DimensionIntegrationsService {
|
|||||||
|
|
||||||
const bots = await NebStore.listComplexBots(userId, roomId);
|
const bots = await NebStore.listComplexBots(userId, roomId);
|
||||||
Cache.for(CACHE_INTEGRATIONS).put("complex_bots_" + roomId, bots);
|
Cache.for(CACHE_INTEGRATIONS).put("complex_bots_" + roomId, bots);
|
||||||
|
|
||||||
if (!AdminService.isAdmin(userId)) {
|
|
||||||
return bots.filter(b => b.isOnline);
|
|
||||||
}
|
|
||||||
|
|
||||||
return bots;
|
return bots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import { TelegramBridge } from "../bridges/TelegramBridge";
|
|||||||
import { WebhooksBridge } from "../bridges/WebhooksBridge";
|
import { WebhooksBridge } from "../bridges/WebhooksBridge";
|
||||||
import { GitterBridge } from "../bridges/GitterBridge";
|
import { GitterBridge } from "../bridges/GitterBridge";
|
||||||
import { SlackBridge } from "../bridges/SlackBridge";
|
import { SlackBridge } from "../bridges/SlackBridge";
|
||||||
import { AdminService } from "../api/admin/AdminService";
|
|
||||||
|
|
||||||
export class BridgeStore {
|
export class BridgeStore {
|
||||||
|
|
||||||
@ -47,10 +46,6 @@ export class BridgeStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AdminService.isAdmin(requestingUserId)) {
|
|
||||||
return enabledBridges.filter(b => b.isOnline);
|
|
||||||
}
|
|
||||||
|
|
||||||
return enabledBridges;
|
return enabledBridges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,9 @@ export class NebStore {
|
|||||||
const notifUserId = await proxy.getNotificationUserId(i.integration, roomId);
|
const notifUserId = await proxy.getNotificationUserId(i.integration, roomId);
|
||||||
const botUserId = null; // TODO: For github
|
const botUserId = null; // TODO: For github
|
||||||
const botConfig = await proxy.getServiceConfiguration(i.integration, roomId);
|
const botConfig = await proxy.getServiceConfiguration(i.integration, roomId);
|
||||||
return new ComplexBot(i.integration, notifUserId, botUserId, botConfig);
|
const bot = new ComplexBot(i.integration, notifUserId, botUserId, botConfig);
|
||||||
|
bot.isOnline = !!bot.botUserId;
|
||||||
|
return bot;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
LogService.error("NebStore", e);
|
LogService.error("NebStore", e);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user