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
		
	
| 
											5 years ago
										 | 
 | ||
|  | @objc(SNOpenGroupV2) | ||
|  | public final class OpenGroupV2 : NSObject, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility | ||
| 
											5 years ago
										 |     @objc public let server: String | ||
|  |     @objc public let room: String | ||
| 
											5 years ago
										 |     public let id: String | ||
| 
											5 years ago
										 |     @objc public let name: String | ||
|  |     @objc public let publicKey: String | ||
| 
											5 years ago
										 |     /// The ID with which the image can be retrieved from the server. | ||
| 
											5 years ago
										 |     public let imageID: String? | ||
| 
											5 years ago
										 | 
 | ||
| 
											5 years ago
										 |     public init(server: String, room: String, name: String, publicKey: String, imageID: String?) { | ||
| 
											5 years ago
										 |         self.server = server.lowercased() | ||
|  |         self.room = room | ||
|  |         self.id = "\(server).\(room)" | ||
|  |         self.name = name | ||
| 
											5 years ago
										 |         self.publicKey = publicKey | ||
| 
											5 years ago
										 |         self.imageID = imageID | ||
| 
											5 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 | ||
| 
											5 years ago
										 |         publicKey = coder.decodeObject(forKey: "publicKey") as! String | ||
| 
											5 years ago
										 |         imageID = coder.decodeObject(forKey: "imageID") as! String? | ||
| 
											5 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") | ||
| 
											5 years ago
										 |         coder.encode(publicKey, forKey: "publicKey") | ||
| 
											5 years ago
										 |         if let imageID = imageID { coder.encode(imageID, forKey: "imageID") } | ||
| 
											5 years ago
										 |     } | ||
|  | 
 | ||
| 
											5 years ago
										 |     override public var description: String { "\(name) (Server: \(server), Room: \(room)" } | ||
| 
											5 years ago
										 | } |