parent
95b1dced18
commit
0a17246737
|
@ -3423,11 +3423,11 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
enabled:YES
|
||||
durationSeconds:(uint32_t)[durationSeconds intValue]];
|
||||
[result addObject:[[OWSDisappearingConfigurationUpdateInfoMessage alloc]
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroupName:nil]];
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroup:NO]];
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -3437,11 +3437,11 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
enabled:YES
|
||||
durationSeconds:(uint32_t)[durationSeconds intValue]];
|
||||
[result addObject:[[OWSDisappearingConfigurationUpdateInfoMessage alloc]
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:nil
|
||||
createdInExistingGroupName:@"Book Club"]];
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:nil
|
||||
createdInExistingGroup:YES]];
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -3451,11 +3451,11 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
enabled:YES
|
||||
durationSeconds:(uint32_t)[durationSeconds intValue]];
|
||||
[result addObject:[[OWSDisappearingConfigurationUpdateInfoMessage alloc]
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroupName:nil]];
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroup:NO]];
|
||||
}
|
||||
{
|
||||
OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration =
|
||||
|
@ -3463,11 +3463,11 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
enabled:NO
|
||||
durationSeconds:0];
|
||||
[result addObject:[[OWSDisappearingConfigurationUpdateInfoMessage alloc]
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroupName:nil]];
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:@"Alice"
|
||||
createdInExistingGroup:NO]];
|
||||
}
|
||||
|
||||
[result addObject:[TSInfoMessage userNotRegisteredMessageInThread:thread recipientId:@"+19174054215"]];
|
||||
|
|
|
@ -821,11 +821,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self.disappearingMessagesConfiguration save];
|
||||
OWSDisappearingConfigurationUpdateInfoMessage *infoMessage =
|
||||
[[OWSDisappearingConfigurationUpdateInfoMessage alloc]
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:self.thread
|
||||
configuration:self.disappearingMessagesConfiguration
|
||||
createdByRemoteName:nil
|
||||
createdInExistingGroupName:nil];
|
||||
initWithTimestamp:[NSDate ows_millisecondTimeStamp]
|
||||
thread:self.thread
|
||||
configuration:self.disappearingMessagesConfiguration
|
||||
createdByRemoteName:nil
|
||||
createdInExistingGroup:NO];
|
||||
[infoMessage save];
|
||||
|
||||
[OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob
|
||||
|
|
|
@ -660,7 +660,7 @@
|
|||
"DISAPPEARING_MESSAGES" = "Disappearing Messages";
|
||||
|
||||
/* Info Message when added to {{group name}} which has enabled message expiration after {{time amount}}, see the *_TIME_AMOUNT strings for context. */
|
||||
"DISAPPEARING_MESSAGES_CONFIGURATION_GROUP_EXISTING_FORMAT" = "%@ has disappearing messages enabled for %@.";
|
||||
"DISAPPEARING_MESSAGES_CONFIGURATION_GROUP_EXISTING_FORMAT" = "Messages in this conversation will disappear after %@.";
|
||||
|
||||
/* subheading in conversation settings */
|
||||
"DISAPPEARING_MESSAGES_DESCRIPTION" = "When enabled, messages sent and received in this conversation will disappear after they have been seen.";
|
||||
|
|
|
@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
thread:(TSThread *)thread
|
||||
configuration:(OWSDisappearingMessagesConfiguration *)configuration
|
||||
createdByRemoteName:(nullable NSString *)remoteName
|
||||
createdInExistingGroupName:(nullable NSString *)createdInExistingGroupName;
|
||||
createdInExistingGroup:(BOOL)createdInExistingGroup;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@interface OWSDisappearingConfigurationUpdateInfoMessage ()
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSString *createdByRemoteName;
|
||||
@property (nonatomic, readonly, nullable) NSString *createdInExistingGroupName;
|
||||
@property (nonatomic, readonly) BOOL createdInExistingGroup;
|
||||
@property (nonatomic, readonly) BOOL configurationIsEnabled;
|
||||
@property (nonatomic, readonly) uint32_t configurationDurationSeconds;
|
||||
|
||||
|
@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
thread:(TSThread *)thread
|
||||
configuration:(OWSDisappearingMessagesConfiguration *)configuration
|
||||
createdByRemoteName:(nullable NSString *)remoteName
|
||||
createdInExistingGroupName:(nullable NSString *)createdInExistingGroupName
|
||||
createdInExistingGroup:(BOOL)createdInExistingGroup
|
||||
{
|
||||
self = [super initWithTimestamp:timestamp inThread:thread messageType:TSInfoMessageTypeDisappearingMessagesUpdate];
|
||||
if (!self) {
|
||||
|
@ -32,8 +32,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
_configurationIsEnabled = configuration.isEnabled;
|
||||
_configurationDurationSeconds = configuration.durationSeconds;
|
||||
|
||||
// At most one should be set
|
||||
OWSAssert(!remoteName || !createdInExistingGroup);
|
||||
|
||||
_createdByRemoteName = remoteName;
|
||||
_createdInExistingGroupName = createdInExistingGroupName;
|
||||
_createdInExistingGroup = createdInExistingGroup;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -47,7 +51,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
-(NSString *)previewTextWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
{
|
||||
if (self.createdByRemoteName) {
|
||||
if (self.createdInExistingGroup) {
|
||||
OWSAssert(self.configurationIsEnabled && self.configurationDurationSeconds > 0);
|
||||
NSString *infoFormat = NSLocalizedString(@"DISAPPEARING_MESSAGES_CONFIGURATION_GROUP_EXISTING_FORMAT",
|
||||
@"Info Message when added to a group which has enabled disappearing messages. Embeds {{time amount}} "
|
||||
@"before messages disappear, see the *_TIME_AMOUNT strings for context.");
|
||||
|
||||
NSString *durationString = [NSString formatDurationSeconds:self.configurationDurationSeconds useShortFormat:NO];
|
||||
return [NSString stringWithFormat:infoFormat, durationString];
|
||||
} else if (self.createdByRemoteName) {
|
||||
if (self.configurationIsEnabled && self.configurationDurationSeconds > 0) {
|
||||
NSString *infoFormat = NSLocalizedString(@"OTHER_UPDATED_DISAPPEARING_MESSAGES_CONFIGURATION",
|
||||
@"Info Message when {{other user}} updates message expiration to {{time amount}}, see the "
|
||||
|
@ -62,14 +74,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@"Info Message when {{other user}} disables or doesn't support disappearing messages");
|
||||
return [NSString stringWithFormat:infoFormat, self.createdByRemoteName];
|
||||
}
|
||||
} else if (self.createdInExistingGroupName) {
|
||||
OWSAssert(self.configurationIsEnabled && self.configurationDurationSeconds > 0);
|
||||
NSString *infoFormat = NSLocalizedString(@"DISAPPEARING_MESSAGES_CONFIGURATION_GROUP_EXISTING_FORMAT",
|
||||
@"Info Message when added to {{group name}} which has enabled message expiration after {{time amount}}, "
|
||||
@"see the *_TIME_AMOUNT strings for context.");
|
||||
|
||||
NSString *durationString = [NSString formatDurationSeconds:self.configurationDurationSeconds useShortFormat:NO];
|
||||
return [NSString stringWithFormat:infoFormat, self.createdByRemoteName, durationString];
|
||||
} else {
|
||||
// Changed by local request
|
||||
if (self.configurationIsEnabled && self.configurationDurationSeconds > 0) {
|
||||
|
|
|
@ -49,14 +49,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*
|
||||
* @param remoteContactName
|
||||
* nil for outgoing messages, otherwise the name of the sender
|
||||
* @param existingGroupName
|
||||
* set when being added to a group which already has DM enabled, otherwise nil
|
||||
* @param createdInExistingGroup
|
||||
* YES when being added to a group which already has DM enabled, otherwise NO
|
||||
*/
|
||||
- (void)becomeConsistentWithDisappearingDuration:(uint32_t)duration
|
||||
thread:(TSThread *)thread
|
||||
appearBeforeTimestamp:(uint64_t)timestampForSorting
|
||||
createdByRemoteContactName:(nullable NSString *)remoteContactName
|
||||
createdInExistingGroupName:(nullable NSString *)existingGroupName
|
||||
createdInExistingGroup:(BOOL)createdInExistingGroup
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||
|
||||
// Clean up any messages that expired since last launch immediately
|
||||
|
|
|
@ -208,7 +208,7 @@ void AssertIsOnDisappearingMessagesQueue()
|
|||
thread:thread
|
||||
appearBeforeTimestamp:message.timestampForSorting
|
||||
createdByRemoteContactName:remoteContactName
|
||||
createdInExistingGroupName:nil
|
||||
createdInExistingGroup:NO
|
||||
transaction:transaction];
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ void AssertIsOnDisappearingMessagesQueue()
|
|||
thread:(TSThread *)thread
|
||||
appearBeforeTimestamp:(uint64_t)timestampForSorting
|
||||
createdByRemoteContactName:(nullable NSString *)remoteContactName
|
||||
createdInExistingGroupName:(nullable NSString *)existingGroupName
|
||||
createdInExistingGroup:(BOOL)createdInExistingGroup
|
||||
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
OWSAssert(thread);
|
||||
|
@ -253,7 +253,7 @@ void AssertIsOnDisappearingMessagesQueue()
|
|||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:remoteContactName
|
||||
createdInExistingGroupName:existingGroupName];
|
||||
createdInExistingGroup:createdInExistingGroup];
|
||||
[infoMessage saveWithTransaction:transaction];
|
||||
|
||||
backgroundTask = nil;
|
||||
|
|
|
@ -776,7 +776,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
thread:thread
|
||||
configuration:disappearingMessagesConfiguration
|
||||
createdByRemoteName:name
|
||||
createdInExistingGroupName:nil];
|
||||
createdInExistingGroup:NO];
|
||||
[message saveWithTransaction:transaction];
|
||||
}
|
||||
|
||||
|
@ -968,14 +968,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
customMessage:updateGroupInfo] saveWithTransaction:transaction];
|
||||
|
||||
if (dataMessage.hasExpireTimer && dataMessage.expireTimer > 0) {
|
||||
// We could use the sender name here, but maybe it makes more sense to attribute it to the group.
|
||||
NSString *configUpdateName = dataMessage.group.name;
|
||||
[[OWSDisappearingMessagesJob sharedJob]
|
||||
becomeConsistentWithDisappearingDuration:dataMessage.expireTimer
|
||||
thread:newGroupThread
|
||||
appearBeforeTimestamp:now
|
||||
createdByRemoteContactName:nil
|
||||
createdInExistingGroupName:configUpdateName
|
||||
createdInExistingGroup:YES
|
||||
transaction:transaction];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue