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

Commit

Permalink
Support .well-known on Dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Aug 22, 2019
1 parent 41b5648 commit 915f1eb
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ stickers:
# The sticker manager URL to promote
managerUrl: "https://stickers.t2bot.io"

# Settings for how Dimension is represented to the public
dimension:
# This is where Dimension is accessible from clients. Be sure to set this
# to your own Dimension instance.
publicUrl: "https://dimension.example.org"

# Settings for controlling how logging works
logging:
Expand Down
42 changes: 42 additions & 0 deletions src/api/matrix/MatrixWellknownService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { GET, Path } from "typescript-rest";
import { AutoWired } from "typescript-ioc/es6";
import {URL} from "url";
import config from "../../config";

interface WellknownResponse {
"m.integrations_widget": {
url: string;
data: {
api_url: string;
};
};
}

/**
* Serving of the .well-known file
*/
@Path("/.well-known/matrix")
@AutoWired
export class MatrixWellknownService {

@GET
@Path("integrations")
public async getIntegrations(): Promise<WellknownResponse> {
const parsed = new URL(config.dimension.publicUrl);

parsed.pathname = '/riot';
const uiUrl = parsed.toString();

parsed.pathname = '/api/v1/scalar';
const apiUrl = parsed.toString();

return {
"m.integrations_widget": {
url: uiUrl,
data: {
api_url: apiUrl,
},
},
};
}
}
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export interface DimensionConfig {
stickerBot: string;
managerUrl: string;
};
dimension: {
publicUrl: string;
};
logging: LogConfig;
}

Expand Down
4 changes: 4 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ module.exports = function () {
target: 'http://localhost:8184',
secure: false
},
'/.well-known': {
target: 'http://localhost:8184',
secure: false
},
}
};

Expand Down

0 comments on commit 915f1eb

Please sign in to comment.