mirror of
https://github.com/spacebarchat/server.git
synced 2026-07-13 05:09:01 +00:00
Add endpoint to get enabled/known gif providers
This commit is contained in:
@@ -191,6 +191,10 @@ export class SpacebarServer extends Server {
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/_spacebar/api/v1/integrations/gif", (req, res) => {
|
||||
res.json({ providers: GifProviderManager.getProviders() });
|
||||
});
|
||||
|
||||
// Pickup non-expired polls
|
||||
const nonExpiredPolls = await Message.createQueryBuilder("message").where("message.poll->>'expiry' > :now", { now: new Date().toISOString() }).getMany();
|
||||
|
||||
|
||||
@@ -48,4 +48,15 @@ export class GifProviderManager {
|
||||
|
||||
throw new Error(`Unknown GIF provider, or it is not enabled: ${id}, known GIF providers: ${this._providers.keys().toArray().join(", ")}`);
|
||||
}
|
||||
|
||||
public static getProviders() {
|
||||
const providers: { [key: string]: { available: boolean } } = {};
|
||||
for (const [id, provider] of this._providers) {
|
||||
providers[id] = {
|
||||
available: provider.available,
|
||||
};
|
||||
}
|
||||
|
||||
return providers;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user