mirror of https://github.com/oxen-io/session-ios
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.
42 lines
1.5 KiB
Swift
42 lines
1.5 KiB
Swift
4 years ago
|
|
||
|
@objc(SNOpenGroupV2)
|
||
|
public final class OpenGroupV2 : NSObject, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility
|
||
4 years ago
|
@objc public let server: String
|
||
|
@objc public let room: String
|
||
4 years ago
|
public let id: String
|
||
4 years ago
|
@objc public let name: String
|
||
|
@objc public let publicKey: String
|
||
4 years ago
|
/// The ID with which the image can be retrieved from the server.
|
||
4 years ago
|
public let imageID: String?
|
||
4 years ago
|
|
||
4 years ago
|
public init(server: String, room: String, name: String, publicKey: String, imageID: String?) {
|
||
4 years ago
|
self.server = server.lowercased()
|
||
|
self.room = room
|
||
|
self.id = "\(server).\(room)"
|
||
|
self.name = name
|
||
4 years ago
|
self.publicKey = publicKey
|
||
4 years ago
|
self.imageID = imageID
|
||
4 years ago
|
}
|
||
|
|
||
|
// MARK: Coding
|
||
|
public init?(coder: NSCoder) {
|
||
|
server = coder.decodeObject(forKey: "server") as! String
|
||
|
room = coder.decodeObject(forKey: "room") as! String
|
||
|
self.id = "\(server).\(room)"
|
||
|
name = coder.decodeObject(forKey: "name") as! String
|
||
4 years ago
|
publicKey = coder.decodeObject(forKey: "publicKey") as! String
|
||
4 years ago
|
imageID = coder.decodeObject(forKey: "imageID") as! String?
|
||
4 years ago
|
super.init()
|
||
|
}
|
||
|
|
||
|
public func encode(with coder: NSCoder) {
|
||
|
coder.encode(server, forKey: "server")
|
||
|
coder.encode(room, forKey: "room")
|
||
|
coder.encode(name, forKey: "name")
|
||
4 years ago
|
coder.encode(publicKey, forKey: "publicKey")
|
||
4 years ago
|
if let imageID = imageID { coder.encode(imageID, forKey: "imageID") }
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
override public var description: String { "\(name) (Server: \(server), Room: \(room)" }
|
||
4 years ago
|
}
|