lint
This commit is contained in:
parent
5d7adef0a2
commit
5b7e7f49d1
2 changed files with 10 additions and 6 deletions
|
@ -40,7 +40,6 @@ import rate_limited_func from '../../ratelimitedfunc';
|
||||||
import * as ObjectUtils from '../../ObjectUtils';
|
import * as ObjectUtils from '../../ObjectUtils';
|
||||||
import * as Rooms from '../../Rooms';
|
import * as Rooms from '../../Rooms';
|
||||||
import eventSearch from '../../Searching';
|
import eventSearch from '../../Searching';
|
||||||
import DMRoomMap from '../../utils/DMRoomMap';
|
|
||||||
|
|
||||||
import {isOnlyCtrlOrCmdKeyEvent, Key} from '../../Keyboard';
|
import {isOnlyCtrlOrCmdKeyEvent, Key} from '../../Keyboard';
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,17 @@ interface Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function shieldStatusForMembership(client: Client, room) {
|
interface Room {
|
||||||
|
getEncryptionTargetMembers: () => Promise<[{userId: string}]>;
|
||||||
|
roomId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function shieldStatusForMembership(client: Client, room: Room) {
|
||||||
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);
|
||||||
|
|
||||||
const verified = [];
|
const verified: string[] = [];
|
||||||
const unverified = [];
|
const unverified: string[] = [];
|
||||||
members.filter((userId) => userId !== client.getUserId())
|
members.filter((userId) => userId !== client.getUserId())
|
||||||
.forEach((userId) => {
|
.forEach((userId) => {
|
||||||
(client.checkUserTrust(userId).isCrossSigningVerified() ?
|
(client.checkUserTrust(userId).isCrossSigningVerified() ?
|
||||||
|
@ -28,8 +33,8 @@ export async function shieldStatusForMembership(client: Client, room) {
|
||||||
/* 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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue