@objc(SNContact) public class Contact : NSObject, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility @objc public let sessionID: String /// The display name of the contact. /// /// - Note: In open groups use `openGroupDisplayName`. @objc public var displayName: String? /// The URL from which to fetch the contact's profile picture. @objc public var profilePictureURL: String? /// The file name of the contact's profile picture on local storage. @objc public var profilePictureFileName: String? /// The key with which the profile picture is encrypted. @objc public var profilePictureEncryptionKey: OWSAES256Key? /// The ID of the thread associated with this contact. @objc public var threadID: String? /// In open groups, where it's more likely that multiple users have the same name, we display a bit of the Session ID after /// a user's display name for added context. public var openGroupDisplayName: String? { guard let displayName = displayName else { return nil } let endIndex = sessionID.endIndex let cutoffIndex = sessionID.index(endIndex, offsetBy: -8) return "\(displayName) (...\(sessionID[cutoffIndex.. Bool { guard let other = other as? Contact else { return false } return sessionID == other.sessionID } // MARK: Hashing override public var hash: Int { // Override NSObject.hash and not Hashable.hashValue or Hashable.hash(into:) return sessionID.hash } // MARK: Description override public var description: String { if let displayName = displayName { return displayName } else { return sessionID } } }