Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Pass device id to widget
Browse files Browse the repository at this point in the history
Implement the [comment in MSC 3819](matrix-org/matrix-spec-proposals#3819 (comment)) which requests passing a device id to a widget.

This is based on the previous work in the matrix-widget-api: matrix-org/matrix-widget-api#78

Signed-off-by: Oliver Sand <oliver.sand@nordeck.net>
  • Loading branch information
Fox32 committed Feb 21, 2023
1 parent b48d568 commit aeab798
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/stores/widgets/StopGapWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export class StopGapWidget extends EventEmitter {
clientId: ELEMENT_CLIENT_ID,
clientTheme: SettingsStore.getValue("theme"),
clientLanguage: getUserLanguage(),
deviceId: this.client.getDeviceId(),
};
const templated = this.mockWidget.getCompleteUrl(Object.assign(defaults, fromCustomisation), opts?.asPopout);

Expand Down
8 changes: 7 additions & 1 deletion test/stores/widgets/StopGapWidget-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe("StopGapWidget", () => {
id: "test",
creatorUserId: "@alice:example.org",
type: "example",
url: "https://example.org",
url: "https://example.org?user-id=$matrix_user_id&device-id=$org.matrix.msc3819.device_id",
roomId: "!1:example.org",
},
room: mkRoom(client, "!1:example.org"),
Expand All @@ -60,6 +60,12 @@ describe("StopGapWidget", () => {
widget.stopMessaging();
});

it("should replace parameters in widget url template", () => {
expect(widget.embedUrl).toBe(
"https://example.org/?user-id=%40userId%3Amatrix.org&device-id=ABCDEFGHI&widgetId=test&parentUrl=http%3A%2F%2Flocalhost%2F",
);
});

it("feeds incoming to-device messages to the widget", async () => {
const event = mkEvent({
event: true,
Expand Down

0 comments on commit aeab798

Please sign in to comment.