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

Autoapprove Element Call oidc requests #11209

Merged
merged 4 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/stores/widgets/StopGapWidgetDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ export class StopGapWidgetDriver extends WidgetDriver {
WidgetEventCapability.forToDeviceEvent(EventDirection.Receive, eventType).raw,
);
}

// To always allow OIDC requests for element call, the widgetPermissionStore is used:
SdkContextClass.instance.widgetPermissionStore.setOIDCState(
forWidget,
forWidgetKind,
inRoomId,
OIDCState.Allowed,
);
}
}

Expand Down
13 changes: 12 additions & 1 deletion test/stores/widgets/WidgetPermissionStore-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ limitations under the License.

import { mocked } from "jest-mock";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { Widget, WidgetKind } from "matrix-widget-api";
import { MatrixWidgetType, Widget, WidgetKind } from "matrix-widget-api";

import { OIDCState, WidgetPermissionStore } from "../../../src/stores/widgets/WidgetPermissionStore";
import SettingsStore from "../../../src/settings/SettingsStore";
import { TestSdkContext } from "../../TestSdkContext";
import { SettingLevel } from "../../../src/settings/SettingLevel";
import { SdkContextClass } from "../../../src/contexts/SDKContext";
import { stubClient } from "../../test-utils";
import { StopGapWidgetDriver } from "../../../src/stores/widgets/StopGapWidgetDriver";

jest.mock("../../../src/settings/SettingsStore");

Expand All @@ -38,6 +39,12 @@ describe("WidgetPermissionStore", () => {
type: "m.custom",
url: "https://invalid.address.here",
});
const ec_w = new Widget({
id: "group_call",
creatorUserId: "@alice:example.org",
type: MatrixWidgetType.Custom,
url: "https://call.element.io",
});
let settings: Record<string, any> = {}; // key value store

beforeEach(() => {
Expand Down Expand Up @@ -92,4 +99,8 @@ describe("WidgetPermissionStore", () => {
const store2 = context.widgetPermissionStore;
expect(store2).toStrictEqual(store);
});
it("auto-approves OIDC requests for element-call", async () => {
new StopGapWidgetDriver([], ec_w, WidgetKind.Room, true, roomId);
expect(widgetPermissionStore.getOIDCState(ec_w, WidgetKind.Room, roomId)).toEqual(OIDCState.Allowed);
});
});