@ -843,7 +843,7 @@ extension MessageReceiver {
public static func handleMessageRequestResponse ( _ message : MessageRequestResponse , using transaction : Any ) {
let userPublicKey = getUserHexEncodedPublicKey ( )
var blindedContactIds: [ String ] = [ ]
var hadBlindedContact: Bool = false
var blindedThreadIds : [ String ] = [ ]
// I g n o r e m e s s a g e s w h i c h w e r e s e n t f r o m t h e c u r r e n t u s e r
@ -882,11 +882,16 @@ extension MessageReceiver {
let mapping : BlindedIdMapping = BlindedIdMapping ( blindedId : blindedId , sessionId : senderId , serverPublicKey : serverPublicKey )
Storage . shared . cacheBlindedIdMapping ( mapping , using : transaction )
// A d d t h e ` b l i n d e d I d ` t o a n a r r a y s o w e c a n r e m o v e t h e m a t t h e e n d o f p r o c e s s i n g
blindedContactIds . append ( blindedId )
// F l a g t h a t w e h a d a b l i n d e d c o n t a c t a n d a d d t h e ` b l i n d e d T h r e a d I d ` t o a n a r r a y s o w e c a n r e m o v e
// t h e m a t t h e e n d o f p r o c e s s i n g
hadBlindedContact = true
blindedThreadIds . append ( blindedThreadId )
// L o o p t h r o u g h a l l o f t h e i n t e r a c t i o n s a n d a d d t h e m t o a l i s t t o b e m o v e d t o t h e n e w t h r e a d
// N o t e : P e n d i n g ` M e s s a g e S e n d J o b s ` _ s h o u l d n ' t _ b e a n i s s u e a s e v e n i f t h e y a r e s e n t a f t e r t h e
// u n - b l i n d i n g o f a t h r e a d , t h e l o g i c w h e n h a n d l i n g t h e s e n t m e s s a g e s s h o u l d a u t o m a t i c a l l y
// a s s i g n t h e m t o t h e c o r r e c t t h r e a d
// TODO: V a l i d a t e t h e a b o v e n o t e o n c e ` / o u t b o x ` h a s b e e n i m p l e m e n t e d
view . enumerateRows ( inGroup : blindedThreadId ) { _ , _ , object , _ , _ , _ in
guard let interaction : TSInteraction = object as ? TSInteraction else {
return
@ -896,9 +901,6 @@ extension MessageReceiver {
}
threadsToDelete . append ( blindedThread )
// TODO: P e n d i n g j o b s ? ? ?
// S t o r a g e . s h a r e d . g e t A l l P e n d i n g J o b s ( o f : < # T # # J o b . T y p e # > )
}
// S o r t t h e i n t e r a c t i o n s b y t h e i r ` s o r t I d ` ( w h i c h l o o k s t o b e a g l o b a l s o r t i d f o r a l l i n t e r a c t i o n s ) j u s t i n c a s e
@ -916,7 +918,6 @@ extension MessageReceiver {
// D e l e t e t h e o l d t h r e a d s
for thread in threadsToDelete {
// TODO: T h i s i s n ' t u p d a t i n g t h e H o m e V C . . . R a c e c o n d i t i o n ? ? ? ( S e e m s t o n o t h a p p e n w h e n s t e p p i n g t h r o u g h w i t h b r e a k p o i n t s )
thread . removeAllThreadInteractions ( with : transaction )
thread . remove ( with : transaction )
}
@ -926,19 +927,13 @@ extension MessageReceiver {
updateContactApprovalStatusIfNeeded (
senderSessionId : senderId ,
threadId : nil ,
forceConfigSync : blindedContactIds . isEmpty , // S y n c h e r e i f t h e r e a r e n o b l i n d e d c o n t a c t s
forceConfigSync : ! hadBlindedContact , // S y n c h e r e i f t h e r e we r e n o b l i n d e d c o n t a c t s
using : transaction
)
// I f t h e r e w e r e b l i n d e d c o n t a c t s t h e n w e s h o u l d r e m o v e t h e m
if ! blindedContactIds . isEmpty {
// D e l e t e a l l o f t h e p r o c e s s e d b l i n d e d c o n t a c t s ( s h o u l d n ' t n e e d t h e m a n y m o r e a n d d o n ' t w a n t t h e m t a k i n g u p
// s p a c e i n t h e c o n f i g m e s s a g e )
for blindedId in blindedContactIds {
// TODO: O W S B l o c k i n g M a n a g e r . . . ? ? ?
}
// W e s h o u l d a s s u m e t h e ' s e n d e r ' i s a n e w l y c r e a t e d c o n t a c t a n d h e n c e n e e d t o u p d a t e i t ' s ` i s A p p r o v e d ` s t a t e
// I f t h e r e w e r e b l i n d e d c o n t a c t s t h e n w e n e e d t o a s s u m e t h a t t h e ' s e n d e r ' i s a n e w l y c r e a t e c o n t a c t a n d h e n c e
// n e e d t o u p d a t e i t ' s ` i s A p p r o v e d ` s t a t e
if hadBlindedContact {
updateContactApprovalStatusIfNeeded (
senderSessionId : userPublicKey ,
threadId : unblindedThreadId ,