-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathfederation.ts
More file actions
52 lines (47 loc) · 1.35 KB
/
federation.ts
File metadata and controls
52 lines (47 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { FederationMatrix } from '@rocket.chat/core-services';
import { getFederationRoutes } from '@rocket.chat/federation-matrix';
import { Logger } from '@rocket.chat/logger';
import { ajv } from '@rocket.chat/rest-typings';
import type express from 'express';
import { WebApp } from 'meteor/webapp';
import { API } from '../../../app/api/server';
const logger = new Logger('FederationRoutes');
API.v1.get(
'/federation/matrixIds.verify',
{
authRequired: true,
query: ajv.compile<{
matrixIds: string[];
}>({
type: 'object',
properties: {
matrixIds: { type: 'array', items: { type: 'string' } },
},
}),
response: {
200: ajv.compile<{
results: { [key: string]: string };
}>({
type: 'object',
properties: {
results: { type: 'object', additionalProperties: { type: 'string' } },
},
}),
},
},
async function () {
const { matrixIds } = this.queryParams;
return API.v1.success({
results: await FederationMatrix.verifyMatrixIds(matrixIds),
});
},
);
export async function registerFederationRoutes(): Promise<void> {
try {
const routes = getFederationRoutes();
(WebApp.rawConnectHandlers as unknown as ReturnType<typeof express>).use(routes.matrix.router).use(routes.wellKnown.router);
} catch (error) {
logger.error({ msg: '[Federation] Failed to register routes:', err: error });
throw error;
}
}