Skip to content

User Profile

UserProfile::UserProfile

Constructs a user profile from existing data (stored from dump()) and the user's secret key for generating the data encryption key. To construct a blank profile (i.e. with no pre-existing dumped data to load) pass std::nullopt as the second argument.

Declaration

UserProfile(
        std::span<const unsigned char> ed25519_secretkey,
        std::optional<std::span<const unsigned char>> dumped);

Parameters

  • ed25519_secretkey — contains the libsodium secret key used to encrypt/decrypt the data when pushing/pulling from the swarm. This can either be the full 64-byte value (which is technically the 32-byte seed followed by the 32-byte pubkey), or just the 32-byte seed of the secret key.
  • dumped — either std::nullopt to construct a new, empty object; or binary state data that was previously dumped from an instance of this class by calling dump().

Returns

  • UserProfile - Constructor

UserProfile::encryption_domain

Returns the domain. Is constant, will always return "UserProfile"

Declaration

const char* encryption_domain() const override { return "UserProfile"; }

Parameters

This endpoint takes no inputs.

Returns

  • const char* - Will return "UserProfile"

UserProfile::get_blinded_msgreqs

Accesses whether or not blinded message requests are enabled for the client. Can have three values:

  • std::nullopt — the value has not been given an explicit value so the client should use its default.
  • true — the value is explicitly enabled (i.e. user wants blinded message requests)
  • false — the value is explicitly disabled (i.e. user disabled blinded message requests)

Declaration

std::optional<bool> get_blinded_msgreqs() const;

Parameters

This endpoint takes no inputs.

Returns

  • std::optional<bool> - true/false if blinded message requests are enabled or disabled; std::nullopt if the option has not been set either way.

UserProfile::get_name

Returns the user profile name, or std::nullopt if there is no profile name set.

Declaration

std::optional<std::string_view> get_name() const;

Parameters

This endpoint takes no inputs.

Returns

  • std::optional<std::string> - Returns the user profile name if it exists

UserProfile::get_nts_expiry

Returns the current Note-to-self message expiry timer, if set, or std::nullopt if there is no current expiry timer set.

Declaration

std::optional<std::chrono::seconds> get_nts_expiry() const;

Parameters

This endpoint takes no inputs.

Returns

  • std::optional<std::chrono::seconds> — Returns the timestamp representing the message expiry timer if the timer is set

UserProfile::get_nts_priority

Gets the Note-to-self conversation priority. Negative means hidden; 0 means unpinned; higher means higher priority (i.e. hidden in the convo list).

Declaration

int get_nts_priority() const;

Parameters

This endpoint takes no inputs.

Returns

  • int — Returns a numeric representing prioritity

UserProfile::get_pro_access_expiry

Retrieves the Session Pro access expiry unix timestamp if it has been set, this should generally be the expiry value returned from /get_pro_details.

Declaration

std::optional<std::chrono::sys_time<std::chrono::milliseconds>> get_pro_access_expiry() const;

Parameters

This endpoint takes no inputs.

Returns

  • std::optional<std::chrono::sys_time<std::chrono::milliseconds>> - The unix timestamp in milliseconds that the users pro access will expire, or nullopt if unset.

UserProfile::get_pro_config

Get the Session Pro data if any, for the current user profile. This may be missing if the user does not have any entitlement to Session Pro config.

Declaration

std::optional<ProConfig> get_pro_config() const;

Parameters

This endpoint takes no inputs.

Returns

UserProfile::get_pro_features

Retrieves the bitset indicating which pro features the user currently has enabled.

Declaration

ProProfileBitset get_profile_bitset() const;

Parameters

This endpoint takes no inputs.

Returns

  • Bitset with individual bits set on it corresponding to SESSION_PROTOCOL_PRO_PROFILE_FEATURES_BITSET. It is possible to receive bits set that don't have a corresponding enum value if you are receiving a bitset from a newer client with newer features enabled. These flags should be ignored by clients that do not recognise them.

UserProfile::get_profile_pic

Gets the user's current profile pic URL and decryption key. The returned object will evaluate as false if the URL and/or key are not set. The returned value will be the latest profile pic between when the user last set their profile and when it was last re-uploaded.

Declaration

profile_pic get_profile_pic() const;

Parameters

This endpoint takes no inputs.

Returns

  • profile_pic - Returns the profile pic

UserProfile::get_profile_updated

Returns the timestamp that the user last updated their profile information; or 0 if it's never been updated. This value will return the latest timestamp between when the user last set their profile and when it was last re-uploaded.

Declaration

std::chrono::sys_seconds get_profile_updated() const;

Parameters

This endpoint takes no inputs.

Returns

  • std::chrono::sys_seconds - timestamp that the user last updated their profile information. Will be 0 if it's never been updated.

UserProfile::remove_pro_config

Remove the Session Pro components from the user profile.

Declaration

bool remove_pro_config();

Parameters

This endpoint takes no inputs.

Returns

  • bool - A flag indicating whether the config had Session Pro components which were removed.

UserProfile::set_animated_avatar

Updates the bitset to specify whether the user has an animated profile picture, should be set when uploading a profile picture. Note: This doesn't prevent a users profile picture from animating, it's just a way to more easily synchronise the state between devices when sending messages so we don't need the device to have successfully download the current display picture in order to be able to determine this.

Declaration

void set_animated_avatar(bool enabled);

Parameters

  • enabled — Flag which specifies whether the users display picture is animated or not.

Returns

UserProfile::set_blinded_msgreqs

Sets whether blinded message requests (i.e. from SOGS servers you are connected to) should be enabled or not. This is typically invoked with either true or false, but can also be called with std::nullopt to explicitly clear the value.

Declaration

void set_blinded_msgreqs(std::optional<bool> enabled);

Parameters

  • enabled — true if blinded message requests should be retrieved, false if they should not, and std::nullopt to drop the setting from the config (and thus use the client's default).

Returns

UserProfile::set_name

Sets the user profile name; if given an empty string then the name is removed.

Declaration

void set_name(std::string_view new_name);

Parameters

  • new_name — The name to be put into the user profile

Returns

UserProfile::set_name_truncated

Sets the user profile name; if given an empty string then the name is removed. Same as the set_name function but truncates the name if it's too long.

Declaration

void set_name_truncated(std::string new_name);

Parameters

  • new_name — The name to be put into the user profile

Returns

UserProfile::set_nts_expiry

Sets the Note-to-self message expiry timer. Call without arguments (or pass a zero time) to disable the expiry timer.

Declaration

void set_nts_expiry(std::chrono::seconds timer = 0s);

Parameters

  • timer — Default to 0 seconds, will set the expiry timer

Returns

UserProfile::set_nts_priority

Sets the Note-to-self conversation priority. -1 for hidden, 0 for unpinned, higher for pinned higher.

Declaration

void set_nts_priority(int priority);

Parameters

  • priority — Numeric representing priority

Returns

UserProfile::set_pro_access_expiry

Updates the Session Pro access expiry unix timestamp.

Declaration

void set_pro_access_expiry(
        std::optional<std::chrono::sys_time<std::chrono::milliseconds>> access_expiry_ts_ms);

Parameters

  • access_expiry_ts_ms — The timestamp that the users Session Pro access will expire, or nullopt to remove the value.

Returns

UserProfile::set_pro_badge

Updates the bitset to specify whether the user wants their profile to show the pro badge.

Declaration

void set_pro_badge(bool enabled);

Parameters

  • enabled — Flag which specifies whether the user wants the pro badge to appear on their profile or not.

Returns

UserProfile::set_pro_config

Attach the Session Pro components to the user profile including the proof entitling the user to use Session Pro features as well as the Ed25519 key pair known as the Rotating Session Pro key authorised to use the proof.

Declaration

void set_pro_config(const ProConfig& pro);

Parameters

  • pro — The Session Pro components to assign to the current user profile. This will overwrite any existing Session Pro config if it exists. No verification of pro is done.

Returns

UserProfile::set_profile_pic

Sets the user's current profile pic to a new URL and decryption key. Clears both as well as the reupload values if either one is empty.

Declaration

void set_profile_pic(std::string_view url, std::span<const unsigned char> key);
void set_profile_pic(profile_pic pic);

Parameters

  • First function:
  • url — URL pointing to the profile pic
  • key — Decryption key
  • Second function:
  • pic — Profile pic object

Returns

UserProfile::set_reupload_profile_pic

Sets the user's profile pic to a new URL and decryption key after reuploading.

Declaration

void set_reupload_profile_pic(std::string_view url, std::span<const unsigned char> key);
void set_reupload_profile_pic(profile_pic pic);

Parameters

  • First function:
  • url — URL pointing to the profile pic
  • key — Decryption key
  • Second function:
  • pic — Profile pic object

Returns

UserProfile::set_theme_primary_color

Sets the setting indicating which primary color the client should use.

Declaration

void set_theme_primary_color(theme_primary_color value);

Parameters

  • value — Updated primary color setting

Returns

UserProfile::storage_namespace

Returns the UserProfile namespace. Is constant, will always return 2

Declaration

Namespace storage_namespace() const override { return Namespace::UserProfile; }

Parameters

This endpoint takes no inputs.

Returns

  • Namespace - Will return 2