From 19a1afaab4b45f294c31c3fee5eabe9cc174bcb4 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 18 Jul 2019 13:37:08 -0300 Subject: [PATCH] Make TSInteraction.thread non-nil. --- .../src/Messages/Interactions/TSInteraction.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m index d77805e215..10ca530bad 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m @@ -181,6 +181,14 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) - (TSThread *)threadWithSneakyTransaction { + if (self.uniqueThreadId == nil) { + // This might be a true for a few legacy interactions enqueued in + // the message sender. The message sender will handle this case. + // Note that this method is not declared as nullable. + OWSFailDebug(@"Missing uniqueThreadId."); + return nil; + } + __block TSThread *thread; [self.databaseStorage readWithBlock:^(SDSAnyReadTransaction *transaction) { thread = [TSThread anyFetchWithUniqueId:self.uniqueThreadId transaction:transaction]; @@ -191,6 +199,14 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) - (TSThread *)threadWithTransaction:(SDSAnyReadTransaction *)transaction { + if (self.uniqueThreadId == nil) { + // This might be a true for a few legacy interactions enqueued in + // the message sender. The message sender will handle this case. + // Note that this method is not declared as nullable. + OWSFailDebug(@"Missing uniqueThreadId."); + return nil; + } + return [TSThread anyFetchWithUniqueId:self.uniqueThreadId transaction:transaction]; }