ZDCUser

@interface ZDCUser

Represents a user in the system.

Non-local users will be instances of this class (ZDCUser). Local users will be instances of ZDCLocalUser (which extends ZDCUser).

  • Creates a basic ZDCUser with the given userID.

    Warning

    The framework handles creating users for you most of the time. So you probably will have zero need of ever creating a user manually.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithUUID:(nullable NSString *)uuid;

    Swift

    init(uuid: String?)

    Parameters

    uuid

    The user’s userID. This should NOT be a random value. It needs to match the user’s actual userID according to the server.

  • A user’s uuid is commonly referred to as the userID.

    This property matches a user’s external userID. That is, this is the same userID used to identify the user in the cloud. It’s always 32 characters long, encoded using zBase32.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull uuid;

    Swift

    var uuid: String { get }
  • References the user’s corresponding ZDCPublicKey stored in the database.

    Specifically, this value represents:

    • the corresponding ZDCPublicKey.uuid
    • the key used to fetch it from YapDatabase (within collection kZDCCollection_PublicKeys)

    If this value is null, it may mean we haven’t fetched the publicKey for the user yet. It may also mean the user’s account has been deleted, and thus they no longer have a publicKey.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *publicKeyID;

    Swift

    var publicKeyID: String? { get set }
  • If the user’s publicKey has been verified using the Ethereum blockchain, this value represents the corresponding transaction in which it was verified.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        ZDCBlockchainProof *blockchainProof;

    Swift

    @NSCopying var blockchainProof: ZDCBlockchainProof? { get set }
  • Every user account is tied to a specific region where their data is stored.

    Note

    Users are allowed to reside in different regions. There are no problems communicating between users in different regions.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) AWSRegion aws_region;

    Swift

    var aws_region: AWSRegion { get }
  • The name of a user’s AWS S3 bucket. This has the form: com.4th-a.user.{userID}-{a few chars of randomness}

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *aws_bucket;

    Swift

    var aws_bucket: String? { get }
  • If we discover the user’s publicKey has been tampered with, this value gets set to YES.

    All user’s have a proof of their publicKey posted to the Ethereum blockchain. If we query the blockchain, and discover the user’s publicKey doesn’t match the blockchain, then we block the user, and refuse to give them access to nodes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL accountBlocked;

    Swift

    var accountBlocked: Bool { get set }
  • If the user’s account gets deleted, this value gets set to YES.

    Since the user may still be referenced through the permissions of various nodes, the ZDCUser instance isn’t immediately deleted from the database. Instead, this flag gets set, and the framework ignores the dead account going forward.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL accountDeleted;

    Swift

    var accountDeleted: Bool { get set }
  • A marker used to refresh the user’s information periodically.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic) NSDate *_Nonnull lastRefresh_profile;

    Swift

    var lastRefresh_profile: Date { get set }
  • A marker used to refresh the user’s information periodically.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic) NSDate *_Nonnull lastRefresh_blockchain;

    Swift

    var lastRefresh_blockchain: Date { get set }
  • Contains the list of social identities that the user has linked to their account.

    For example, Alice might link multiple identities to her account:

    • Facebook
    • LinkedIn
    • GitHub

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic)
        NSArray<ZDCUserIdentity *> *_Nonnull identities;

    Swift

    var identities: [ZDCUserIdentity] { get set }
  • Allows a user to control which identity is displayed within the UI.

    For example, Alice might link multiple identities to her account:

    • Facebook (for friends & family)
    • LinkedIn (for work colleagues)

    Alice might set her LinkedIn profile as her preferred identity. This means that, all else being equal, her LinkedIn name & avatar will be shown to other people.

    However, this can be overridden by other users. For example, Bob (Alice’s friend) may prefer to see Alice’s Facebook name & avatar. So Bob can set Alice’s ZDCUser.preferredIdentityID to override this value.

    In other words:

    • Alice’s LinkedIn ZDCUserIdentity.isOwnerPerferredIdentity is TRUE
    • But Bob has set Alice’s ZDCUser.preferredIdentityID to point at her Facebook ZDCUserIdentity
    • Thus on Bob’s system, we display Alice using her Facebook identity

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *preferredIdentityID;

    Swift

    var preferredIdentityID: String? { get set }
  • Extracts an identity for the user from their list of linked identities.

    The following rules are followed, in order:

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) ZDCUserIdentity *displayIdentity;

    Swift

    var displayIdentity: ZDCUserIdentity? { get }
  • Extracts a name for the user from their list of linked identities.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSString *_Nonnull displayName;

    Swift

    var displayName: String { get }
  • Returns the corresponding identity (from the identities array) if it exists.

    Declaration

    Objective-C

    - (nullable ZDCUserIdentity *)identityWithID:(nonnull NSString *)identityID;

    Swift

    func identity(withID identityID: String) -> ZDCUserIdentity?
  • Shorthand way to check if this is an instance of ZDCLocalUser.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL isLocal;

    Swift

    var isLocal: Bool { get }
  • Shorthand way to check if this is NOT an instance of ZDCLocalUser.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL isRemote;

    Swift

    var isRemote: Bool { get }
  • Shorthand way to check if there’s a valid aws_region & aws_bucket property.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL hasRegionAndBucket;

    Swift

    var hasRegionAndBucket: Bool { get }
  • Used when migrating between ZDCUser and ZDCLocalUser.

    Declaration

    Objective-C

    - (void)copyTo:(nonnull ZDCUser *)copy;

    Swift

    func copy(to copy: ZDCUser)
  • Returns YES if the given string is:

  • 32 characters in zBase32 encoding

  • Note

    This method returns NO for anonymousID’s (which are 16 characters).

    Declaration

    Objective-C

    + (BOOL)isUserID:(nonnull NSString *)str;

    Swift

    class func isUserID(_ str: String) -> Bool
  • Returns YES if the given string is:

    • 16 characters in zBase32 encoding

    Declaration

    Objective-C

    + (BOOL)isAnonymousID:(nonnull NSString *)str;

    Swift

    class func isAnonymousID(_ str: String) -> Bool