diff --git a/src/i18n/en-US.json b/src/i18n/en-US.json index 2ebd5eabc5c..bb419e92973 100644 --- a/src/i18n/en-US.json +++ b/src/i18n/en-US.json @@ -496,6 +496,8 @@ "conversationNewConversation": "Communication in Wire is always end-to-end encrypted. Everything you send and receive in this conversation is only accessible to you and your contact.", "conversationNotClassified": "Security level: Unclassified", "conversationNotFoundMessage": "You may not have permission with this account or it no longer exists.", + "conversationWithBlockedUserMessage": "The link to this group conversation is no longer valid or leads to a conversation with someone you blocked.", + "conversationWithBlockedUserTitle": "Conversation not reachable", "conversationNotFoundTitle": "{{brandName}} can’t open this conversation.", "conversationParticipantsSearchPlaceholder": "Search by name", "conversationParticipantsTitle": "People", diff --git a/src/script/error/ConversationError.ts b/src/script/error/ConversationError.ts index 92495ed8a4e..a14daf5b212 100644 --- a/src/script/error/ConversationError.ts +++ b/src/script/error/ConversationError.ts @@ -21,6 +21,7 @@ import {BaseError, BASE_ERROR_TYPE} from './BaseError'; enum CONVERSATION_ERROR_TYPE { CONVERSATION_NOT_FOUND = 'CONVERSATION_NOT_FOUND', + CONVERSATION_WITH_BLOCKED_USER = 'CONVERSATION_WITH_BLOCKED_USER', INVALID_PARAMETER = 'INVALID_PARAMETER', LEGAL_HOLD_CONVERSATION_CANCELLATION = 'LEGAL_HOLD_CONVERSATION_CANCELLATION', MESSAGE_NOT_FOUND = 'MESSAGE_NOT_FOUND', @@ -46,6 +47,7 @@ export class ConversationError extends BaseError { static get MESSAGE(): Record { return { CONVERSATION_NOT_FOUND: 'Conversation not found', + CONVERSATION_WITH_BLOCKED_USER: 'Conversation not reachable', INVALID_PARAMETER: 'Invalid parameter passed', LEGAL_HOLD_CONVERSATION_CANCELLATION: 'Sending to legal hold conversation was canceled by user', MESSAGE_NOT_FOUND: 'Message not found in conversation', @@ -64,6 +66,7 @@ export class ConversationError extends BaseError { static get TYPE(): Record { return { CONVERSATION_NOT_FOUND: CONVERSATION_ERROR_TYPE.CONVERSATION_NOT_FOUND, + CONVERSATION_WITH_BLOCKED_USER: CONVERSATION_ERROR_TYPE.CONVERSATION_WITH_BLOCKED_USER, INVALID_PARAMETER: CONVERSATION_ERROR_TYPE.INVALID_PARAMETER, LEGAL_HOLD_CONVERSATION_CANCELLATION: CONVERSATION_ERROR_TYPE.LEGAL_HOLD_CONVERSATION_CANCELLATION, MESSAGE_NOT_FOUND: CONVERSATION_ERROR_TYPE.MESSAGE_NOT_FOUND, diff --git a/src/script/view_model/ContentViewModel.ts b/src/script/view_model/ContentViewModel.ts index 876bebbbf80..0a9da2b5fa7 100644 --- a/src/script/view_model/ContentViewModel.ts +++ b/src/script/view_model/ContentViewModel.ts @@ -219,10 +219,27 @@ export class ContentViewModel { ); } + private showConversationWithBlockedUserErrorModal(): void { + PrimaryModal.show( + PrimaryModal.type.ACKNOWLEDGE, + { + text: { + message: t('conversationWithBlockedUserMessage'), + title: t('conversationWithBlockedUserTitle'), + }, + }, + undefined, + ); + } + private isConversationNotFoundError(error: any): boolean { return error.type === ConversationError.TYPE.CONVERSATION_NOT_FOUND; } + private isConversationWithBlockedUserError(error: any): boolean { + return error.type === ConversationError.TYPE.CONVERSATION_WITH_BLOCKED_USER; + } + /** * Opens the specified conversation. * @@ -249,6 +266,7 @@ export class ContentViewModel { try { const conversationEntity = await this.getConversationEntity(conversation, domain); + const isConnectionBlocked = conversationEntity?.connection()?.isBlocked(); if (!conversationEntity) { this.closeRightSidebar(); @@ -258,6 +276,14 @@ export class ContentViewModel { ); } + if (isConnectionBlocked) { + this.closeRightSidebar(); + throw new ConversationError( + ConversationError.TYPE.CONVERSATION_WITH_BLOCKED_USER, + ConversationError.MESSAGE.CONVERSATION_WITH_BLOCKED_USER, + ); + } + const isActiveConversation = this.conversationState.isActiveConversation(conversationEntity); if (!isActiveConversation) { @@ -276,10 +302,14 @@ export class ContentViewModel { this.showAndNavigate(conversationEntity, openNotificationSettings); } catch (error: any) { if (this.isConversationNotFoundError(error)) { - this.showConversationNotFoundErrorModal(); - } else { - throw error; + return this.showConversationNotFoundErrorModal(); } + + if (this.isConversationWithBlockedUserError(error)) { + return this.showConversationWithBlockedUserErrorModal(); + } + + throw error; } };