mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-26 21:28:40 +00:00
Rename files
This commit is contained in:
28
ts/util/areWeAdmin.preload.ts
Normal file
28
ts/util/areWeAdmin.preload.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { ConversationAttributesType } from '../model-types.d.ts';
|
||||
import { SignalService as Proto } from '../protobuf/index.std.js';
|
||||
import { isGroupV2 } from './whatTypeOfConversation.dom.js';
|
||||
import { itemStorage } from '../textsecure/Storage.preload.js';
|
||||
|
||||
export function areWeAdmin(
|
||||
attributes: Pick<
|
||||
ConversationAttributesType,
|
||||
'groupId' | 'groupVersion' | 'membersV2'
|
||||
>
|
||||
): boolean {
|
||||
if (!isGroupV2(attributes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const memberEnum = Proto.Member.Role;
|
||||
const members = attributes.membersV2 || [];
|
||||
const ourAci = itemStorage.user.getAci();
|
||||
const me = members.find(item => item.aci === ourAci);
|
||||
if (!me) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return me.role === memberEnum.ADMINISTRATOR;
|
||||
}
|
||||
Reference in New Issue
Block a user