Fix duplicate push notification bug

This commit is contained in:
nielsandriesse 2020-06-01 17:02:10 +10:00
parent b6264be795
commit 6977846ce2
9 changed files with 29 additions and 1 deletions

View file

@ -130,6 +130,10 @@ NS_ASSUME_NONNULL_BEGIN
stringWithFormat:@"%@ with message timestamps: %lu", self.logTag, (unsigned long)self.messageTimestamps.count];
}
#pragma mark - Other
- (uint)ttl { return (uint)[LKTTLUtilities getTTLFor:LKMessageTypeReceipt]; }
@end
NS_ASSUME_NONNULL_END

View file

@ -8,11 +8,16 @@ public final class TTLUtilities : NSObject {
@objc(LKMessageType)
public enum MessageType : Int {
case address
case call
case disappearingMessagesConfiguration
case ephemeral
case friendRequest
case linkDevice
case profileKey
case receipt
case regular
case sessionRequest
case sync
case typingIndicator
case unlinkDevice
}
@ -20,11 +25,16 @@ public final class TTLUtilities : NSObject {
@objc public static func getTTL(for messageType: MessageType) -> UInt64 {
switch messageType {
case .address: return 1 * kMinuteInMs
case .call: return 1 * kMinuteInMs
case .disappearingMessagesConfiguration: return 4 * kDayInMs - 1 * kHourInMs
case .ephemeral: return 4 * kDayInMs - 1 * kHourInMs
case .friendRequest: return 4 * kDayInMs
case .linkDevice: return 4 * kMinuteInMs
case .sessionRequest: return 4 * kDayInMs - 1 * kHourInMs
case .profileKey: return 4 * kDayInMs - 1 * kHourInMs
case .receipt: return 4 * kDayInMs - 1 * kHourInMs
case .regular: return 2 * kDayInMs
case .sessionRequest: return 4 * kDayInMs - 1 * kHourInMs
case .sync: return 4 * kDayInMs - 1 * kHourInMs
case .typingIndicator: return 1 * kMinuteInMs
case .unlinkDevice: return 4 * kDayInMs - 1 * kHourInMs
}

View file

@ -60,6 +60,8 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (uint)ttl { return (uint)[LKTTLUtilities getTTLFor:LKMessageTypeSync]; }
- (BOOL)shouldBeSaved
{
return NO;

View file

@ -42,6 +42,8 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (uint)ttl { return (uint)[LKTTLUtilities getTTLFor:LKMessageTypeSync]; }
- (BOOL)shouldBeSaved
{
return NO;

View file

@ -24,6 +24,8 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- (uint)ttl { return (uint)[LKTTLUtilities getTTLFor:LKMessageTypeDisappearingMessagesConfiguration]; }
- (instancetype)initWithConfiguration:(OWSDisappearingMessagesConfiguration *)configuration thread:(TSThread *)thread
{
// MJK TODO - remove sender timestamp

View file

@ -36,6 +36,8 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- (uint)ttl { return (uint)[LKTTLUtilities getTTLFor:LKMessageTypeEphemeral]; }
- (nullable SSKProtoDataMessageBuilder *)dataMessageBuilder
{
SSKProtoDataMessageBuilder *_Nullable builder = [super dataMessageBuilder];

View file

@ -162,6 +162,8 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - TSYapDatabaseObject overrides
- (uint)ttl { return (uint)[LKTTLUtilities getTTLFor:LKMessageTypeCall]; }
- (BOOL)shouldBeSaved
{
return NO;

View file

@ -84,6 +84,8 @@ NS_ASSUME_NONNULL_BEGIN
return contentData;
}
- (uint)ttl { return (uint)[LKTTLUtilities getTTLFor:LKMessageTypeEphemeral]; }
- (BOOL)shouldSyncTranscript
{
return NO;

View file

@ -32,6 +32,8 @@ NS_ASSUME_NONNULL_BEGIN
return [super initWithCoder:coder];
}
- (uint)ttl { return (uint)[LKTTLUtilities getTTLFor:LKMessageTypeProfileKey]; }
- (BOOL)shouldBeSaved
{
return NO;