mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
review feedback
This commit is contained in:
parent
4f3d4426ea
commit
098df07c67
4 changed files with 17 additions and 17 deletions
|
@ -55,7 +55,7 @@ import RightPanelStore from "../../stores/RightPanelStore";
|
|||
import {haveTileForEvent} from "../views/rooms/EventTile";
|
||||
import RoomContext from "../../contexts/RoomContext";
|
||||
import MatrixClientContext from "../../contexts/MatrixClientContext";
|
||||
import { shieldStatusForMembership } from '../../utils/ShieldUtils';
|
||||
import { shieldStatusForRoom } from '../../utils/ShieldUtils';
|
||||
|
||||
const DEBUG = false;
|
||||
let debuglog = function() {};
|
||||
|
@ -820,7 +820,7 @@ export default createReactClass({
|
|||
|
||||
/* At this point, the user has encryption on and cross-signing on */
|
||||
this.setState({
|
||||
e2eStatus: await shieldStatusForMembership(this.context, room),
|
||||
e2eStatus: await shieldStatusForRoom(this.context, room),
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import E2EIcon from './E2EIcon';
|
|||
import InviteOnlyIcon from './InviteOnlyIcon';
|
||||
// eslint-disable-next-line camelcase
|
||||
import rate_limited_func from '../../../ratelimitedfunc';
|
||||
import { shieldStatusForMembership } from '../../../utils/ShieldUtils';
|
||||
import { shieldStatusForRoom } from '../../../utils/ShieldUtils';
|
||||
|
||||
export default createReactClass({
|
||||
displayName: 'RoomTile',
|
||||
|
@ -157,7 +157,7 @@ export default createReactClass({
|
|||
|
||||
/* At this point, the user has encryption on and cross-signing on */
|
||||
this.setState({
|
||||
e2eStatus: await shieldStatusForMembership(cli, this.props.room),
|
||||
e2eStatus: await shieldStatusForRoom(cli, this.props.room),
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ interface Room {
|
|||
roomId: string;
|
||||
}
|
||||
|
||||
export async function shieldStatusForMembership(client: Client, room: Room): Promise<string> {
|
||||
export async function shieldStatusForRoom(client: Client, room: Room): Promise<string> {
|
||||
const members = (await room.getEncryptionTargetMembers()).map(({userId}) => userId);
|
||||
const inDMMap = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId);
|
||||
|
||||
|
@ -33,8 +33,8 @@ export async function shieldStatusForMembership(client: Client, room: Room): Pro
|
|||
/* Don't alarm if no other users are verified */
|
||||
const includeUser = (verified.length > 0) && // Don't alarm for self in rooms where nobody else is verified
|
||||
!inDMMap && // Don't alarm for self in DMs with other users
|
||||
(members.length !== 2) || // Don't alarm for self in 1:1 chats with other users
|
||||
(members.length === 1); // Do alarm for self if we're alone in a room
|
||||
(members.length !== 2) || // Don't alarm for self in 1:1 chats with other users
|
||||
(members.length === 1); // Do alarm for self if we're alone in a room
|
||||
const targets = includeUser ? [...verified, client.getUserId()] : verified;
|
||||
for (const userId of targets) {
|
||||
const devices = await client.getStoredDevicesForUser(userId);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { shieldStatusForMembership } from '../../src/utils/ShieldUtils';
|
||||
import { shieldStatusForRoom } from '../../src/utils/ShieldUtils';
|
||||
import DMRoomMap from '../../src/utils/DMRoomMap';
|
||||
|
||||
function mkClient(selfTrust) {
|
||||
|
@ -55,7 +55,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
|||
roomId: dm ? "DM" : "other",
|
||||
getEncryptionTargetMembers: () => ["@self:localhost", "@FF1:h", "@FF2:h"].map((userId) => ({userId})),
|
||||
};
|
||||
const status = await shieldStatusForMembership(client, room);
|
||||
const status = await shieldStatusForRoom(client, room);
|
||||
expect(status).toEqual("normal");
|
||||
});
|
||||
|
||||
|
@ -68,7 +68,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
|||
roomId: dm ? "DM" : "other",
|
||||
getEncryptionTargetMembers: () => ["@self:localhost", "@TT1:h", "@TT2:h"].map((userId) => ({userId})),
|
||||
};
|
||||
const status = await shieldStatusForMembership(client, room);
|
||||
const status = await shieldStatusForRoom(client, room);
|
||||
expect(status).toEqual(result);
|
||||
});
|
||||
|
||||
|
@ -81,7 +81,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
|||
roomId: dm ? "DM" : "other",
|
||||
getEncryptionTargetMembers: () => ["@self:localhost", "@TT1:h", "@FF2:h"].map((userId) => ({userId})),
|
||||
};
|
||||
const status = await shieldStatusForMembership(client, room);
|
||||
const status = await shieldStatusForRoom(client, room);
|
||||
expect(status).toEqual(result);
|
||||
});
|
||||
|
||||
|
@ -94,7 +94,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
|||
roomId: dm ? "DM" : "other",
|
||||
getEncryptionTargetMembers: () => ["@self:localhost"].map((userId) => ({userId})),
|
||||
};
|
||||
const status = await shieldStatusForMembership(client, room);
|
||||
const status = await shieldStatusForRoom(client, room);
|
||||
expect(status).toEqual(result);
|
||||
});
|
||||
|
||||
|
@ -107,7 +107,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
|||
roomId: dm ? "DM" : "other",
|
||||
getEncryptionTargetMembers: () => ["@self:localhost", "@TT:h"].map((userId) => ({userId})),
|
||||
};
|
||||
const status = await shieldStatusForMembership(client, room);
|
||||
const status = await shieldStatusForRoom(client, room);
|
||||
expect(status).toEqual(result);
|
||||
});
|
||||
|
||||
|
@ -120,7 +120,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
|||
roomId: dm ? "DM" : "other",
|
||||
getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h"].map((userId) => ({userId})),
|
||||
};
|
||||
const status = await shieldStatusForMembership(client, room);
|
||||
const status = await shieldStatusForRoom(client, room);
|
||||
expect(status).toEqual(result);
|
||||
});
|
||||
});
|
||||
|
@ -140,7 +140,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() {
|
|||
roomId: dm ? "DM" : "other",
|
||||
getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h"].map((userId) => ({userId})),
|
||||
};
|
||||
const status = await shieldStatusForMembership(client, room);
|
||||
const status = await shieldStatusForRoom(client, room);
|
||||
expect(status).toEqual(result);
|
||||
});
|
||||
|
||||
|
@ -152,7 +152,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() {
|
|||
roomId: dm ? "DM" : "other",
|
||||
getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h", "@TT: h"].map((userId) => ({userId})),
|
||||
};
|
||||
const status = await shieldStatusForMembership(client, room);
|
||||
const status = await shieldStatusForRoom(client, room);
|
||||
expect(status).toEqual(result);
|
||||
});
|
||||
|
||||
|
@ -164,7 +164,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() {
|
|||
roomId: dm ? "DM" : "other",
|
||||
getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h", "@FT: h"].map((userId) => ({userId})),
|
||||
};
|
||||
const status = await shieldStatusForMembership(client, room);
|
||||
const status = await shieldStatusForRoom(client, room);
|
||||
expect(status).toEqual(result);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue