fix up handling of clock out of sync
This commit is contained in:
parent
e85f69a144
commit
504a9afc0a
|
@ -846,7 +846,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
|
|||
const chatParams = {
|
||||
identifier: this.id,
|
||||
body,
|
||||
timestamp: this.get('sent_at') || Date.now(),
|
||||
timestamp: Date.now(), // force a new timestamp to handle user fixed his clock
|
||||
expireTimer: this.get('expireTimer'),
|
||||
attachments,
|
||||
preview,
|
||||
|
|
|
@ -70,11 +70,11 @@ export async function sendMessage(
|
|||
);
|
||||
throw e;
|
||||
}
|
||||
if (!snode) {
|
||||
if (!usedNodes || usedNodes.length === 0) {
|
||||
throw new window.textsecure.EmptySwarmError(pubKey, 'Ran out of swarm nodes to query');
|
||||
} else {
|
||||
window?.log?.info(
|
||||
`loki_message:::sendMessage - Successfully stored message to ${pubKey} via ${snode.ip}:${snode.port}`
|
||||
);
|
||||
}
|
||||
|
||||
window?.log?.info(
|
||||
`loki_message:::sendMessage - Successfully stored message to ${pubKey} via ${snode.ip}:${snode.port}`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -496,8 +496,8 @@ export async function storeOnNode(targetNode: Snode, params: SendParams): Promis
|
|||
e,
|
||||
`destination ${targetNode.ip}:${targetNode.port}`
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** */
|
||||
|
|
|
@ -38,6 +38,9 @@ export interface SnodeResponse {
|
|||
|
||||
export const NEXT_NODE_NOT_FOUND_PREFIX = 'Next node not found: ';
|
||||
|
||||
export const CLOCK_OUT_OF_SYNC_MESSAGE_ERROR =
|
||||
'You clock is out of sync with the network. Check your clock';
|
||||
|
||||
// Returns the actual ciphertext, symmetric key that will be used
|
||||
// for decryption, and an ephemeral_key to send to the next hop
|
||||
async function encryptForPubKey(pubKeyX25519hex: string, reqObj: any): Promise<DestinationContext> {
|
||||
|
@ -196,9 +199,8 @@ async function buildOnionGuardNodePayload(
|
|||
function process406Error(statusCode: number) {
|
||||
if (statusCode === 406) {
|
||||
// clock out of sync
|
||||
console.warn('clock out of sync todo');
|
||||
// this will make the pRetry stop
|
||||
throw new pRetry.AbortError('You clock is out of sync with the network. Check your clock.');
|
||||
throw new pRetry.AbortError(CLOCK_OUT_OF_SYNC_MESSAGE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -881,6 +883,10 @@ export async function lokiOnionFetch(
|
|||
// better handle the no connection state
|
||||
throw new Error(ERROR_CODE_NO_CONNECT);
|
||||
}
|
||||
if (e?.message === CLOCK_OUT_OF_SYNC_MESSAGE_ERROR) {
|
||||
window?.log?.warn('Its an clock out of sync error ');
|
||||
throw new pRetry.AbortError(CLOCK_OUT_OF_SYNC_MESSAGE_ERROR);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue