Skip to content

Commit d920671

Browse files
authored
Merge pull request #36 from matrix-org/travis/msc2873
Add template variables to support MSC2873
2 parents 5b32803 + fe87ab2 commit d920671

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/templating/url-template.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 The Matrix.org Foundation C.I.C.
2+
* Copyright 2020, 2021 The Matrix.org Foundation C.I.C.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,16 +21,24 @@ export interface ITemplateParams {
2121
currentUserId: string;
2222
userDisplayName?: string;
2323
userHttpAvatarUrl?: string;
24+
clientId?: string;
25+
clientTheme?: string;
26+
clientLanguage?: string;
2427
}
2528

2629
export function runTemplate(url: string, widget: IWidget, params: ITemplateParams): string {
2730
// Always apply the supplied params over top of data to ensure the data can't lie about them.
2831
const variables = Object.assign({}, widget.data, {
29-
matrix_room_id: params.widgetRoomId || "",
30-
matrix_user_id: params.currentUserId,
31-
matrix_display_name: params.userDisplayName || params.currentUserId,
32-
matrix_avatar_url: params.userHttpAvatarUrl || "",
33-
matrix_widget_id: widget.id,
32+
'matrix_room_id': params.widgetRoomId || "",
33+
'matrix_user_id': params.currentUserId,
34+
'matrix_display_name': params.userDisplayName || params.currentUserId,
35+
'matrix_avatar_url': params.userHttpAvatarUrl || "",
36+
'matrix_widget_id': widget.id,
37+
38+
// TODO: Convert to stable (https://github.com/matrix-org/matrix-doc/pull/2873)
39+
'org.matrix.msc2873.client_id': params.clientId || "",
40+
'org.matrix.msc2873.client_theme': params.clientTheme || "",
41+
'org.matrix.msc2873.client_language': params.clientLanguage || "",
3442
});
3543
let result = url;
3644
for (const key of Object.keys(variables)) {

0 commit comments

Comments
 (0)