Skip to content

Commit

Permalink
handle errors for changing connection status
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Gira committed Sep 11, 2023
1 parent b82527c commit 6cda396
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
9 changes: 6 additions & 3 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",
"modalUserCannotCancelConnectionMessage": "Connection request could not be cancelled",
"modalUserCannotConnectHeadline": "Connecting not possible",
"modalUserCannotConnectMessage": "Connection request could not be sent",
"modalUserCannotConnectLegalHoldMessage": "You cannot connect to this user due to legal hold. [link]Learn more[/link]",
"modalUserCannotConnectNotFederatingMessage": "You can’t send a connection request as your backend doesn’t federate with the one of {{username}}.",
"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
39 changes: 36 additions & 3 deletions src/script/connection/ConnectionRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class ConnectionRepository {
);
PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, {
text: {
htmlMessage: t('modalUserCannotConnectLegalHoldMessage', {}, replaceLinkLegalHold),
htmlMessage: t('modalUserCannotSendConnectionLegalHoldMessage', {}, replaceLinkLegalHold),
title: t('modalUserCannotConnectHeadline'),
},
});
Expand All @@ -211,7 +211,7 @@ export class ConnectionRepository {
case BackendErrorLabel.FEDERATION_NOT_ALLOWED: {
PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, {
text: {
htmlMessage: t('modalUserCannotConnectNotFederatingMessage', userEntity.name()),
htmlMessage: t('modalUserCannotSendConnectionNotFederatingMessage', userEntity.name()),
title: t('modalUserCannotConnectHeadline'),
},
});
Expand All @@ -222,7 +222,7 @@ export class ConnectionRepository {
this.logger.error(`Failed to send connection request to user '${userEntity.id}': ${error.message}`, error);
PrimaryModal.show(PrimaryModal.type.ACKNOWLEDGE, {
text: {
htmlMessage: t('modalUserCannotConnectMessage', userEntity.name()),
htmlMessage: t('modalUserCannotSendConnectionMessage'),
title: t('modalUserCannotConnectHeadline'),
},
});
Expand Down Expand Up @@ -318,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 6cda396

Please sign in to comment.