You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/SessionMessagingKit/Messages/Control Messages/ExpirationTimerUpdate.swift

46 lines
1.6 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import GRDB
import SessionUtilitiesKit
public final class ExpirationTimerUpdate: ControlMessage {
public override var isSelfSendValid: Bool { true }
// MARK: - Proto Conversion
public override class func fromProto(_ proto: SNProtoContent, sender: String) -> ExpirationTimerUpdate? {
guard let dataMessageProto = proto.dataMessage else { return nil }
let isExpirationTimerUpdate = (dataMessageProto.flags & UInt32(SNProtoDataMessage.SNProtoDataMessageFlags.expirationTimerUpdate.rawValue)) != 0
guard isExpirationTimerUpdate else { return nil }
return ExpirationTimerUpdate()
}
Merge remote-tracking branch 'origin/feature/updated-user-config-handling' into disappearing-message-redesign # Conflicts: # Session.xcodeproj/project.pbxproj # Session/Conversations/ConversationVC.swift # Session/Conversations/ConversationViewModel.swift # Session/Conversations/Settings/ThreadDisappearingMessagesSettingsViewModel.swift # Session/Conversations/Settings/ThreadSettingsViewModel.swift # Session/Conversations/Views & Modals/ConversationTitleView.swift # Session/Notifications/AppNotifications.swift # Session/Settings/NukeDataModal.swift # Session/Shared/SessionTableViewModel.swift # Session/Shared/Views/SessionCell.swift # SessionMessagingKit/Configuration.swift # SessionMessagingKit/Database/Models/Contact.swift # SessionMessagingKit/Database/Models/DisappearingMessageConfiguration.swift # SessionMessagingKit/Messages/Control Messages/ClosedGroupControlMessage.swift # SessionMessagingKit/Messages/Message.swift # SessionMessagingKit/Messages/Visible Messages/VisibleMessage.swift # SessionMessagingKit/Protos/Generated/SNProto.swift # SessionMessagingKit/Protos/Generated/SessionProtos.pb.swift # SessionMessagingKit/Protos/SessionProtos.proto # SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift # SessionMessagingKit/Sending & Receiving/MessageReceiver.swift # SessionMessagingKit/Shared Models/SessionThreadViewModel.swift # SessionMessagingKitTests/Open Groups/OpenGroupManagerSpec.swift # SessionMessagingKitTests/_TestUtilities/TestOnionRequestAPI.swift # SessionSnodeKit/Models/SnodeAPIEndpoint.swift # SessionSnodeKit/SnodeAPI.swift # SessionTests/Conversations/Settings/ThreadDisappearingMessagesViewModelSpec.swift # SessionUtilitiesKit/General/Features.swift
2 years ago
public override func toProto(_ db: Database, threadId: String) -> SNProtoContent? {
let dataMessageProto = SNProtoDataMessage.builder()
dataMessageProto.setFlags(UInt32(SNProtoDataMessage.SNProtoDataMessageFlags.expirationTimerUpdate.rawValue))
let contentProto = SNProtoContent.builder()
// DisappearingMessagesConfiguration
setDisappearingMessagesConfigurationIfNeeded(on: contentProto)
do {
contentProto.setDataMessage(try dataMessageProto.build())
return try contentProto.build()
} catch {
SNLog("Couldn't construct expiration timer update proto from: \(self).")
return nil
}
}
// MARK: - Description
public var description: String {
"""
ExpirationTimerUpdate()
"""
}
}