Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
Support MSC1708 (and co.) and prepare for MSC1711
Browse files Browse the repository at this point in the history
Fixes #234

Later support for MSC1711 will be done in #238
  • Loading branch information
turt2live committed Feb 8, 2019
1 parent 3db2896 commit 38ea8d3
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 55 deletions.
82 changes: 59 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"dns-then": "^0.1.0",
"express": "^4.16.4",
"git-rev-sync": "^1.12.0",
"isipaddress": "0.0.2",
"js-yaml": "^3.12.0",
"lodash": "^4.17.5",
"matrix-js-snippets": "^0.2.8",
Expand All @@ -36,10 +37,12 @@
"netmask": "^1.0.6",
"random-string": "^0.2.0",
"request": "^2.88.0",
"request-promise": "^4.2.2",
"require-dir-all": "^0.4.15",
"sequelize": "^4.39.1",
"sequelize-typescript": "^0.6.6",
"sharp": "^0.21.1",
"split-host": "^0.1.1",
"spotify-uri": "^1.0.0",
"sqlite3": "^4.0.4",
"telegraf": "^3.25.5",
Expand Down
18 changes: 16 additions & 2 deletions src/api/admin/AdminService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import config from "../../config";
import { ApiError } from "../ApiError";
import { MatrixLiteClient } from "../../matrix/MatrixLiteClient";
import { CURRENT_VERSION } from "../../version";
import { getFederationUrl } from "../../matrix/helpers";
import { getFederationConnInfo } from "../../matrix/helpers";

interface DimensionVersionResponse {
version: string;
Expand All @@ -17,6 +17,7 @@ interface DimensionConfigResponse {
name: string;
userId: string;
federationUrl: string;
federationHostname: string;
clientServerUrl: string;
};
}
Expand Down Expand Up @@ -70,15 +71,28 @@ export class AdminService {
await AdminService.validateAndGetAdminTokenOwner(scalarToken);

const client = new MatrixLiteClient(config.homeserver.accessToken);
const fedInfo = await getFederationConnInfo(config.homeserver.name);
return {
admins: config.admins,
widgetBlacklist: config.widgetBlacklist,
homeserver: {
name: config.homeserver.name,
userId: await client.whoAmI(),
federationUrl: await getFederationUrl(config.homeserver.name),
federationUrl: fedInfo.url,
federationHostname: fedInfo.hostname,
clientServerUrl: config.homeserver.clientServerUrl,
},
};
}

@GET
@Path("test/federation")
public async testFederationRouting(@QueryParam("scalar_token") scalarToken: string, @QueryParam("server_name") serverName: string): Promise<any> {
await AdminService.validateAndGetAdminTokenOwner(scalarToken);

return {
inputServerName: serverName,
resolvedServer: await getFederationConnInfo(serverName),
};
}
}
Loading

0 comments on commit 38ea8d3

Please sign in to comment.