Merge pull request #201 from loki-project/push-notifications

Fix Duplicate Push Notification Bug
pull/202/head
Niels Andriesse 5 years ago committed by GitHub
commit bc9b98cdba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save