Skip to content

Commit 58710d1

Browse files
authored
Autoapprove Element Call oidc requests (matrix-org#11209)
* autoapprove Element Call oidc requests Signed-off-by: Timo K <[email protected]> * update comment Signed-off-by: Timo K <[email protected]> * add tests for oidc element-call Signed-off-by: Timo K <[email protected]> * fix ES lint Signed-off-by: Timo K <[email protected]> --------- Signed-off-by: Timo K <[email protected]>
1 parent ab972dd commit 58710d1

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/stores/widgets/StopGapWidgetDriver.ts

+8
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ export class StopGapWidgetDriver extends WidgetDriver {
165165
WidgetEventCapability.forToDeviceEvent(EventDirection.Receive, eventType).raw,
166166
);
167167
}
168+
169+
// To always allow OIDC requests for element call, the widgetPermissionStore is used:
170+
SdkContextClass.instance.widgetPermissionStore.setOIDCState(
171+
forWidget,
172+
forWidgetKind,
173+
inRoomId,
174+
OIDCState.Allowed,
175+
);
168176
}
169177
}
170178

test/stores/widgets/WidgetPermissionStore-test.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ limitations under the License.
1616

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

2121
import { OIDCState, WidgetPermissionStore } from "../../../src/stores/widgets/WidgetPermissionStore";
2222
import SettingsStore from "../../../src/settings/SettingsStore";
2323
import { TestSdkContext } from "../../TestSdkContext";
2424
import { SettingLevel } from "../../../src/settings/SettingLevel";
2525
import { SdkContextClass } from "../../../src/contexts/SDKContext";
2626
import { stubClient } from "../../test-utils";
27+
import { StopGapWidgetDriver } from "../../../src/stores/widgets/StopGapWidgetDriver";
2728

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

@@ -38,6 +39,12 @@ describe("WidgetPermissionStore", () => {
3839
type: "m.custom",
3940
url: "https://invalid.address.here",
4041
});
42+
const elementCallWidget = new Widget({
43+
id: "group_call",
44+
creatorUserId: "@alice:example.org",
45+
type: MatrixWidgetType.Custom,
46+
url: "https://call.element.io",
47+
});
4148
let settings: Record<string, any> = {}; // key value store
4249

4350
beforeEach(() => {
@@ -92,4 +99,10 @@ describe("WidgetPermissionStore", () => {
9299
const store2 = context.widgetPermissionStore;
93100
expect(store2).toStrictEqual(store);
94101
});
102+
it("auto-approves OIDC requests for element-call", async () => {
103+
new StopGapWidgetDriver([], elementCallWidget, WidgetKind.Room, true, roomId);
104+
expect(widgetPermissionStore.getOIDCState(elementCallWidget, WidgetKind.Room, roomId)).toEqual(
105+
OIDCState.Allowed,
106+
);
107+
});
95108
});

0 commit comments

Comments
 (0)