Fix incorrect timer update copy in closed groups
This commit is contained in:
parent
4ee5c66653
commit
4e590da262
|
@ -272,8 +272,6 @@ typedef void (^SystemMessageActionBlock)(void);
|
||||||
case TSInfoMessageAddGroupToProfileWhitelistOffer:
|
case TSInfoMessageAddGroupToProfileWhitelistOffer:
|
||||||
case TSInfoMessageTypeGroupUpdate:
|
case TSInfoMessageTypeGroupUpdate:
|
||||||
case TSInfoMessageTypeGroupQuit:
|
case TSInfoMessageTypeGroupQuit:
|
||||||
case TSInfoMessageTypeLokiSessionResetInProgress:
|
|
||||||
case TSInfoMessageTypeLokiSessionResetDone:
|
|
||||||
return nil;
|
return nil;
|
||||||
case TSInfoMessageTypeDisappearingMessagesUpdate: {
|
case TSInfoMessageTypeDisappearingMessagesUpdate: {
|
||||||
BOOL areDisappearingMessagesEnabled = YES;
|
BOOL areDisappearingMessagesEnabled = YES;
|
||||||
|
@ -426,8 +424,6 @@ typedef void (^SystemMessageActionBlock)(void);
|
||||||
switch (message.messageType) {
|
switch (message.messageType) {
|
||||||
case TSInfoMessageUserNotRegistered:
|
case TSInfoMessageUserNotRegistered:
|
||||||
case TSInfoMessageTypeSessionDidEnd:
|
case TSInfoMessageTypeSessionDidEnd:
|
||||||
case TSInfoMessageTypeLokiSessionResetInProgress:
|
|
||||||
case TSInfoMessageTypeLokiSessionResetDone:
|
|
||||||
return nil;
|
return nil;
|
||||||
case TSInfoMessageTypeUnsupportedMessage:
|
case TSInfoMessageTypeUnsupportedMessage:
|
||||||
// Unused.
|
// Unused.
|
||||||
|
|
|
@ -19,9 +19,7 @@ typedef NS_ENUM(NSInteger, TSInfoMessageType) {
|
||||||
TSInfoMessageTypeDisappearingMessagesUpdate,
|
TSInfoMessageTypeDisappearingMessagesUpdate,
|
||||||
TSInfoMessageAddToContactsOffer,
|
TSInfoMessageAddToContactsOffer,
|
||||||
TSInfoMessageAddUserToProfileWhitelistOffer,
|
TSInfoMessageAddUserToProfileWhitelistOffer,
|
||||||
TSInfoMessageAddGroupToProfileWhitelistOffer,
|
TSInfoMessageAddGroupToProfileWhitelistOffer
|
||||||
TSInfoMessageTypeLokiSessionResetInProgress,
|
|
||||||
TSInfoMessageTypeLokiSessionResetDone,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
+ (instancetype)userNotRegisteredMessageInThread:(TSThread *)thread recipientId:(NSString *)recipientId;
|
+ (instancetype)userNotRegisteredMessageInThread:(TSThread *)thread recipientId:(NSString *)recipientId;
|
||||||
|
|
|
@ -113,10 +113,6 @@ NSUInteger TSInfoMessageSchemaVersion = 1;
|
||||||
- (NSString *)previewTextWithTransaction:(YapDatabaseReadTransaction *)transaction
|
- (NSString *)previewTextWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||||
{
|
{
|
||||||
switch (_messageType) {
|
switch (_messageType) {
|
||||||
case TSInfoMessageTypeLokiSessionResetInProgress:
|
|
||||||
return NSLocalizedString(@"Secure session reset in progress", nil);
|
|
||||||
case TSInfoMessageTypeLokiSessionResetDone:
|
|
||||||
return NSLocalizedString(@"Secure session reset done", nil);
|
|
||||||
case TSInfoMessageTypeSessionDidEnd:
|
case TSInfoMessageTypeSessionDidEnd:
|
||||||
return NSLocalizedString(@"SECURE_SESSION_RESET", nil);
|
return NSLocalizedString(@"SECURE_SESSION_RESET", nil);
|
||||||
case TSInfoMessageTypeUnsupportedMessage:
|
case TSInfoMessageTypeUnsupportedMessage:
|
||||||
|
|
|
@ -104,13 +104,11 @@ extension MessageReceiver {
|
||||||
|
|
||||||
public static func setExpirationTimer(to duration: UInt32, for senderPublicKey: String, groupPublicKey: String?, using transaction: Any) {
|
public static func setExpirationTimer(to duration: UInt32, for senderPublicKey: String, groupPublicKey: String?, using transaction: Any) {
|
||||||
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
||||||
var isGroup = false
|
|
||||||
var threadOrNil: TSThread?
|
var threadOrNil: TSThread?
|
||||||
if let groupPublicKey = groupPublicKey {
|
if let groupPublicKey = groupPublicKey {
|
||||||
guard Storage.shared.isClosedGroup(groupPublicKey) else { return }
|
guard Storage.shared.isClosedGroup(groupPublicKey) else { return }
|
||||||
let groupID = LKGroupUtilities.getEncodedClosedGroupIDAsData(groupPublicKey)
|
let groupID = LKGroupUtilities.getEncodedClosedGroupIDAsData(groupPublicKey)
|
||||||
threadOrNil = TSGroupThread.fetch(uniqueId: TSGroupThread.threadId(fromGroupId: groupID), transaction: transaction)
|
threadOrNil = TSGroupThread.fetch(uniqueId: TSGroupThread.threadId(fromGroupId: groupID), transaction: transaction)
|
||||||
isGroup = true
|
|
||||||
} else {
|
} else {
|
||||||
threadOrNil = TSContactThread.getWithContactId(senderPublicKey, transaction: transaction)
|
threadOrNil = TSContactThread.getWithContactId(senderPublicKey, transaction: transaction)
|
||||||
}
|
}
|
||||||
|
@ -119,20 +117,18 @@ extension MessageReceiver {
|
||||||
configuration.save(with: transaction)
|
configuration.save(with: transaction)
|
||||||
let senderDisplayName = SSKEnvironment.shared.profileManager.profileNameForRecipient(withID: senderPublicKey, transaction: transaction) ?? senderPublicKey
|
let senderDisplayName = SSKEnvironment.shared.profileManager.profileNameForRecipient(withID: senderPublicKey, transaction: transaction) ?? senderPublicKey
|
||||||
let message = OWSDisappearingConfigurationUpdateInfoMessage(timestamp: NSDate.millisecondTimestamp(), thread: thread,
|
let message = OWSDisappearingConfigurationUpdateInfoMessage(timestamp: NSDate.millisecondTimestamp(), thread: thread,
|
||||||
configuration: configuration, createdByRemoteName: senderDisplayName, createdInExistingGroup: isGroup)
|
configuration: configuration, createdByRemoteName: senderDisplayName, createdInExistingGroup: false)
|
||||||
message.save(with: transaction)
|
message.save(with: transaction)
|
||||||
SSKEnvironment.shared.disappearingMessagesJob.startIfNecessary()
|
SSKEnvironment.shared.disappearingMessagesJob.startIfNecessary()
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func disableExpirationTimer(for senderPublicKey: String, groupPublicKey: String?, using transaction: Any) {
|
public static func disableExpirationTimer(for senderPublicKey: String, groupPublicKey: String?, using transaction: Any) {
|
||||||
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
||||||
var isGroup = false
|
|
||||||
var threadOrNil: TSThread?
|
var threadOrNil: TSThread?
|
||||||
if let groupPublicKey = groupPublicKey {
|
if let groupPublicKey = groupPublicKey {
|
||||||
guard Storage.shared.isClosedGroup(groupPublicKey) else { return }
|
guard Storage.shared.isClosedGroup(groupPublicKey) else { return }
|
||||||
let groupID = LKGroupUtilities.getEncodedClosedGroupIDAsData(groupPublicKey)
|
let groupID = LKGroupUtilities.getEncodedClosedGroupIDAsData(groupPublicKey)
|
||||||
threadOrNil = TSGroupThread.fetch(uniqueId: TSGroupThread.threadId(fromGroupId: groupID), transaction: transaction)
|
threadOrNil = TSGroupThread.fetch(uniqueId: TSGroupThread.threadId(fromGroupId: groupID), transaction: transaction)
|
||||||
isGroup = true
|
|
||||||
} else {
|
} else {
|
||||||
threadOrNil = TSContactThread.getWithContactId(senderPublicKey, transaction: transaction)
|
threadOrNil = TSContactThread.getWithContactId(senderPublicKey, transaction: transaction)
|
||||||
}
|
}
|
||||||
|
@ -141,7 +137,7 @@ extension MessageReceiver {
|
||||||
configuration.save(with: transaction)
|
configuration.save(with: transaction)
|
||||||
let senderDisplayName = SSKEnvironment.shared.profileManager.profileNameForRecipient(withID: senderPublicKey, transaction: transaction) ?? senderPublicKey
|
let senderDisplayName = SSKEnvironment.shared.profileManager.profileNameForRecipient(withID: senderPublicKey, transaction: transaction) ?? senderPublicKey
|
||||||
let message = OWSDisappearingConfigurationUpdateInfoMessage(timestamp: NSDate.millisecondTimestamp(), thread: thread,
|
let message = OWSDisappearingConfigurationUpdateInfoMessage(timestamp: NSDate.millisecondTimestamp(), thread: thread,
|
||||||
configuration: configuration, createdByRemoteName: senderDisplayName, createdInExistingGroup: isGroup)
|
configuration: configuration, createdByRemoteName: senderDisplayName, createdInExistingGroup: false)
|
||||||
message.save(with: transaction)
|
message.save(with: transaction)
|
||||||
SSKEnvironment.shared.disappearingMessagesJob.startIfNecessary()
|
SSKEnvironment.shared.disappearingMessagesJob.startIfNecessary()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue