Skip to content

Commit 1004da7

Browse files
committed
Missed a legacy_blinding flag
1 parent e7eed21 commit 1004da7

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

include/session/config/contacts.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ LIBSESSION_EXPORT bool contacts_set_blinded(
350350
/// BOOL contacts_erase_blinded(
351351
/// [in, out] config_object* conf,
352352
/// [in] const char* community_base_url,
353-
/// [in] const char* blinded_id,
354-
/// [in] bool legacy_blinding
353+
/// [in] const char* blinded_id
355354
/// );
356355
/// ```
357356
///
@@ -365,10 +364,7 @@ LIBSESSION_EXPORT bool contacts_set_blinded(
365364
/// Outputs:
366365
/// - `bool` -- True if erasing was successful
367366
LIBSESSION_EXPORT bool contacts_erase_blinded_contact(
368-
config_object* conf,
369-
const char* community_base_url,
370-
const char* blinded_id,
371-
bool legacy_blinding);
367+
config_object* conf, const char* community_base_url, const char* blinded_id);
372368

373369
typedef struct contacts_iterator {
374370
void* _internals;

include/session/config/contacts.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,10 @@ class Contacts : public ConfigBase {
530530
/// Inputs:
531531
/// - `base_url` -- the base url for the community this blinded contact originated from
532532
/// - `blinded_id` -- hex string of the blinded id
533-
/// - `legacy_blinding` -- flag indicating whether `blinded_id` is using legacy blinding
534533
///
535534
/// Outputs:
536535
/// - `bool` - Returns true if contact was found and removed, false otherwise
537-
bool erase_blinded(
538-
std::string_view base_url, std::string_view blinded_id, bool legacy_blinding);
536+
bool erase_blinded(std::string_view base_url, std::string_view blinded_id);
539537

540538
struct iterator;
541539
/// API: contacts/contacts::begin

src/config/contacts.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,13 @@ void Contacts::set_blinded(const blinded_contact_info& bc) {
479479
set_ts(info["j"], bc.created);
480480
}
481481

482-
bool Contacts::erase_blinded(
483-
std::string_view base_url_, std::string_view blinded_id, bool legacy_blinding) {
484-
check_session_id(blinded_id, legacy_blinding ? "15" : "25");
482+
bool Contacts::erase_blinded(std::string_view base_url_, std::string_view blinded_id) {
483+
auto prefix = get_session_id_prefix(blinded_id);
484+
485+
if (prefix != session::SessionIDPrefix::community_blinded &&
486+
prefix != session::SessionIDPrefix::community_blinded_legacy)
487+
throw std::invalid_argument{
488+
"Invalid blinded ID: Expected '15' or '25' prefix; got " + std::string{blinded_id}};
485489

486490
auto base_url = community::canonical_url(base_url_);
487491
auto pk = std::string(blinded_id.substr(2));
@@ -679,13 +683,9 @@ LIBSESSION_C_API bool contacts_set_blinded(
679683
}
680684

681685
LIBSESSION_C_API bool contacts_erase_blinded(
682-
config_object* conf,
683-
const char* community_base_url,
684-
const char* blinded_id,
685-
bool legacy_blinding) {
686+
config_object* conf, const char* community_base_url, const char* blinded_id) {
686687
try {
687-
return unbox<Contacts>(conf)->erase_blinded(
688-
community_base_url, blinded_id, legacy_blinding);
688+
return unbox<Contacts>(conf)->erase_blinded(community_base_url, blinded_id);
689689
} catch (...) {
690690
return false;
691691
}

tests/test_config_contacts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ TEST_CASE("Contacts", "[config][blinded_contacts]") {
10161016
// Conflict! Oh no!
10171017

10181018
// On client 1 delete a contact:
1019-
CHECK(contacts.erase_blinded(comm_base_url, definitely_real_id, true));
1019+
CHECK(contacts.erase_blinded(comm_base_url, definitely_real_id));
10201020

10211021
// Client 2 adds a new friend:
10221022
auto third_id = "152222222222222222222222222222222222222222222222222222222222222222"sv;

0 commit comments

Comments
 (0)