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

Commit 74c159a

Browse files
committed
Display "The sender has blocked you from receiving this message" error message instead of "Unable to decrypt message"
1 parent e3b1eff commit 74c159a

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/components/views/messages/DecryptionFailureBody.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { ReactNode } from "react";
17+
import React from "react";
18+
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
1819

1920
import { _t } from "../../../languageHandler";
2021
import { IBodyProps } from "./IBodyProps";
2122

23+
function getErrorMessage(mxEvent: MatrixEvent): string {
24+
return mxEvent.isEncryptedDisabledForUnverifiedDevices()
25+
? _t("The sender has blocked you from receiving this message")
26+
: _t("Unable to decrypt message");
27+
}
28+
2229
// A placeholder element for messages that could not be decrypted
23-
export default class DecryptionFailureBody extends React.Component<Partial<IBodyProps>> {
24-
public render(): ReactNode {
25-
return <div className="mx_DecryptionFailureBody mx_EventTile_content">{_t("Unable to decrypt message")}</div>;
26-
}
30+
export function DecryptionFailureBody({ mxEvent }: Partial<IBodyProps>): JSX.Element {
31+
return <div className="mx_DecryptionFailureBody mx_EventTile_content">{getErrorMessage(mxEvent)}</div>;
2732
}

src/components/views/messages/MessageEvent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { MPollEndBody } from "./MPollEndBody";
4141
import MLocationBody from "./MLocationBody";
4242
import MjolnirBody from "./MjolnirBody";
4343
import MBeaconBody from "./MBeaconBody";
44-
import DecryptionFailureBody from "./DecryptionFailureBody";
44+
import { DecryptionFailureBody } from "./DecryptionFailureBody";
4545
import { GetRelationsForEvent, IEventTileOps } from "../rooms/EventTile";
4646
import { VoiceBroadcastBody, VoiceBroadcastInfoEventType, VoiceBroadcastInfoState } from "../../../voice-broadcast";
4747

src/components/views/rooms/EventTile.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { Layout } from "../../../settings/enums/Layout";
3535
import { formatTime } from "../../../DateUtils";
3636
import { MatrixClientPeg } from "../../../MatrixClientPeg";
3737
import MatrixClientContext from "../../../contexts/MatrixClientContext";
38-
import DecryptionFailureBody from "../messages/DecryptionFailureBody";
38+
import { DecryptionFailureBody } from "../messages/DecryptionFailureBody";
3939
import { E2EState } from "./E2EIcon";
4040
import RoomAvatar from "../avatars/RoomAvatar";
4141
import MessageContextMenu from "../context_menus/MessageContextMenu";
@@ -1270,7 +1270,7 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
12701270
{this.props.mxEvent.isRedacted() ? (
12711271
<RedactedBody mxEvent={this.props.mxEvent} />
12721272
) : this.props.mxEvent.isDecryptionFailure() ? (
1273-
<DecryptionFailureBody />
1273+
<DecryptionFailureBody mxEvent={this.props.mxEvent} />
12741274
) : (
12751275
MessagePreviewStore.instance.generatePreviewForEvent(this.props.mxEvent)
12761276
)}

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,6 +2328,7 @@
23282328
"Last month": "Last month",
23292329
"The beginning of the room": "The beginning of the room",
23302330
"Jump to date": "Jump to date",
2331+
"The sender has blocked you from receiving this message": "The sender has blocked you from receiving this message",
23312332
"%(displayName)s (%(matrixId)s)": "%(displayName)s (%(matrixId)s)",
23322333
"Downloading": "Downloading",
23332334
"Decrypting": "Decrypting",

0 commit comments

Comments
 (0)