mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Support for announcement-only groups
This commit is contained in:
@@ -121,6 +121,8 @@ export type ConversationType = {
|
||||
accessControlAddFromInviteLink?: number;
|
||||
accessControlAttributes?: number;
|
||||
accessControlMembers?: number;
|
||||
announcementsOnly?: boolean;
|
||||
announcementsOnlyReady?: boolean;
|
||||
expireTimer?: number;
|
||||
memberships?: Array<{
|
||||
conversationId: string;
|
||||
|
||||
@@ -26,6 +26,7 @@ import { isConversationUnregistered } from '../../util/isConversationUnregistere
|
||||
import { filterAndSortConversationsByTitle } from '../../util/filterAndSortConversations';
|
||||
import { ContactNameColors, ContactNameColorType } from '../../types/Colors';
|
||||
import { isInSystemContacts } from '../../util/isInSystemContacts';
|
||||
import { isGroupV2 } from '../../util/whatTypeOfConversation';
|
||||
|
||||
import {
|
||||
getIntl,
|
||||
@@ -894,3 +895,32 @@ export function isMissingRequiredProfileSharing(
|
||||
conversation.messageCount > 0
|
||||
);
|
||||
}
|
||||
|
||||
export const getGroupAdminsSelector = createSelector(
|
||||
getConversationSelector,
|
||||
(conversationSelector: GetConversationByIdType) => {
|
||||
return (conversationId: string): Array<ConversationType> => {
|
||||
const { groupId, groupVersion, memberships = [] } = conversationSelector(
|
||||
conversationId
|
||||
);
|
||||
|
||||
if (
|
||||
!isGroupV2({
|
||||
groupId,
|
||||
groupVersion,
|
||||
})
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const admins: Array<ConversationType> = [];
|
||||
memberships.forEach(membership => {
|
||||
if (membership.isAdmin) {
|
||||
const admin = conversationSelector(membership.conversationId);
|
||||
admins.push(admin);
|
||||
}
|
||||
});
|
||||
return admins;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1133,6 +1133,11 @@ export function canReply(
|
||||
return false;
|
||||
}
|
||||
|
||||
// Groups where only admins can send messages
|
||||
if (conversation.announcementsOnly && !conversation.areWeAdmin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We can reply if this is outgoing and sent to at least one recipient
|
||||
if (isOutgoing(message)) {
|
||||
return (
|
||||
|
||||
@@ -12,6 +12,7 @@ import { selectRecentEmojis } from '../selectors/emojis';
|
||||
import { getIntl, getUserConversationId } from '../selectors/user';
|
||||
import {
|
||||
getConversationSelector,
|
||||
getGroupAdminsSelector,
|
||||
isMissingRequiredProfileSharing,
|
||||
} from '../selectors/conversations';
|
||||
import { getPropsForQuote } from '../selectors/message';
|
||||
@@ -38,7 +39,12 @@ const mapStateToProps = (state: StateType, props: ExternalProps) => {
|
||||
throw new Error(`Conversation id ${id} not found!`);
|
||||
}
|
||||
|
||||
const { draftText, draftBodyRanges } = conversation;
|
||||
const {
|
||||
announcementsOnly,
|
||||
areWeAdmin,
|
||||
draftText,
|
||||
draftBodyRanges,
|
||||
} = conversation;
|
||||
|
||||
const receivedPacks = getReceivedStickerPacks(state);
|
||||
const installedPacks = getInstalledStickerPacks(state);
|
||||
@@ -109,6 +115,10 @@ const mapStateToProps = (state: StateType, props: ExternalProps) => {
|
||||
isMissingMandatoryProfileSharing: isMissingRequiredProfileSharing(
|
||||
conversation
|
||||
),
|
||||
// Groups
|
||||
announcementsOnly,
|
||||
areWeAdmin,
|
||||
groupAdmins: getGroupAdminsSelector(state)(conversation.id),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -93,10 +93,13 @@ const mapStateToProps = (state: StateType, ownProps: OwnProps) => {
|
||||
return {
|
||||
...pick(conversation, [
|
||||
'acceptedMessageRequest',
|
||||
'announcementsOnly',
|
||||
'areWeAdmin',
|
||||
'avatarPath',
|
||||
'canChangeTimer',
|
||||
'color',
|
||||
'expireTimer',
|
||||
'groupVersion',
|
||||
'isArchived',
|
||||
'isMe',
|
||||
'isPinned',
|
||||
@@ -107,10 +110,9 @@ const mapStateToProps = (state: StateType, ownProps: OwnProps) => {
|
||||
'name',
|
||||
'phoneNumber',
|
||||
'profileName',
|
||||
'sharedGroupNames',
|
||||
'title',
|
||||
'type',
|
||||
'groupVersion',
|
||||
'sharedGroupNames',
|
||||
'unblurredAvatarPath',
|
||||
]),
|
||||
conversationTitle: state.conversations.selectedConversationTitle,
|
||||
|
||||
@@ -15,6 +15,7 @@ export type SmartGroupV2PermissionsProps = {
|
||||
conversationId: string;
|
||||
setAccessControlAttributesSetting: (value: number) => void;
|
||||
setAccessControlMembersSetting: (value: number) => void;
|
||||
setAnnouncementsOnly: (value: boolean) => void;
|
||||
};
|
||||
|
||||
const mapStateToProps = (
|
||||
|
||||
Reference in New Issue
Block a user