Skip to content

Commit

Permalink
Merge pull request #1244 from Bilb/fix-sending-errors-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilb committed Jul 14, 2020
2 parents 1a27fc4 + 48e4862 commit 4e56ad2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
14 changes: 11 additions & 3 deletions js/models/messages.js
Expand Up @@ -1087,17 +1087,25 @@
}

const { body, attachments, preview, quote } = await this.uploadData();
const ourNumber = window.storage.get('primaryDevicePubKey');
const ourConversation = window.ConversationController.get(ourNumber);

const chatMessage = new libsession.Messages.Outgoing.ChatMessage({
const chatParams = {
identifier: this.id,
body,
timestamp: this.get('sent_at'),
expireTimer: this.get('expireTimer'),
attachments,
preview,
quote,
lokiProfile: this.conversation.getOurProfile(),
});
};
if (ourConversation) {
chatParams.lokiProfile = ourConversation.getOurProfile();
}

const chatMessage = new libsession.Messages.Outgoing.ChatMessage(
chatParams
);

// Special-case the self-send case - we send only a sync message
if (recipients.length === 1) {
Expand Down
3 changes: 2 additions & 1 deletion js/modules/loki_message_api.js
Expand Up @@ -96,8 +96,9 @@ class LokiMessageAPI {
// eslint-disable-next-line more/no-then
snode = await primitives.firstTrue(promises);
} catch (e) {
const snodeStr = snode ? `${snode.ip}:${snode.port}` : 'null';
log.warn(
`loki_message:::sendMessage - ${e.code} ${e.message} to ${pubKey} via ${snode.ip}:${snode.port}`
`loki_message:::sendMessage - ${e.code} ${e.message} to ${pubKey} via snode:${snodeStr}`
);
if (e instanceof textsecure.WrongDifficultyError) {
// Force nonce recalculation
Expand Down
2 changes: 0 additions & 2 deletions ts/session/snode_api/serviceNodeAPI.ts
Expand Up @@ -298,8 +298,6 @@ export async function storeOnNode(
return false;
}

const res = snodeRes as any;

const json = JSON.parse(snodeRes.body);
// Make sure we aren't doing too much PoW
const currentDifficulty = window.storage.get('PoWDifficulty', null);
Expand Down

0 comments on commit 4e56ad2

Please sign in to comment.