1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-13 23:41:50 +03:00

Hide messages blocked by ban lists

This commit is contained in:
Travis Ralston
2019-10-31 16:19:42 -06:00
parent b420fd6758
commit 11068d189c
5 changed files with 91 additions and 1 deletions

View File

@ -18,6 +18,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import sdk from '../../../index';
import SettingsStore from "../../../settings/SettingsStore";
import {Mjolnir} from "../../../mjolnir/Mjolnir";
module.exports = createReactClass({
displayName: 'MessageEvent',
@ -49,6 +51,10 @@ module.exports = createReactClass({
return this.refs.body && this.refs.body.getEventTileOps ? this.refs.body.getEventTileOps() : null;
},
onTileUpdate: function() {
this.forceUpdate();
},
render: function() {
const UnknownBody = sdk.getComponent('messages.UnknownBody');
@ -81,6 +87,20 @@ module.exports = createReactClass({
}
}
if (SettingsStore.isFeatureEnabled("feature_mjolnir")) {
const allowRender = localStorage.getItem(`mx_mjolnir_render_${this.props.mxEvent.getRoomId()}__${this.props.mxEvent.getId()}`) === "true";
if (!allowRender) {
const userDomain = this.props.mxEvent.getSender().split(':').slice(1).join(':');
const userBanned = Mjolnir.sharedInstance().isUserBanned(this.props.mxEvent.getSender());
const serverBanned = Mjolnir.sharedInstance().isServerBanned(userDomain);
if (userBanned || serverBanned) {
BodyType = sdk.getComponent('messages.MjolnirBody');
}
}
}
return <BodyType
ref="body" mxEvent={this.props.mxEvent}
highlights={this.props.highlights}
@ -90,6 +110,8 @@ module.exports = createReactClass({
maxImageHeight={this.props.maxImageHeight}
replacingEventId={this.props.replacingEventId}
editState={this.props.editState}
onHeightChanged={this.props.onHeightChanged} />;
onHeightChanged={this.props.onHeightChanged}
onTileUpdate={this.onTileUpdate}
/>;
},
});