Merge pull request #373 from msgmaxim/timestamp-error

Show correct error on incorrect timestamp
pull/378/head
Beaudan Campbell-Brown 6 years ago committed by GitHub
commit 0e9372d3d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -240,6 +240,9 @@ class LokiMessageAPI {
throw e; throw e;
} else if (e instanceof textsecure.NotFoundError) { } else if (e instanceof textsecure.NotFoundError) {
// TODO: Handle resolution error // TODO: Handle resolution error
} else if (e instanceof textsecure.TimestampError) {
log.warn('Timestamp is invalid');
throw e;
} else if (e instanceof textsecure.HTTPError) { } else if (e instanceof textsecure.HTTPError) {
// TODO: Handle working connection but error response // TODO: Handle working connection but error response
const body = await e.response.text(); const body = await e.response.text();

@ -77,6 +77,12 @@ const fetch = async (url, options = {}) => {
throw new textsecure.WrongDifficultyError(difficulty); throw new textsecure.WrongDifficultyError(difficulty);
} }
if (response.status === 406) {
throw new textsecure.TimestampError(
'Invalid Timestamp (check your clock)'
);
}
if (!response.ok) { if (!response.ok) {
throw new textsecure.HTTPError('Loki_rpc error', response); throw new textsecure.HTTPError('Loki_rpc error', response);
} }

@ -263,6 +263,16 @@
} }
} }
function TimestampError(message) {
this.name = 'TimeStampError';
ReplayableError.call(this, {
name: 'TimestampError',
message,
});
}
inherit(ReplayableError, TimestampError);
window.textsecure.UnregisteredUserError = UnregisteredUserError; window.textsecure.UnregisteredUserError = UnregisteredUserError;
window.textsecure.SendMessageNetworkError = SendMessageNetworkError; window.textsecure.SendMessageNetworkError = SendMessageNetworkError;
window.textsecure.IncomingIdentityKeyError = IncomingIdentityKeyError; window.textsecure.IncomingIdentityKeyError = IncomingIdentityKeyError;
@ -281,4 +291,5 @@
window.textsecure.NotFoundError = NotFoundError; window.textsecure.NotFoundError = NotFoundError;
window.textsecure.WrongSwarmError = WrongSwarmError; window.textsecure.WrongSwarmError = WrongSwarmError;
window.textsecure.WrongDifficultyError = WrongDifficultyError; window.textsecure.WrongDifficultyError = WrongDifficultyError;
window.textsecure.TimestampError = TimestampError;
})(); })();

Loading…
Cancel
Save