mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 06:50:28 +03:00
Better invites management (#2336)
* move block users to account settings * filter invites and add more options * add better rate limit recovery in rateLimitedActions util function
This commit is contained in:
parent
0d27bde33e
commit
206ed33516
17 changed files with 1088 additions and 524 deletions
|
|
@ -19,6 +19,7 @@ import {
|
|||
import { CryptoBackend } from 'matrix-js-sdk/lib/common-crypto/CryptoBackend';
|
||||
import { AccountDataEvent } from '../../types/matrix/accountData';
|
||||
import {
|
||||
Membership,
|
||||
MessageEvent,
|
||||
NotificationType,
|
||||
RoomToParents,
|
||||
|
|
@ -171,7 +172,7 @@ export const getNotificationType = (mx: MatrixClient, roomId: string): Notificat
|
|||
}
|
||||
|
||||
if (!roomPushRule) {
|
||||
const overrideRules = mx.getAccountData('m.push_rules')?.getContent<IPushRules>()
|
||||
const overrideRules = mx.getAccountData(EventType.PushRules)?.getContent<IPushRules>()
|
||||
?.global?.override;
|
||||
if (!overrideRules) return NotificationType.Default;
|
||||
|
||||
|
|
@ -443,3 +444,32 @@ export const getMentionContent = (userIds: string[], room: boolean): IMentions =
|
|||
|
||||
return mMentions;
|
||||
};
|
||||
|
||||
export const getCommonRooms = (
|
||||
mx: MatrixClient,
|
||||
rooms: string[],
|
||||
otherUserId: string
|
||||
): string[] => {
|
||||
const commonRooms: string[] = [];
|
||||
|
||||
rooms.forEach((roomId) => {
|
||||
const room = mx.getRoom(roomId);
|
||||
if (!room || room.getMyMembership() !== Membership.Join) return;
|
||||
|
||||
const common = room.hasMembershipState(otherUserId, Membership.Join);
|
||||
if (common) {
|
||||
commonRooms.push(roomId);
|
||||
}
|
||||
});
|
||||
|
||||
return commonRooms;
|
||||
};
|
||||
|
||||
export const bannedInRooms = (mx: MatrixClient, rooms: string[], otherUserId: string): boolean =>
|
||||
rooms.some((roomId) => {
|
||||
const room = mx.getRoom(roomId);
|
||||
if (!room || room.getMyMembership() !== Membership.Join) return false;
|
||||
|
||||
const banned = room.hasMembershipState(otherUserId, Membership.Ban);
|
||||
return banned;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue