Skip to content

Commit

Permalink
fix(connection): Detects tenant hyphen and length problems and show n…
Browse files Browse the repository at this point in the history
…otification.
  • Loading branch information
damencho authored and saghul committed Nov 15, 2024
1 parent d438292 commit 6af4d18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lang/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,9 @@
"gifsMenu": "GIPHY",
"groupTitle": "Notifications",
"hostAskedUnmute": "The moderator would like you to speak",
"invalidTenant": "Invalid tenant",
"invalidTenantHyphenDescription": "The tenant you are using is invalid (starts or ends with '-').",
"invalidTenantLengthDescription": "The tenant you are using is too long.",
"invitedOneMember": "{{name}} has been invited",
"invitedThreePlusMembers": "{{name}} and {{count}} others have been invited",
"invitedTwoMembers": "{{first}} and {{second}} have been invited",
Expand Down
17 changes: 16 additions & 1 deletion react/features/base/conference/middleware.any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
import StateListenerRegistry from '../redux/StateListenerRegistry';
import { TRACK_ADDED, TRACK_REMOVED } from '../tracks/actionTypes';
import { parseURIString } from '../util/uri';

import {
CONFERENCE_FAILED,
Expand Down Expand Up @@ -421,13 +422,27 @@ function _connectionFailed({ dispatch, getState }: IStore, next: Function, actio
}

if (error.name === JitsiConnectionErrors.CONFERENCE_REQUEST_FAILED) {
let notificationAction: Function = showNotification;
const notificationProps = {
customActionNameKey: [ 'dialog.rejoinNow' ],
customActionHandler: [ () => dispatch(reloadNow()) ],
descriptionKey: 'notify.connectionFailed'
} as INotificationProps;

dispatch(showNotification(notificationProps, NOTIFICATION_TIMEOUT_TYPE.STICKY));
const { locationURL = { href: '' } as URL } = getState()['features/base/connection'];
const { tenant } = parseURIString(locationURL.href) || {};

if (tenant.startsWith('-') || tenant.endsWith('-')) {
notificationProps.descriptionKey = 'notify.invalidTenantHyphenDescription';
notificationProps.titleKey = 'notify.invalidTenant';
notificationAction = showErrorNotification;
} else if (tenant.length > 63) {
notificationProps.descriptionKey = 'notify.invalidTenantLengthDescription';
notificationProps.titleKey = 'notify.invalidTenant';
notificationAction = showErrorNotification;
}

dispatch(notificationAction(notificationProps, NOTIFICATION_TIMEOUT_TYPE.STICKY));
}

const result = next(action);
Expand Down

0 comments on commit 6af4d18

Please sign in to comment.