Unify introduction response methods and handle ProtocolStateException

It is possible that a remote DECLINE message arrives short before the
user responds to the introduction.
This will cause a ProtocolStateException which (for now) is just caught
and a generic (existing) error message will be shown.
This commit is contained in:
Torsten Grote
2018-04-26 18:18:31 -03:00
parent f8f98ed95d
commit 337f7e7b8f
4 changed files with 22 additions and 46 deletions

View File

@@ -865,7 +865,8 @@ introductionOnboardingSeen();
"Unknown Request Type");
}
loadMessages();
} catch (DbException | FormatException e) {
} catch (DbException e) {
// TODO use more generic error message
introductionResponseError();
if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
@@ -898,11 +899,14 @@ introductionOnboardingSeen();
@DatabaseExecutor
private void respondToIntroductionRequest(SessionId sessionId,
boolean accept, long time) throws DbException, FormatException {
if (accept) {
introductionManager.acceptIntroduction(contactId, sessionId, time);
} else {
introductionManager.declineIntroduction(contactId, sessionId, time);
boolean accept, long time) throws DbException {
try {
introductionManager
.respondToIntroduction(contactId, sessionId, time, accept);
} catch (ProtocolStateException e) {
if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
introductionResponseError();
}
}