2022-01-17 16:04:37 +01:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-01-17 16:04:37 +01:00
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
2024-09-09 14:57:16 +01:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2022-01-17 16:04:37 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
2023-08-07 09:24:58 +01:00
|
|
|
import { MatrixEvent } from "matrix-js-sdk/src/matrix";
|
2022-01-17 16:04:37 +01:00
|
|
|
|
|
|
|
|
import { _t } from "../../../languageHandler";
|
|
|
|
|
import { IBodyProps } from "./IBodyProps";
|
|
|
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
|
mxEvent: MatrixEvent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A message hidden from the user pending moderation.
|
|
|
|
|
*
|
|
|
|
|
* Note: This component must not be used when the user is the author of the message
|
|
|
|
|
* or has a sufficient powerlevel to see the message.
|
|
|
|
|
*/
|
|
|
|
|
const HiddenBody = React.forwardRef<any, IProps | IBodyProps>(({ mxEvent }, ref) => {
|
|
|
|
|
let text;
|
|
|
|
|
const visibility = mxEvent.messageVisibility();
|
|
|
|
|
switch (visibility.visible) {
|
|
|
|
|
case true:
|
|
|
|
|
throw new Error("HiddenBody should only be applied to hidden messages");
|
|
|
|
|
case false:
|
|
|
|
|
if (visibility.reason) {
|
2023-10-02 13:52:27 +01:00
|
|
|
text = _t("timeline|pending_moderation_reason", { reason: visibility.reason });
|
2022-01-17 16:04:37 +01:00
|
|
|
} else {
|
2023-10-02 13:52:27 +01:00
|
|
|
text = _t("timeline|pending_moderation");
|
2022-01-17 16:04:37 +01:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<span className="mx_HiddenBody" ref={ref}>
|
|
|
|
|
{text}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default HiddenBody;
|