Remove announcementGroup capability checks
This commit is contained in:
parent
dcf0c5284d
commit
144d594e31
5 changed files with 2 additions and 71 deletions
|
@ -4066,10 +4066,6 @@
|
||||||
"message": "You cannot send messages to that group.",
|
"message": "You cannot send messages to that group.",
|
||||||
"description": "Shown in toast when you attempt to forward a message to an announcement only group"
|
"description": "Shown in toast when you attempt to forward a message to an announcement only group"
|
||||||
},
|
},
|
||||||
"GroupV2--add--missing-capability": {
|
|
||||||
"message": "These people cannot be added to the group until they upgrade Signal.",
|
|
||||||
"description": "Shown in a confirmation dialog when members who cannot view announcement only group cannot be added"
|
|
||||||
},
|
|
||||||
"GroupV2--cannot-start-group-call": {
|
"GroupV2--cannot-start-group-call": {
|
||||||
"message": "Only admins of the group can start a call.",
|
"message": "Only admins of the group can start a call.",
|
||||||
"description": "Shown in toast when a non-admin starts a group call in an announcements only group"
|
"description": "Shown in toast when a non-admin starts a group call in an announcements only group"
|
||||||
|
|
|
@ -8,7 +8,6 @@ import { action } from '@storybook/addon-actions';
|
||||||
import { times } from 'lodash';
|
import { times } from 'lodash';
|
||||||
|
|
||||||
import { setupI18n } from '../../../util/setupI18n';
|
import { setupI18n } from '../../../util/setupI18n';
|
||||||
import { CapabilityError } from '../../../types/errors';
|
|
||||||
import enMessages from '../../../../_locales/en/messages.json';
|
import enMessages from '../../../../_locales/en/messages.json';
|
||||||
import type { Props } from './ConversationDetails';
|
import type { Props } from './ConversationDetails';
|
||||||
import { ConversationDetails } from './ConversationDetails';
|
import { ConversationDetails } from './ConversationDetails';
|
||||||
|
@ -189,16 +188,6 @@ story.add('Group Links On', () => {
|
||||||
return <ConversationDetails {...props} isAdmin />;
|
return <ConversationDetails {...props} isAdmin />;
|
||||||
});
|
});
|
||||||
|
|
||||||
story.add('Group add with missing capabilities', () => (
|
|
||||||
<ConversationDetails
|
|
||||||
{...createProps()}
|
|
||||||
canEditGroupInfo
|
|
||||||
addMembers={async () => {
|
|
||||||
throw new CapabilityError('stories');
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
));
|
|
||||||
|
|
||||||
story.add('1:1', () => (
|
story.add('1:1', () => (
|
||||||
<ConversationDetails {...createProps()} isGroup={false} />
|
<ConversationDetails {...createProps()} isGroup={false} />
|
||||||
));
|
));
|
||||||
|
|
|
@ -16,7 +16,6 @@ import { getMutedUntilText } from '../../../util/getMutedUntilText';
|
||||||
import type { LocalizerType, ThemeType } from '../../../types/Util';
|
import type { LocalizerType, ThemeType } from '../../../types/Util';
|
||||||
import type { MediaItemType } from '../../../types/MediaItem';
|
import type { MediaItemType } from '../../../types/MediaItem';
|
||||||
import type { BadgeType } from '../../../badges/types';
|
import type { BadgeType } from '../../../badges/types';
|
||||||
import { CapabilityError } from '../../../types/errors';
|
|
||||||
import { missingCaseError } from '../../../util/missingCaseError';
|
import { missingCaseError } from '../../../util/missingCaseError';
|
||||||
|
|
||||||
import { DisappearingTimerSelect } from '../../DisappearingTimerSelect';
|
import { DisappearingTimerSelect } from '../../DisappearingTimerSelect';
|
||||||
|
@ -166,8 +165,6 @@ export const ConversationDetails: React.ComponentType<Props> = ({
|
||||||
useState<RequestState>(RequestState.Inactive);
|
useState<RequestState>(RequestState.Inactive);
|
||||||
const [addGroupMembersRequestState, setAddGroupMembersRequestState] =
|
const [addGroupMembersRequestState, setAddGroupMembersRequestState] =
|
||||||
useState<RequestState>(RequestState.Inactive);
|
useState<RequestState>(RequestState.Inactive);
|
||||||
const [membersMissingCapability, setMembersMissingCapability] =
|
|
||||||
useState(false);
|
|
||||||
|
|
||||||
if (conversation === undefined) {
|
if (conversation === undefined) {
|
||||||
throw new Error('ConversationDetails rendered without a conversation');
|
throw new Error('ConversationDetails rendered without a conversation');
|
||||||
|
@ -260,12 +257,7 @@ export const ConversationDetails: React.ComponentType<Props> = ({
|
||||||
setModalState(ModalState.NothingOpen);
|
setModalState(ModalState.NothingOpen);
|
||||||
setAddGroupMembersRequestState(RequestState.Inactive);
|
setAddGroupMembersRequestState(RequestState.Inactive);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof CapabilityError) {
|
setAddGroupMembersRequestState(RequestState.InactiveWithError);
|
||||||
setMembersMissingCapability(true);
|
|
||||||
setAddGroupMembersRequestState(RequestState.InactiveWithError);
|
|
||||||
} else {
|
|
||||||
setAddGroupMembersRequestState(RequestState.InactiveWithError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
|
@ -317,16 +309,6 @@ export const ConversationDetails: React.ComponentType<Props> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="conversation-details-panel">
|
<div className="conversation-details-panel">
|
||||||
{membersMissingCapability && (
|
|
||||||
<ConfirmationDialog
|
|
||||||
cancelText={i18n('Confirmation--confirm')}
|
|
||||||
i18n={i18n}
|
|
||||||
onClose={() => setMembersMissingCapability(false)}
|
|
||||||
>
|
|
||||||
{i18n('GroupV2--add--missing-capability')}
|
|
||||||
</ConfirmationDialog>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<ConversationDetailsHeader
|
<ConversationDetailsHeader
|
||||||
areWeASubscriber={areWeASubscriber}
|
areWeASubscriber={areWeASubscriber}
|
||||||
badges={badges}
|
badges={badges}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import { CallMode } from '../types/Calling';
|
||||||
import * as EmbeddedContact from '../types/EmbeddedContact';
|
import * as EmbeddedContact from '../types/EmbeddedContact';
|
||||||
import * as Conversation from '../types/Conversation';
|
import * as Conversation from '../types/Conversation';
|
||||||
import * as Stickers from '../types/Stickers';
|
import * as Stickers from '../types/Stickers';
|
||||||
import { CapabilityError } from '../types/errors';
|
|
||||||
import type {
|
import type {
|
||||||
ContactWithHydratedAvatar,
|
ContactWithHydratedAvatar,
|
||||||
GroupV1InfoType,
|
GroupV1InfoType,
|
||||||
|
@ -616,14 +615,6 @@ export class ConversationModel extends window.Backbone
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
this.get('announcementsOnly') &&
|
|
||||||
!toRequest.get('capabilities')?.announcementGroup
|
|
||||||
) {
|
|
||||||
log.warn(`addPendingApprovalRequest/${idLog}: member needs to upgrade.`);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need the user's profileKeyCredential, which requires a roundtrip with the
|
// We need the user's profileKeyCredential, which requires a roundtrip with the
|
||||||
// server, and most definitely their profileKey. A getProfiles() call will
|
// server, and most definitely their profileKey. A getProfiles() call will
|
||||||
// ensure that we have as much as we can get with the data we have.
|
// ensure that we have as much as we can get with the data we have.
|
||||||
|
@ -668,16 +659,6 @@ export class ConversationModel extends window.Backbone
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
this.get('announcementsOnly') &&
|
|
||||||
!toRequest.get('capabilities')?.announcementGroup
|
|
||||||
) {
|
|
||||||
log.warn(
|
|
||||||
`addMember/${idLog}: ${toRequest.idForLogging()} needs to upgrade.`
|
|
||||||
);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const uuid = toRequest.get('uuid');
|
const uuid = toRequest.get('uuid');
|
||||||
if (!uuid) {
|
if (!uuid) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@ -2301,18 +2282,6 @@ export class ConversationModel extends window.Backbone
|
||||||
}
|
}
|
||||||
|
|
||||||
async addMembersV2(conversationIds: ReadonlyArray<string>): Promise<void> {
|
async addMembersV2(conversationIds: ReadonlyArray<string>): Promise<void> {
|
||||||
if (this.get('announcementsOnly')) {
|
|
||||||
const isEveryMemberCapable = conversationIds.every(conversationId => {
|
|
||||||
const model = window.ConversationController.get(conversationId);
|
|
||||||
return Boolean(model?.get('capabilities')?.announcementGroup);
|
|
||||||
});
|
|
||||||
if (!isEveryMemberCapable) {
|
|
||||||
throw new CapabilityError(
|
|
||||||
'addMembersV2: some or all members need to upgrade.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.modifyGroupV2({
|
await this.modifyGroupV2({
|
||||||
name: 'addMembersV2',
|
name: 'addMembersV2',
|
||||||
createGroupChange: () =>
|
createGroupChange: () =>
|
||||||
|
@ -3603,10 +3572,7 @@ export class ConversationModel extends window.Backbone
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const members = getConversationMembers(this.attributes);
|
return true;
|
||||||
return members.every(conversationAttrs =>
|
|
||||||
Boolean(conversationAttrs.capabilities?.announcementGroup)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getMemberIds(): Array<string> {
|
getMemberIds(): Array<string> {
|
||||||
|
|
|
@ -17,6 +17,4 @@ export function toLogFormat(error: unknown): string {
|
||||||
return String(error);
|
return String(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CapabilityError extends Error {}
|
|
||||||
|
|
||||||
export class ProfileDecryptError extends Error {}
|
export class ProfileDecryptError extends Error {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue