@@ -20,6 +20,7 @@ typedef struct contacts_contact {
2020 char name [101 ];
2121 char nickname [101 ];
2222 user_profile_pic profile_pic ;
23+ int64_t profile_updated ; // unix timestamp (seconds)
2324
2425 bool approved ;
2526 bool approved_me ;
@@ -36,6 +37,31 @@ typedef struct contacts_contact {
3637
3738} contacts_contact ;
3839
40+ typedef struct contacts_blinded_contact {
41+ char session_id [67 ]; // in hex; 66 hex chars + null terminator.
42+ char base_url [268 ]; // null-terminated (max length 267), normalized (i.e. always lower-case,
43+ // only has port if non-default, has trailing / removed)
44+ unsigned char pubkey [32 ]; // 32 bytes (not terminated, can contain nulls)
45+
46+ char name [101 ]; // This will be a 0-length string when unset
47+ user_profile_pic profile_pic ;
48+
49+ bool legacy_blinding ;
50+ int64_t created ; // unix timestamp (seconds)
51+
52+ } contacts_blinded_contact ;
53+
54+ /// Struct containing a list of contacts_blinded_contact structs. Typically where this is returned
55+ /// by this API it must be freed (via `free()`) when done with it.
56+ ///
57+ /// When returned as a pointer by a libsession-util function this is allocated in such a way that
58+ /// just the outer contacts_blinded_contact_list can be free()d to free both the list *and* the
59+ /// inner `value` and pointed-at values.
60+ typedef struct contacts_blinded_contact_list {
61+ contacts_blinded_contact * * value ; // array of blinded contacts
62+ size_t len ; // length of `value`
63+ } contacts_blinded_contact_list ;
64+
3965/// API: contacts/contacts_init
4066///
4167/// Constructs a contacts config object and sets a pointer to it in `conf`.
@@ -208,6 +234,147 @@ LIBSESSION_EXPORT bool contacts_erase(config_object* conf, const char* session_i
208234/// - `size_t` -- number of contacts
209235LIBSESSION_EXPORT size_t contacts_size (const config_object * conf );
210236
237+ /// API: contacts/contacts_blinded_contacts
238+ ///
239+ /// Retrieves a list of blinded contact records.
240+ ///
241+ /// Declaration:
242+ /// ```cpp
243+ /// contacts_blinded_contact_list* contacts_blinded_contacts(
244+ /// [in] config_object* conf
245+ /// );
246+ /// ```
247+ ///
248+ /// Inputs:
249+ /// - `conf` -- [in, out] Pointer to config_object object
250+ ///
251+ /// Outputs:
252+ /// - `contacts_blinded_contact_list*` -- pointer to the list of blinded contact structs; the
253+ /// pointer belongs to the caller and must be freed when done with it.
254+ LIBSESSION_EXPORT contacts_blinded_contact_list * contacts_blinded (const config_object * conf );
255+
256+ /// API: contacts/contacts_get_blinded_contact
257+ ///
258+ /// Fills `blinded_contact` with the blinded contact info given a blinded session ID (specified as a
259+ /// null-terminated hex string), if the blinded contact exists, and returns true. If the contact
260+ /// does not exist then `blinded_contact` is left unchanged and false is returned.
261+ ///
262+ /// Declaration:
263+ /// ```cpp
264+ /// BOOL contacts_get_blinded_contact(
265+ /// [in] config_object* conf,
266+ /// [in] const char* blinded_id,
267+ /// [in] bool legacy_blinding,
268+ /// [out] contacts_blinded_contact* blinded_contact
269+ /// );
270+ /// ```
271+ ///
272+ /// Inputs:
273+ /// - `conf` -- [in] Pointer to the config object
274+ /// - `blinded_id` -- [in] null terminated hex string
275+ /// - `legacy_blinding` -- [in] null terminated hex string
276+ /// - `blinded_contact` -- [out] the blinded contact info data
277+ ///
278+ /// Output:
279+ /// - `bool` -- Returns true if blinded contact exists
280+ LIBSESSION_EXPORT bool contacts_get_blinded (
281+ config_object * conf ,
282+ const char * blinded_id ,
283+ bool legacy_blinding ,
284+ contacts_blinded_contact * blinded_contact ) LIBSESSION_WARN_UNUSED ;
285+
286+ /// API: contacts/contacts_get_or_construct_blinded
287+ ///
288+ /// Same as the above `contacts_get_blinded()` except that when the blinded contact does not exist,
289+ /// this sets all the contact fields to defaults and loads it with the given blinded_id.
290+ ///
291+ /// Returns true as long as it is given a valid blinded_id. A false return is considered an error,
292+ /// and means the blinded_id was not a valid blinded_id.
293+ ///
294+ /// This is the method that should usually be used to create or update a blinded contact, followed
295+ /// by setting fields in the blinded contact, and then giving it to contacts_set_blinded().
296+ ///
297+ /// Declaration:
298+ /// ```cpp
299+ /// BOOL contacts_get_or_construct_blinded(
300+ /// [in] config_object* conf,
301+ /// [in] const char* community_base_url,
302+ /// [in] const char* community_pubkey_hex,
303+ /// [in] const char* blinded_id,
304+ /// [in] bool legacy_blinding,
305+ /// [out] contacts_blinded_contact* blinded_contact
306+ /// );
307+ /// ```
308+ ///
309+ /// Inputs:
310+ /// - `conf` -- [in] Pointer to the config object
311+ /// - `community_base_url` -- [in] null terminated string
312+ /// - `community_pubkey_hex` -- [in] null terminated hex string
313+ /// - `blinded_id` -- [in] null terminated hex string
314+ /// - `legacy_blinding` -- [in] null terminated hex string
315+ /// - `blinded_contact` -- [out] the blinded contact info data
316+ ///
317+ /// Output:
318+ /// - `bool` -- Returns true if contact exsts
319+ LIBSESSION_EXPORT bool contacts_get_or_construct_blinded (
320+ config_object * conf ,
321+ const char * community_base_url ,
322+ const char * community_pubkey_hex ,
323+ const char * blinded_id ,
324+ bool legacy_blinding ,
325+ contacts_blinded_contact * blinded_contact ) LIBSESSION_WARN_UNUSED ;
326+
327+ /// API: contacts/contacts_set_blinded
328+ ///
329+ /// Adds or updates a blinded contact from the given contact info struct.
330+ ///
331+ /// Declaration:
332+ /// ```cpp
333+ /// BOOL contacts_set_blinded_contact(
334+ /// [in] config_object* conf,
335+ /// [in] contacts_blinded_contact* bc
336+ /// );
337+ /// ```
338+ ///
339+ /// Inputs:
340+ /// - `conf` -- [in] Pointer to the config object
341+ /// - `blinded_contact` -- [in] the blinded contact info data
342+ ///
343+ /// Output:
344+ /// - `bool` -- Returns true if the call succeeds, false if an error occurs.
345+ LIBSESSION_EXPORT bool contacts_set_blinded (
346+ config_object * conf , const contacts_blinded_contact * bc );
347+
348+ /// API: contacts/contacts_erase_blinded
349+ ///
350+ /// Erases a blinded contact from the blinded contact list. blinded_id is in hex. Returns true if
351+ /// the blinded contact was found and removed, false if the blinded contact was not present.
352+ ///
353+ /// Declaration:
354+ /// ```cpp
355+ /// BOOL contacts_erase_blinded(
356+ /// [in, out] config_object* conf,
357+ /// [in] const char* community_base_url,
358+ /// [in] const char* blinded_id,
359+ /// [in] bool legacy_blinding
360+ /// );
361+ /// ```
362+ ///
363+ /// Inputs:
364+ /// - `conf` -- [in, out] Pointer to the config object
365+ /// - `base_url` -- [in] Text containing null terminated base url for the community this blinded
366+ /// contact originated from
367+ /// - `blinded_id` -- [in] Text containing null terminated hex string
368+ /// - `legacy_blinding` -- [in] Flag indicating whether this blinded contact used legacy blinding
369+ ///
370+ /// Outputs:
371+ /// - `bool` -- True if erasing was successful
372+ LIBSESSION_EXPORT bool contacts_erase_blinded_contact (
373+ config_object * conf ,
374+ const char * community_base_url ,
375+ const char * blinded_id ,
376+ bool legacy_blinding );
377+
211378typedef struct contacts_iterator {
212379 void * _internals ;
213380} contacts_iterator ;
0 commit comments