Moves conversation.getProps out of models
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
a0d7c36e3b
commit
7c1957c30d
21 changed files with 810 additions and 598 deletions
27
ts/util/areWeAdmin.ts
Normal file
27
ts/util/areWeAdmin.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { ConversationAttributesType } from '../model-types';
|
||||
import { SignalService as Proto } from '../protobuf';
|
||||
import { isGroupV2 } from './whatTypeOfConversation';
|
||||
|
||||
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 ourUuid = window.textsecure.storage.user.getUuid()?.toString();
|
||||
const me = members.find(item => item.uuid === ourUuid);
|
||||
if (!me) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return me.role === memberEnum.ADMINISTRATOR;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue