update legacy to be unknown

pull/941/head
Ryan Zhao 2 years ago
parent a966fca55e
commit 09e1c02e1d

@ -20,13 +20,13 @@ public struct DisappearingMessagesConfiguration: Codable, Identifiable, Equatabl
} }
public enum DisappearingMessageType: Int, Codable, Hashable, DatabaseValueConvertible { public enum DisappearingMessageType: Int, Codable, Hashable, DatabaseValueConvertible {
case legacy case unknown
case disappearAfterRead case disappearAfterRead
case disappearAfterSend case disappearAfterSend
public var defaultDuration: TimeInterval { public var defaultDuration: TimeInterval {
switch self { switch self {
case .legacy: return (12 * 60 * 60) case .unknown: return 0
case .disappearAfterRead: return (12 * 60 * 60) case .disappearAfterRead: return (12 * 60 * 60)
case .disappearAfterSend: return (24 * 60 * 60) case .disappearAfterSend: return (24 * 60 * 60)
} }
@ -34,7 +34,7 @@ public struct DisappearingMessagesConfiguration: Codable, Identifiable, Equatabl
init(protoType: SNProtoContent.SNProtoContentExpirationType) { init(protoType: SNProtoContent.SNProtoContentExpirationType) {
switch protoType { switch protoType {
case .legacy: self = .legacy case .unknown: self = .unknown
case .deleteAfterRead: self = .disappearAfterRead case .deleteAfterRead: self = .disappearAfterRead
case .deleteAfterSend: self = .disappearAfterSend case .deleteAfterSend: self = .disappearAfterSend
} }
@ -42,7 +42,7 @@ public struct DisappearingMessagesConfiguration: Codable, Identifiable, Equatabl
func toProto() -> SNProtoContent.SNProtoContentExpirationType { func toProto() -> SNProtoContent.SNProtoContentExpirationType {
switch self { switch self {
case .legacy: return .legacy case .unknown: return .unknown
case .disappearAfterRead: return .deleteAfterRead case .disappearAfterRead: return .deleteAfterRead
case .disappearAfterSend: return .deleteAfterSend case .disappearAfterSend: return .deleteAfterSend
} }
@ -215,7 +215,7 @@ extension DisappearingMessagesConfiguration {
public static func validDurationsSeconds(_ type: DisappearingMessageType) -> [TimeInterval] { public static func validDurationsSeconds(_ type: DisappearingMessageType) -> [TimeInterval] {
switch type { switch type {
case .legacy, .disappearAfterRead: case .disappearAfterRead:
return [ return [
60, // TODO: remove this, for test purpose only 60, // TODO: remove this, for test purpose only
(5 * 60), (5 * 60),
@ -233,6 +233,8 @@ extension DisappearingMessagesConfiguration {
(7 * 24 * 60 * 60), (7 * 24 * 60 * 60),
(2 * 7 * 24 * 60 * 60) (2 * 7 * 24 * 60 * 60)
] ]
default:
return []
} }
} }
} }

@ -588,14 +588,14 @@ extension SNProtoMessageRequestResponse.SNProtoMessageRequestResponseBuilder {
// MARK: - SNProtoContentExpirationType // MARK: - SNProtoContentExpirationType
@objc public enum SNProtoContentExpirationType: Int32 { @objc public enum SNProtoContentExpirationType: Int32 {
case legacy = 0 case unknown = 0
case deleteAfterRead = 1 case deleteAfterRead = 1
case deleteAfterSend = 2 case deleteAfterSend = 2
} }
private class func SNProtoContentExpirationTypeWrap(_ value: SessionProtos_Content.ExpirationType) -> SNProtoContentExpirationType { private class func SNProtoContentExpirationTypeWrap(_ value: SessionProtos_Content.ExpirationType) -> SNProtoContentExpirationType {
switch value { switch value {
case .legacy: return .legacy case .unknown: return .unknown
case .deleteAfterRead: return .deleteAfterRead case .deleteAfterRead: return .deleteAfterRead
case .deleteAfterSend: return .deleteAfterSend case .deleteAfterSend: return .deleteAfterSend
} }
@ -603,7 +603,7 @@ extension SNProtoMessageRequestResponse.SNProtoMessageRequestResponseBuilder {
private class func SNProtoContentExpirationTypeUnwrap(_ value: SNProtoContentExpirationType) -> SessionProtos_Content.ExpirationType { private class func SNProtoContentExpirationTypeUnwrap(_ value: SNProtoContentExpirationType) -> SessionProtos_Content.ExpirationType {
switch value { switch value {
case .legacy: return .legacy case .unknown: return .unknown
case .deleteAfterRead: return .deleteAfterRead case .deleteAfterRead: return .deleteAfterRead
case .deleteAfterSend: return .deleteAfterSend case .deleteAfterSend: return .deleteAfterSend
} }

@ -358,7 +358,7 @@ struct SessionProtos_Content {
mutating func clearSharedConfigMessage() {_uniqueStorage()._sharedConfigMessage = nil} mutating func clearSharedConfigMessage() {_uniqueStorage()._sharedConfigMessage = nil}
var expirationType: SessionProtos_Content.ExpirationType { var expirationType: SessionProtos_Content.ExpirationType {
get {return _storage._expirationType ?? .legacy} get {return _storage._expirationType ?? .unknown}
set {_uniqueStorage()._expirationType = newValue} set {_uniqueStorage()._expirationType = newValue}
} }
/// Returns true if `expirationType` has been explicitly set. /// Returns true if `expirationType` has been explicitly set.
@ -388,17 +388,17 @@ struct SessionProtos_Content {
enum ExpirationType: SwiftProtobuf.Enum { enum ExpirationType: SwiftProtobuf.Enum {
typealias RawValue = Int typealias RawValue = Int
case legacy // = 0 case unknown // = 0
case deleteAfterRead // = 1 case deleteAfterRead // = 1
case deleteAfterSend // = 2 case deleteAfterSend // = 2
init() { init() {
self = .legacy self = .unknown
} }
init?(rawValue: Int) { init?(rawValue: Int) {
switch rawValue { switch rawValue {
case 0: self = .legacy case 0: self = .unknown
case 1: self = .deleteAfterRead case 1: self = .deleteAfterRead
case 2: self = .deleteAfterSend case 2: self = .deleteAfterSend
default: return nil default: return nil
@ -407,7 +407,7 @@ struct SessionProtos_Content {
var rawValue: Int { var rawValue: Int {
switch self { switch self {
case .legacy: return 0 case .unknown: return 0
case .deleteAfterRead: return 1 case .deleteAfterRead: return 1
case .deleteAfterSend: return 2 case .deleteAfterSend: return 2
} }
@ -2121,7 +2121,7 @@ extension SessionProtos_Content: SwiftProtobuf.Message, SwiftProtobuf._MessageIm
extension SessionProtos_Content.ExpirationType: SwiftProtobuf._ProtoNameProviding { extension SessionProtos_Content.ExpirationType: SwiftProtobuf._ProtoNameProviding {
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
0: .same(proto: "LEGACY"), 0: .same(proto: "UNKNOWN"),
1: .same(proto: "DELETE_AFTER_READ"), 1: .same(proto: "DELETE_AFTER_READ"),
2: .same(proto: "DELETE_AFTER_SEND"), 2: .same(proto: "DELETE_AFTER_SEND"),
] ]

@ -51,7 +51,7 @@ message MessageRequestResponse {
message Content { message Content {
enum ExpirationType { enum ExpirationType {
LEGACY = 0; UNKNOWN = 0;
DELETE_AFTER_READ = 1; DELETE_AFTER_READ = 1;
DELETE_AFTER_SEND = 2; DELETE_AFTER_SEND = 2;
} }

@ -9,5 +9,5 @@ public final class Features {
public static let useSharedUtilForUserConfig: Bool = true // TODO: Base this off a timestamp public static let useSharedUtilForUserConfig: Bool = true // TODO: Base this off a timestamp
// public static let useNewDisappearingMessagesConfig: Bool = Date().timeIntervalSince1970 > 1671062400 // 15/12/2022 // public static let useNewDisappearingMessagesConfig: Bool = Date().timeIntervalSince1970 > 1671062400 // 15/12/2022
public static let useNewDisappearingMessagesConfig: Bool = true public static let useNewDisappearingMessagesConfig: Bool = false
} }

Loading…
Cancel
Save