Add an option to force a default jitsi domain on the widget

Fixes https://github.com/turt2live/matrix-dimension/issues/231
This commit is contained in:
Travis Ralston 2018-12-22 19:30:25 -07:00
parent ac43f07fa9
commit 363003199a
5 changed files with 21 additions and 1 deletions

View File

@ -8,6 +8,7 @@ export interface EtherpadWidgetOptions {
export interface JitsiWidgetOptions { export interface JitsiWidgetOptions {
jitsiDomain: string; jitsiDomain: string;
scriptUrl: string; scriptUrl: string;
useDomainAsDefault: boolean;
} }
export class Widget extends Integration { export class Widget extends Integration {

View File

@ -10,6 +10,12 @@
placeholder="jitsi.riot.im" placeholder="jitsi.riot.im"
[(ngModel)]="widget.options.jitsiDomain" [disabled]="isUpdating"/> [(ngModel)]="widget.options.jitsiDomain" [disabled]="isUpdating"/>
</label> </label>
<label class="label-block">
Use this domain as the default conference domain
<span class="text-muted ">Some clients can create widgets that are not compatible with Dimension, making Dimension use jitsi.riot.im by default. By enabling this option, you'll force Dimension to use your Jitsi domain at risk of having clients not respect it.</span>
<ui-switch [checked]="widget.options.useDomainAsDefault" size="medium" [disabled]="isUpdating"
(change)="toggleForcedJitsi()"></ui-switch>
</label>
<label class="label-block"> <label class="label-block">
Jitsi Script URL Jitsi Script URL
<span class="text-muted ">This is used to create the Jitsi widget. It is normally at /libs/external_api.min.js from your domain.</span> <span class="text-muted ">This is used to create the Jitsi widget. It is normally at /libs/external_api.min.js from your domain.</span>

View File

@ -18,6 +18,9 @@ export class AdminWidgetJitsiConfigComponent implements ModalComponent<WidgetCon
constructor(public dialog: DialogRef<WidgetConfigDialogContext>, private adminIntegrationsApi: AdminIntegrationsApiService, private toaster: ToasterService) { constructor(public dialog: DialogRef<WidgetConfigDialogContext>, private adminIntegrationsApi: AdminIntegrationsApiService, private toaster: ToasterService) {
this.originalWidget = dialog.context.widget; this.originalWidget = dialog.context.widget;
this.widget = JSON.parse(JSON.stringify(this.originalWidget)); this.widget = JSON.parse(JSON.stringify(this.originalWidget));
// Fix the ui-switch not picking up a boolean value
this.widget.options.useDomainAsDefault = !!this.widget.options.useDomainAsDefault;
} }
public save() { public save() {
@ -32,4 +35,8 @@ export class AdminWidgetJitsiConfigComponent implements ModalComponent<WidgetCon
this.toaster.pop("error", "Error updating widget"); this.toaster.pop("error", "Error updating widget");
}); });
} }
public toggleForcedJitsi() {
this.widget.options.useDomainAsDefault = !this.widget.options.useDomainAsDefault;
}
} }

View File

@ -77,6 +77,7 @@ export interface FE_JitsiWidget extends FE_Widget {
options: { options: {
jitsiDomain: string; jitsiDomain: string;
scriptUrl: string; scriptUrl: string;
useDomainAsDefault: boolean;
}; };
} }

View File

@ -32,7 +32,7 @@ export class JitsiWidgetWrapperComponent extends CapableWidget implements OnInit
let params: any = activatedRoute.snapshot.queryParams; let params: any = activatedRoute.snapshot.queryParams;
this.domain = params.domain || "jitsi.riot.im"; // Riot doesn't supply a domain, so we default this.domain = params.domain;
this.conferenceId = params.confId || params.conferenceId; this.conferenceId = params.confId || params.conferenceId;
this.displayName = params.displayName; this.displayName = params.displayName;
this.avatarUrl = params.avatarUrl; this.avatarUrl = params.avatarUrl;
@ -44,6 +44,11 @@ export class JitsiWidgetWrapperComponent extends CapableWidget implements OnInit
this.widgetApi.getWidget("jitsi").then(integration => { this.widgetApi.getWidget("jitsi").then(integration => {
const widget = <FE_JitsiWidget>integration; const widget = <FE_JitsiWidget>integration;
$.getScript(widget.options.scriptUrl); $.getScript(widget.options.scriptUrl);
if (!this.domain) {
// Always fall back to jitsi.riot.im to maintain compatibility with widgets created by Riot.
this.domain = widget.options.useDomainAsDefault ? widget.options.jitsiDomain : "jitsi.riot.im";
}
}); });
this.jitsiApiSubscription = ScalarWidgetApi.requestReceived.subscribe(request => { this.jitsiApiSubscription = ScalarWidgetApi.requestReceived.subscribe(request => {
if (!this.isJoined) { if (!this.isJoined) {