@@ -169,13 +169,13 @@ blinded_contact_info::blinded_contact_info(
169169 std::string_view blinded_id,
170170 std::span<const unsigned char > pubkey,
171171 bool legacy_blinding) :
172- legacy_blinding{legacy_blinding },
173- community (std::move(base_url), blinded_id.substr( 2 ), std::move(pubkey)) {
172+ comm{ community ( std::move (base_url), blinded_id. substr ( 2 ), std::move (pubkey)) },
173+ legacy_blinding{legacy_blinding} {
174174 check_session_id (blinded_id, legacy_blinding ? " 15" : " 25" );
175175}
176176
177177const std::string blinded_contact_info::session_id () const {
178- return " {}{}" _format (legacy_blinding ? " 15" : " 25" , room ());
178+ return " {}{}" _format (legacy_blinding ? " 15" : " 25" , comm. room ());
179179}
180180
181181void blinded_contact_info::set_name (std::string n) {
@@ -185,6 +185,22 @@ void blinded_contact_info::set_name(std::string n) {
185185 name = std::move (n);
186186}
187187
188+ void blinded_contact_info::set_base_url (std::string_view base_url) {
189+ comm.set_base_url (base_url);
190+ }
191+
192+ void blinded_contact_info::set_room (std::string_view room) {
193+ comm.set_room (room);
194+ }
195+
196+ void blinded_contact_info::set_pubkey (std::span<const unsigned char > pubkey) {
197+ comm.set_pubkey (pubkey);
198+ }
199+
200+ void blinded_contact_info::set_pubkey (std::string_view pubkey) {
201+ comm.set_pubkey (pubkey);
202+ }
203+
188204void blinded_contact_info::load (const dict& info_dict) {
189205 name = maybe_string (info_dict, " n" ).value_or (" " );
190206
@@ -201,12 +217,12 @@ void blinded_contact_info::load(const dict& info_dict) {
201217}
202218
203219void blinded_contact_info::into (contacts_blinded_contact& c) const {
204- copy_c_str (c.base_url , base_url ());
220+ copy_c_str (c.base_url , comm. base_url ());
205221 c.session_id [0 ] = (legacy_blinding ? ' 1' : ' 2' );
206222 c.session_id [1 ] = ' 5' ;
207223 std::memcpy (c.session_id + 2 , session_id ().data (), 64 );
208224 c.session_id [66 ] = ' \0 ' ;
209- std::memcpy (c.pubkey , pubkey ().data (), 32 );
225+ std::memcpy (c.pubkey , comm. pubkey ().data (), 32 );
210226 copy_c_str (c.name , name);
211227 if (profile_picture) {
212228 copy_c_str (c.profile_pic .url , profile_picture.url );
@@ -218,8 +234,8 @@ void blinded_contact_info::into(contacts_blinded_contact& c) const {
218234 c.created = to_epoch_seconds (created);
219235}
220236
221- blinded_contact_info::blinded_contact_info (const contacts_blinded_contact& c) :
222- community(c.base_url, {c.session_id + 2 , 64 }, c.pubkey) {
237+ blinded_contact_info::blinded_contact_info (const contacts_blinded_contact& c) {
238+ comm = community (c.base_url , {c.session_id + 2 , 64 }, c.pubkey );
223239 assert (std::strlen (c.name ) <= contact_info::MAX_NAME_LENGTH);
224240 name = c.name ;
225241 assert (std::strlen (c.profile_pic .url ) <= profile_pic::MAX_URL_LENGTH);
@@ -374,14 +390,14 @@ size_t Contacts::size() const {
374390
375391ConfigBase::DictFieldProxy Contacts::blinded_contact_field (
376392 const blinded_contact_info& bc, std::span<const unsigned char >* get_pubkey) const {
377- auto record = data[" b" ][bc.base_url ()];
393+ auto record = data[" b" ][bc.comm . base_url ()];
378394 if (get_pubkey) {
379395 auto pkrec = record[" #" ];
380396 if (auto pk = pkrec.string_view_or (" " ); pk.size () == 32 )
381397 *get_pubkey = std::span<const unsigned char >{
382398 reinterpret_cast <const unsigned char *>(pk.data ()), pk.size ()};
383399 }
384- return record[" R" ][bc.room ()]; // The `room` value is the blinded id without the prefix
400+ return record[" R" ][bc.comm . room ()]; // The `room` value is the blinded id without the prefix
385401}
386402
387403using any_blinded_contact = std::variant<blinded_contact_info>;
@@ -395,7 +411,7 @@ std::optional<blinded_contact_info> Contacts::get_blinded(
395411 std::shared_ptr<any_blinded_contact> val;
396412
397413 while (!comm.done ()) {
398- if (comm.load <blinded_contact_info>(val)) // TODO: This is untested
414+ if (comm.load <blinded_contact_info>(val))
399415 if (auto * ptr = std::get_if<blinded_contact_info>(val.get ());
400416 ptr && ptr->session_id () == pubkey_hex)
401417 return *ptr;
@@ -425,7 +441,7 @@ std::vector<blinded_contact_info> Contacts::blinded_contacts() const {
425441}
426442
427443bool Contacts::set_blinded_contact (const blinded_contact_info& bc) {
428- data[" b" ][bc.base_url ()][" #" ] = bc.pubkey ();
444+ data[" b" ][bc.comm . base_url ()][" #" ] = bc. comm .pubkey ();
429445 auto info = blinded_contact_field (bc); // data["b"][base]["R"][bc_session_id_without_prefix]
430446
431447 // Always set the name, even if empty, to keep the dict from getting pruned if there are no
0 commit comments