diff --git a/SignalServiceKit/src/Contacts/Threads/TSGroupThread.h b/SignalServiceKit/src/Contacts/Threads/TSGroupThread.h index c5136e126..8d11b4ab7 100644 --- a/SignalServiceKit/src/Contacts/Threads/TSGroupThread.h +++ b/SignalServiceKit/src/Contacts/Threads/TSGroupThread.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // #import "TSGroupModel.h" @@ -22,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)getOrCreateThreadWithGroupId:(NSData *)groupId transaction:(YapDatabaseReadWriteTransaction *)transaction; ++ (nullable instancetype)threadWithGroupId:(NSData *)groupId; + (nullable instancetype)threadWithGroupId:(NSData *)groupId transaction:(YapDatabaseReadTransaction *)transaction; + (NSString *)threadIdFromGroupId:(NSData *)groupId; diff --git a/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m b/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m index 74c48e2a3..a61f675ac 100644 --- a/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m +++ b/SignalServiceKit/src/Contacts/Threads/TSGroupThread.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // #import "TSGroupThread.h" @@ -58,6 +58,17 @@ NS_ASSUME_NONNULL_BEGIN return self; } ++ (nullable instancetype)threadWithGroupId:(NSData *)groupId; +{ + OWSAssert(groupId.length > 0); + + __block TSGroupThread *thread; + [[self dbReadWriteConnection] readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { + thread = [self threadWithGroupId:groupId transaction:transaction]; + }]; + return thread; +} + + (nullable instancetype)threadWithGroupId:(NSData *)groupId transaction:(YapDatabaseReadTransaction *)transaction { OWSAssert(groupId.length > 0); diff --git a/SignalServiceKit/src/Devices/OWSGroupsOutputStream.m b/SignalServiceKit/src/Devices/OWSGroupsOutputStream.m index cdda93b3c..4c8f5abd6 100644 --- a/SignalServiceKit/src/Devices/OWSGroupsOutputStream.m +++ b/SignalServiceKit/src/Devices/OWSGroupsOutputStream.m @@ -1,9 +1,13 @@ -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// #import "OWSGroupsOutputStream.h" #import "MIMETypeUtil.h" +#import "OWSDisappearingMessagesConfiguration.h" #import "OWSSignalServiceProtos.pb.h" #import "TSGroupModel.h" +#import "TSGroupThread.h" #import NS_ASSUME_NONNULL_BEGIN @@ -33,6 +37,16 @@ NS_ASSUME_NONNULL_BEGIN [self.delegateStream writeRawVarint32:groupDataLength]; [self.delegateStream writeRawData:groupData]; + TSGroupThread *_Nullable groupThread = [TSGroupThread threadWithGroupId:group.groupId]; + if (groupThread) { + OWSDisappearingMessagesConfiguration *_Nullable disappearingMessagesConfiguration = + [OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:groupThread.uniqueId]; + + if (disappearingMessagesConfiguration && disappearingMessagesConfiguration.isEnabled) { + [groupBuilder setExpireTimer:disappearingMessagesConfiguration.durationSeconds]; + } + } + if (avatarPng) { [self.delegateStream writeRawData:avatarPng]; }