Skip to content

Commit

Permalink
feat: handle connection requests errors (WPB-4418) (#15783)
Browse files Browse the repository at this point in the history
* feat: handle connection requests errors (WPB-4418)

* handle errors for changing connection status
  • Loading branch information
V-Gira committed Sep 11, 2023
1 parent 5b31ae9 commit 274f333
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -959,11 +959,14 @@
"modalUserBlockHeadline": "Block {{user}}?",
"modalUserBlockMessage": "{{user}} won’t be able to contact you or add you to group conversations.",
"modalUserBlockedForLegalHold": "This user is blocked due to legal hold. [link]Learn more[/link]",
"modalUserCannotAcceptConnectionMessage": "Connection request could not be accepted",
"modalUserCannotBeAddedHeadline": "Guests cannot be added",
"modalUserCannotConnectLegalHoldHeadline": "Cannot connect to this user",
"modalUserCannotConnectLegalHoldMessage": "You cannot connect to this user due to legal hold. [link]Learn more[/link]",
"modalUserCannotConnectNotFederatingHeadline": "Connecting not possible",
"modalUserCannotConnectNotFederatingMessage": "You can’t send a connection request as your backend doesn’t federate with the one of {{username}}.",
"modalUserCannotCancelConnectionMessage": "Connection request could not be cancelled",
"modalUserCannotConnectHeadline": "Connecting not possible",
"modalUserCannotIgnoreConnectionMessage": "Connection request could not be ignored",
"modalUserCannotSendConnectionMessage": "Connection request could not be sent",
"modalUserCannotSendConnectionLegalHoldMessage": "You cannot connect to this user due to legal hold. [link]Learn more[/link]",
"modalUserCannotSendConnectionNotFederatingMessage": "You can’t send a connection request as your backend doesn’t federate with the one of {{username}}.",
"modalUserLearnMore": "Learn more",
"modalUserUnblockAction": "Unblock",
"modalUserUnblockHeadline": "Unblock?",
Expand Down
48 changes: 44 additions & 4 deletions src/script/connection/ConnectionRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ export class ConnectionRepository {
);
PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, {
text: {
htmlMessage: t('modalUserCannotConnectLegalHoldMessage', {}, replaceLinkLegalHold),
title: t('modalUserCannotConnectLegalHoldHeadline'),
htmlMessage: t('modalUserCannotSendConnectionLegalHoldMessage', {}, replaceLinkLegalHold),
title: t('modalUserCannotConnectHeadline'),
},
});
break;
Expand All @@ -211,15 +211,22 @@ export class ConnectionRepository {
case BackendErrorLabel.FEDERATION_NOT_ALLOWED: {
PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, {
text: {
htmlMessage: t('modalUserCannotConnectNotFederatingMessage', userEntity.name()),
title: t('modalUserCannotConnectNotFederatingHeadline'),
htmlMessage: t('modalUserCannotSendConnectionNotFederatingMessage', userEntity.name()),
title: t('modalUserCannotConnectHeadline'),
},
});
break;
}

default: {
this.logger.error(`Failed to send connection request to user '${userEntity.id}': ${error.message}`, error);
PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, {
text: {
htmlMessage: t('modalUserCannotSendConnectionMessage'),
title: t('modalUserCannotConnectHeadline'),
},
});
break;
}
}
return false;
Expand Down Expand Up @@ -311,6 +318,39 @@ export class ConnectionRepository {
} catch (error) {
const logMessage = `Connection change from '${currentStatus}' to '${newStatus}' failed`;
this.logger.error(`${logMessage} for '${userEntity.id}' failed: ${error.message}`, error);
switch (newStatus) {
case ConnectionStatus.ACCEPTED: {
PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, {
text: {
htmlMessage: t('modalUserCannotAcceptConnectionMessage'),
title: t('modalUserCannotConnectHeadline'),
},
});
}
case ConnectionStatus.CANCELLED: {
PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, {
text: {
htmlMessage: t('modalUserCannotCancelConnectionMessage'),
title: t('modalUserCannotConnectHeadline'),
},
});
}
case ConnectionStatus.IGNORED: {
PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, {
text: {
htmlMessage: t('modalUserCannotIgnoreConnectionMessage'),
title: t('modalUserCannotConnectHeadline'),
},
});
}
default: {
PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, {
text: {
title: t('modalUserCannotConnectHeadline'),
},
});
}
}
}
}

Expand Down

0 comments on commit 274f333

Please sign in to comment.