mirror of https://github.com/vector-im/riot-web
review feedback
parent
4f3d4426ea
commit
098df07c67
|
@ -55,7 +55,7 @@ import RightPanelStore from "../../stores/RightPanelStore";
|
||||||
import {haveTileForEvent} from "../views/rooms/EventTile";
|
import {haveTileForEvent} from "../views/rooms/EventTile";
|
||||||
import RoomContext from "../../contexts/RoomContext";
|
import RoomContext from "../../contexts/RoomContext";
|
||||||
import MatrixClientContext from "../../contexts/MatrixClientContext";
|
import MatrixClientContext from "../../contexts/MatrixClientContext";
|
||||||
import { shieldStatusForMembership } from '../../utils/ShieldUtils';
|
import { shieldStatusForRoom } from '../../utils/ShieldUtils';
|
||||||
|
|
||||||
const DEBUG = false;
|
const DEBUG = false;
|
||||||
let debuglog = function() {};
|
let debuglog = function() {};
|
||||||
|
@ -820,7 +820,7 @@ export default createReactClass({
|
||||||
|
|
||||||
/* At this point, the user has encryption on and cross-signing on */
|
/* At this point, the user has encryption on and cross-signing on */
|
||||||
this.setState({
|
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';
|
import InviteOnlyIcon from './InviteOnlyIcon';
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
import rate_limited_func from '../../../ratelimitedfunc';
|
import rate_limited_func from '../../../ratelimitedfunc';
|
||||||
import { shieldStatusForMembership } from '../../../utils/ShieldUtils';
|
import { shieldStatusForRoom } from '../../../utils/ShieldUtils';
|
||||||
|
|
||||||
export default createReactClass({
|
export default createReactClass({
|
||||||
displayName: 'RoomTile',
|
displayName: 'RoomTile',
|
||||||
|
@ -157,7 +157,7 @@ export default createReactClass({
|
||||||
|
|
||||||
/* At this point, the user has encryption on and cross-signing on */
|
/* At this point, the user has encryption on and cross-signing on */
|
||||||
this.setState({
|
this.setState({
|
||||||
e2eStatus: await shieldStatusForMembership(cli, this.props.room),
|
e2eStatus: await shieldStatusForRoom(cli, this.props.room),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ interface Room {
|
||||||
roomId: string;
|
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 members = (await room.getEncryptionTargetMembers()).map(({userId}) => userId);
|
||||||
const inDMMap = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId);
|
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 */
|
/* 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
|
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
|
!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 !== 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 === 1); // Do alarm for self if we're alone in a room
|
||||||
const targets = includeUser ? [...verified, client.getUserId()] : verified;
|
const targets = includeUser ? [...verified, client.getUserId()] : verified;
|
||||||
for (const userId of targets) {
|
for (const userId of targets) {
|
||||||
const devices = await client.getStoredDevicesForUser(userId);
|
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';
|
import DMRoomMap from '../../src/utils/DMRoomMap';
|
||||||
|
|
||||||
function mkClient(selfTrust) {
|
function mkClient(selfTrust) {
|
||||||
|
@ -55,7 +55,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
||||||
roomId: dm ? "DM" : "other",
|
roomId: dm ? "DM" : "other",
|
||||||
getEncryptionTargetMembers: () => ["@self:localhost", "@FF1:h", "@FF2:h"].map((userId) => ({userId})),
|
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");
|
expect(status).toEqual("normal");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
||||||
roomId: dm ? "DM" : "other",
|
roomId: dm ? "DM" : "other",
|
||||||
getEncryptionTargetMembers: () => ["@self:localhost", "@TT1:h", "@TT2:h"].map((userId) => ({userId})),
|
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);
|
expect(status).toEqual(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
||||||
roomId: dm ? "DM" : "other",
|
roomId: dm ? "DM" : "other",
|
||||||
getEncryptionTargetMembers: () => ["@self:localhost", "@TT1:h", "@FF2:h"].map((userId) => ({userId})),
|
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);
|
expect(status).toEqual(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
||||||
roomId: dm ? "DM" : "other",
|
roomId: dm ? "DM" : "other",
|
||||||
getEncryptionTargetMembers: () => ["@self:localhost"].map((userId) => ({userId})),
|
getEncryptionTargetMembers: () => ["@self:localhost"].map((userId) => ({userId})),
|
||||||
};
|
};
|
||||||
const status = await shieldStatusForMembership(client, room);
|
const status = await shieldStatusForRoom(client, room);
|
||||||
expect(status).toEqual(result);
|
expect(status).toEqual(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
||||||
roomId: dm ? "DM" : "other",
|
roomId: dm ? "DM" : "other",
|
||||||
getEncryptionTargetMembers: () => ["@self:localhost", "@TT:h"].map((userId) => ({userId})),
|
getEncryptionTargetMembers: () => ["@self:localhost", "@TT:h"].map((userId) => ({userId})),
|
||||||
};
|
};
|
||||||
const status = await shieldStatusForMembership(client, room);
|
const status = await shieldStatusForRoom(client, room);
|
||||||
expect(status).toEqual(result);
|
expect(status).toEqual(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ describe("shieldStatusForMembership self-trust behaviour", function() {
|
||||||
roomId: dm ? "DM" : "other",
|
roomId: dm ? "DM" : "other",
|
||||||
getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h"].map((userId) => ({userId})),
|
getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h"].map((userId) => ({userId})),
|
||||||
};
|
};
|
||||||
const status = await shieldStatusForMembership(client, room);
|
const status = await shieldStatusForRoom(client, room);
|
||||||
expect(status).toEqual(result);
|
expect(status).toEqual(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -140,7 +140,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() {
|
||||||
roomId: dm ? "DM" : "other",
|
roomId: dm ? "DM" : "other",
|
||||||
getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h"].map((userId) => ({userId})),
|
getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h"].map((userId) => ({userId})),
|
||||||
};
|
};
|
||||||
const status = await shieldStatusForMembership(client, room);
|
const status = await shieldStatusForRoom(client, room);
|
||||||
expect(status).toEqual(result);
|
expect(status).toEqual(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() {
|
||||||
roomId: dm ? "DM" : "other",
|
roomId: dm ? "DM" : "other",
|
||||||
getEncryptionTargetMembers: () => ["@self:localhost", "@TF:h", "@TT: h"].map((userId) => ({userId})),
|
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);
|
expect(status).toEqual(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ describe("shieldStatusForMembership other-trust behaviour", function() {
|
||||||
roomId: dm ? "DM" : "other",
|
roomId: dm ? "DM" : "other",
|
||||||
getEncryptionTargetMembers: () => ["@self:localhost", "@FF:h", "@FT: h"].map((userId) => ({userId})),
|
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);
|
expect(status).toEqual(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue