From f89c4387eb8641fb8d406d03122e9c8eeac89b0e Mon Sep 17 00:00:00 2001
From: aguestuser <aguestuser@riseup.net>
Date: Mon, 21 Sep 2020 13:46:00 -0400
Subject: [PATCH] [hf] safely destructure identity failure errors

* BUG SYMPTOM: some send response handlers error when they try to
  destructure a null `data` field
* CAUSE: the `{identityFailure}` destructuring assignment unsafely
  assumes that all `send_message` values will have a `data` field on
  which we can call `data[0]`
* FIX: don't assume anything about the shape of the `data`
  field. extract `identityFailure` from it (if it is there) with a
  lodash `get` call to the full path to the field we are trying
  to (conditionally) extract
---
 app/signal/callbacks.js | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/app/signal/callbacks.js b/app/signal/callbacks.js
index 1777f047..5909cf64 100644
--- a/app/signal/callbacks.js
+++ b/app/signal/callbacks.js
@@ -102,8 +102,7 @@ const handle = message => {
 const _handleSendResponse = ({ message, state }) => {
   delete registry[`${messageTypes.SEND}-${message.id}`]
 
-  const { identityFailure } = get(message, 'data[0]')
-  if (identityFailure) {
+  if (get(message, 'data.0.identityFailure')) {
     return _updateFingerprint(message, state)
   }
 
-- 
GitLab