You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-04 11:51:45 +03:00 
			
		
		
		
	Remove legacy codepaths for Unknown Device Error (UDE/UDD) handling
as we now always `setGlobalErrorOnUnknownDevices(false)` Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
		@@ -24,7 +24,6 @@ import { _t, _td } from '../../languageHandler';
 | 
			
		||||
import * as sdk from '../../index';
 | 
			
		||||
import {MatrixClientPeg} from '../../MatrixClientPeg';
 | 
			
		||||
import Resend from '../../Resend';
 | 
			
		||||
import * as cryptodevices from '../../cryptodevices';
 | 
			
		||||
import dis from '../../dispatcher/dispatcher';
 | 
			
		||||
import {messageForResourceLimitError, messageForSendError} from '../../utils/ErrorUtils';
 | 
			
		||||
 | 
			
		||||
@@ -126,13 +125,6 @@ export default createReactClass({
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    _onSendWithoutVerifyingClick: function() {
 | 
			
		||||
        cryptodevices.getUnknownDevicesForRoom(MatrixClientPeg.get(), this.props.room).then((devices) => {
 | 
			
		||||
            cryptodevices.markAllDevicesKnown(MatrixClientPeg.get(), devices);
 | 
			
		||||
            Resend.resendUnsentEvents(this.props.room);
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    _onResendAllClick: function() {
 | 
			
		||||
        Resend.resendUnsentEvents(this.props.room);
 | 
			
		||||
        dis.dispatch({action: 'focus_composer'});
 | 
			
		||||
@@ -143,10 +135,6 @@ export default createReactClass({
 | 
			
		||||
        dis.dispatch({action: 'focus_composer'});
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    _onShowDevicesClick: function() {
 | 
			
		||||
        cryptodevices.showUnknownDeviceDialogForMessages(MatrixClientPeg.get(), this.props.room);
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    _onRoomLocalEchoUpdated: function(event, room, oldEventId, oldStatus) {
 | 
			
		||||
        if (room.roomId !== this.props.room.roomId) return;
 | 
			
		||||
 | 
			
		||||
@@ -213,82 +201,65 @@ export default createReactClass({
 | 
			
		||||
        if (!unsentMessages.length) return null;
 | 
			
		||||
 | 
			
		||||
        let title;
 | 
			
		||||
        let content;
 | 
			
		||||
 | 
			
		||||
        const hasUDE = unsentMessages.some((m) => {
 | 
			
		||||
            return m.error && m.error.name === "UnknownDeviceError";
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        if (hasUDE) {
 | 
			
		||||
            title = _t("Message not sent due to unknown sessions being present");
 | 
			
		||||
            content = _t(
 | 
			
		||||
                "<showSessionsText>Show sessions</showSessionsText>, <sendAnywayText>send anyway</sendAnywayText> or <cancelText>cancel</cancelText>.",
 | 
			
		||||
        let consentError = null;
 | 
			
		||||
        let resourceLimitError = null;
 | 
			
		||||
        for (const m of unsentMessages) {
 | 
			
		||||
            if (m.error && m.error.errcode === 'M_CONSENT_NOT_GIVEN') {
 | 
			
		||||
                consentError = m.error;
 | 
			
		||||
                break;
 | 
			
		||||
            } else if (m.error && m.error.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
 | 
			
		||||
                resourceLimitError = m.error;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (consentError) {
 | 
			
		||||
            title = _t(
 | 
			
		||||
                "You can't send any messages until you review and agree to " +
 | 
			
		||||
                "<consentLink>our terms and conditions</consentLink>.",
 | 
			
		||||
                {},
 | 
			
		||||
                {
 | 
			
		||||
                    'showSessionsText': (sub) => <a className="mx_RoomStatusBar_resend_link" key="resend" onClick={this._onShowDevicesClick}>{ sub }</a>,
 | 
			
		||||
                    'sendAnywayText': (sub) => <a className="mx_RoomStatusBar_resend_link" key="sendAnyway" onClick={this._onSendWithoutVerifyingClick}>{ sub }</a>,
 | 
			
		||||
                    'cancelText': (sub) => <a className="mx_RoomStatusBar_resend_link" key="cancel" onClick={this._onCancelAllClick}>{ sub }</a>,
 | 
			
		||||
                    'consentLink': (sub) =>
 | 
			
		||||
                        <a href={consentError.data && consentError.data.consent_uri} target="_blank">
 | 
			
		||||
                            { sub }
 | 
			
		||||
                        </a>,
 | 
			
		||||
                },
 | 
			
		||||
            );
 | 
			
		||||
        } else if (resourceLimitError) {
 | 
			
		||||
            title = messageForResourceLimitError(
 | 
			
		||||
                resourceLimitError.data.limit_type,
 | 
			
		||||
                resourceLimitError.data.admin_contact, {
 | 
			
		||||
                'monthly_active_user': _td(
 | 
			
		||||
                    "Your message wasn't sent because this homeserver has hit its Monthly Active User Limit. " +
 | 
			
		||||
                    "Please <a>contact your service administrator</a> to continue using the service.",
 | 
			
		||||
                ),
 | 
			
		||||
                '': _td(
 | 
			
		||||
                    "Your message wasn't sent because this homeserver has exceeded a resource limit. " +
 | 
			
		||||
                    "Please <a>contact your service administrator</a> to continue using the service.",
 | 
			
		||||
                ),
 | 
			
		||||
            });
 | 
			
		||||
        } else if (
 | 
			
		||||
            unsentMessages.length === 1 &&
 | 
			
		||||
            unsentMessages[0].error &&
 | 
			
		||||
            unsentMessages[0].error.data &&
 | 
			
		||||
            unsentMessages[0].error.data.error
 | 
			
		||||
        ) {
 | 
			
		||||
            title = messageForSendError(unsentMessages[0].error.data) || unsentMessages[0].error.data.error;
 | 
			
		||||
        } else {
 | 
			
		||||
            let consentError = null;
 | 
			
		||||
            let resourceLimitError = null;
 | 
			
		||||
            for (const m of unsentMessages) {
 | 
			
		||||
                if (m.error && m.error.errcode === 'M_CONSENT_NOT_GIVEN') {
 | 
			
		||||
                    consentError = m.error;
 | 
			
		||||
                    break;
 | 
			
		||||
                } else if (m.error && m.error.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
 | 
			
		||||
                    resourceLimitError = m.error;
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (consentError) {
 | 
			
		||||
                title = _t(
 | 
			
		||||
                    "You can't send any messages until you review and agree to " +
 | 
			
		||||
                    "<consentLink>our terms and conditions</consentLink>.",
 | 
			
		||||
                    {},
 | 
			
		||||
                    {
 | 
			
		||||
                        'consentLink': (sub) =>
 | 
			
		||||
                            <a href={consentError.data && consentError.data.consent_uri} target="_blank">
 | 
			
		||||
                                { sub }
 | 
			
		||||
                            </a>,
 | 
			
		||||
                    },
 | 
			
		||||
                );
 | 
			
		||||
            } else if (resourceLimitError) {
 | 
			
		||||
                title = messageForResourceLimitError(
 | 
			
		||||
                    resourceLimitError.data.limit_type,
 | 
			
		||||
                    resourceLimitError.data.admin_contact, {
 | 
			
		||||
                    'monthly_active_user': _td(
 | 
			
		||||
                        "Your message wasn't sent because this homeserver has hit its Monthly Active User Limit. " +
 | 
			
		||||
                        "Please <a>contact your service administrator</a> to continue using the service.",
 | 
			
		||||
                    ),
 | 
			
		||||
                    '': _td(
 | 
			
		||||
                        "Your message wasn't sent because this homeserver has exceeded a resource limit. " +
 | 
			
		||||
                        "Please <a>contact your service administrator</a> to continue using the service.",
 | 
			
		||||
                    ),
 | 
			
		||||
                });
 | 
			
		||||
            } else if (
 | 
			
		||||
                unsentMessages.length === 1 &&
 | 
			
		||||
                unsentMessages[0].error &&
 | 
			
		||||
                unsentMessages[0].error.data &&
 | 
			
		||||
                unsentMessages[0].error.data.error
 | 
			
		||||
            ) {
 | 
			
		||||
                title = messageForSendError(unsentMessages[0].error.data) || unsentMessages[0].error.data.error;
 | 
			
		||||
            } else {
 | 
			
		||||
                title = _t('%(count)s of your messages have not been sent.', { count: unsentMessages.length });
 | 
			
		||||
            }
 | 
			
		||||
            content = _t("%(count)s <resendText>Resend all</resendText> or <cancelText>cancel all</cancelText> now. " +
 | 
			
		||||
               "You can also select individual messages to resend or cancel.",
 | 
			
		||||
                { count: unsentMessages.length },
 | 
			
		||||
                {
 | 
			
		||||
                    'resendText': (sub) =>
 | 
			
		||||
                        <a className="mx_RoomStatusBar_resend_link" key="resend" onClick={this._onResendAllClick}>{ sub }</a>,
 | 
			
		||||
                    'cancelText': (sub) =>
 | 
			
		||||
                        <a className="mx_RoomStatusBar_resend_link" key="cancel" onClick={this._onCancelAllClick}>{ sub }</a>,
 | 
			
		||||
                },
 | 
			
		||||
            );
 | 
			
		||||
            title = _t('%(count)s of your messages have not been sent.', { count: unsentMessages.length });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const content = _t("%(count)s <resendText>Resend all</resendText> or <cancelText>cancel all</cancelText> " +
 | 
			
		||||
            "now. You can also select individual messages to resend or cancel.",
 | 
			
		||||
            { count: unsentMessages.length },
 | 
			
		||||
            {
 | 
			
		||||
                'resendText': (sub) =>
 | 
			
		||||
                    <a className="mx_RoomStatusBar_resend_link" key="resend" onClick={this._onResendAllClick}>{ sub }</a>,
 | 
			
		||||
                'cancelText': (sub) =>
 | 
			
		||||
                    <a className="mx_RoomStatusBar_resend_link" key="cancel" onClick={this._onCancelAllClick}>{ sub }</a>,
 | 
			
		||||
            },
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        return <div className="mx_RoomStatusBar_connectionLostBar">
 | 
			
		||||
            <img src={require("../../../res/img/feather-customised/warning-triangle.svg")} width="24" height="24" title={_t("Warning")} alt="" />
 | 
			
		||||
            <div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user