Create GroupCallUpdateMessage

This commit is contained in:
Niels Andriesse 2021-08-02 13:36:51 +10:00
parent 2ae54ed46e
commit c77255a57f
2 changed files with 71 additions and 0 deletions

View File

@ -176,6 +176,7 @@
B8269D2925C7A4B400488AB4 /* InputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8269D2825C7A4B400488AB4 /* InputView.swift */; };
B8269D3325C7A8C600488AB4 /* InputViewButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8269D3225C7A8C600488AB4 /* InputViewButton.swift */; };
B8269D3D25C7B34D00488AB4 /* InputTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8269D3C25C7B34D00488AB4 /* InputTextView.swift */; };
B82A0C0026B79EB700C1BCE3 /* GroupCallUpdateMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = B82A0BFF26B79EB700C1BCE3 /* GroupCallUpdateMessage.swift */; };
B82B40882399EB0E00A248E7 /* LandingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B82B40872399EB0E00A248E7 /* LandingVC.swift */; };
B82B408A2399EC0600A248E7 /* FakeChatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B82B40892399EC0600A248E7 /* FakeChatView.swift */; };
B82B408C239A068800A248E7 /* RegisterVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B82B408B239A068800A248E7 /* RegisterVC.swift */; };
@ -1181,6 +1182,7 @@
B8269D2825C7A4B400488AB4 /* InputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputView.swift; sourceTree = "<group>"; };
B8269D3225C7A8C600488AB4 /* InputViewButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputViewButton.swift; sourceTree = "<group>"; };
B8269D3C25C7B34D00488AB4 /* InputTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputTextView.swift; sourceTree = "<group>"; };
B82A0BFF26B79EB700C1BCE3 /* GroupCallUpdateMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupCallUpdateMessage.swift; sourceTree = "<group>"; };
B82B40872399EB0E00A248E7 /* LandingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LandingVC.swift; sourceTree = "<group>"; };
B82B40892399EC0600A248E7 /* FakeChatView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FakeChatView.swift; sourceTree = "<group>"; };
B82B408B239A068800A248E7 /* RegisterVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterVC.swift; sourceTree = "<group>"; };
@ -2477,6 +2479,7 @@
C300A5E62554B07300555489 /* ExpirationTimerUpdate.swift */,
C3DA9C0625AE7396008F7C7E /* ConfigurationMessage.swift */,
B822F9CC26B3C538003B8CB8 /* IndividualCallMessage.swift */,
B82A0BFF26B79EB700C1BCE3 /* GroupCallUpdateMessage.swift */,
);
path = "Control Messages";
sourceTree = "<group>";
@ -4730,6 +4733,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B82A0C0026B79EB700C1BCE3 /* GroupCallUpdateMessage.swift in Sources */,
B8856D08256F10F1001CE70E /* DeviceSleepManager.swift in Sources */,
C3471F4C25553AB000297E91 /* MessageReceiver+Decryption.swift in Sources */,
C300A5D32554B05A00555489 /* TypingIndicator.swift in Sources */,

View File

@ -0,0 +1,67 @@
import SessionUtilitiesKit
public final class GroupCallUpdateMessage : ControlMessage {
public var eraID: String?
// MARK: Initialization
public override init() { super.init() }
internal init(eraID: String) {
super.init()
self.eraID = eraID
}
// MARK: Validation
public override var isValid: Bool {
guard super.isValid else { return false }
return eraID != nil
}
// MARK: Coding
public required init?(coder: NSCoder) {
super.init(coder: coder)
guard let eraID = coder.decodeObject(forKey: "eraID") as? String else { return nil }
self.eraID = eraID
}
public override func encode(with coder: NSCoder) {
super.encode(with: coder)
guard let eraID = eraID else { return }
coder.encode(eraID, forKey: "eraID")
}
// MARK: Proto Conversion
public override class func fromProto(_ proto: SNProtoContent) -> GroupCallUpdateMessage? {
guard let groupCallUpdate = proto.dataMessage?.groupCallUpdate,
let eraID = groupCallUpdate.eraID else { return nil }
return GroupCallUpdateMessage(eraID: eraID)
}
public override func toProto(using transaction: YapDatabaseReadWriteTransaction) -> SNProtoContent? {
guard let eraID = eraID else {
SNLog("Couldn't construct group call update message proto from: \(self).")
return nil
}
let groupCallUpdateProto = SNProtoDataMessageGroupCallUpdate.builder()
groupCallUpdateProto.setEraID(eraID)
do {
let dataMessageProto = SNProtoDataMessage.builder()
dataMessageProto.setGroupCallUpdate(try groupCallUpdateProto.build())
let contentProto = SNProtoContent.builder()
contentProto.setDataMessage(try dataMessageProto.build())
return try contentProto.build()
} catch {
SNLog("Couldn't construct group call update message proto from: \(self).")
return nil
}
}
// MARK: Description
public override var description: String {
"""
GroupCallUpdateMessage(
eraID: \(eraID ?? "null")
)
"""
}
}