Skip to content

Commit 1fdd145

Browse files
authored
Merge pull request #68 from mpretty-cyro/feature/enable_profile_updated
Disabled the "profile_updated" timestamp updating logic
2 parents b68ae75 + c26dac7 commit 1fdd145

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if(CCACHE_PROGRAM)
1717
endif()
1818

1919
project(libsession-util
20-
VERSION 1.5.6
20+
VERSION 1.5.7
2121
DESCRIPTION "Session client utility library"
2222
LANGUAGES ${LANGS})
2323

src/config/user_profile.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ void UserProfile::set_name(std::string_view new_name) {
2929
throw std::invalid_argument{"Invalid profile name: exceeds maximum length"};
3030
set_nonempty_str(data["n"], new_name);
3131

32-
// const auto target_timestamp = (data["t"].integer_or(0) >= data["T"].integer_or(0) ? "t" :
33-
// "T"); data[target_timestamp] = ts_now();
32+
const auto target_timestamp = (data["t"].integer_or(0) >= data["T"].integer_or(0) ? "t" : "T");
33+
data[target_timestamp] = ts_now();
3434
}
3535
void UserProfile::set_name_truncated(std::string new_name) {
3636
set_name(utf8_truncate(std::move(new_name), contact_info::MAX_NAME_LENGTH));
@@ -59,7 +59,7 @@ void UserProfile::set_profile_pic(std::string_view url, std::span<const unsigned
5959
if (url.empty() || key.size() != 32)
6060
set_reupload_profile_pic({});
6161

62-
// data["t"] = ts_now();
62+
data["t"] = ts_now();
6363
}
6464

6565
void UserProfile::set_profile_pic(profile_pic pic) {
@@ -69,7 +69,7 @@ void UserProfile::set_profile_pic(profile_pic pic) {
6969
void UserProfile::set_reupload_profile_pic(
7070
std::string_view url, std::span<const unsigned char> key) {
7171
set_pair_if(!url.empty() && key.size() == 32, data["P"], url, data["Q"], key);
72-
// data["T"] = ts_now();
72+
data["T"] = ts_now();
7373
}
7474

7575
void UserProfile::set_reupload_profile_pic(profile_pic pic) {
@@ -100,8 +100,8 @@ void UserProfile::set_blinded_msgreqs(std::optional<bool> value) {
100100
else
101101
data["M"] = static_cast<int>(*value);
102102

103-
// const auto target_timestamp = (data["t"].integer_or(0) >= data["T"].integer_or(0) ? "t" :
104-
// "T"); data[target_timestamp] = ts_now();
103+
const auto target_timestamp = (data["t"].integer_or(0) >= data["T"].integer_or(0) ? "t" : "T");
104+
data[target_timestamp] = ts_now();
105105
}
106106

107107
std::optional<bool> UserProfile::get_blinded_msgreqs() const {
@@ -111,11 +111,11 @@ std::optional<bool> UserProfile::get_blinded_msgreqs() const {
111111
}
112112

113113
std::chrono::sys_seconds UserProfile::get_profile_updated() const {
114-
// if (auto t = data["t"].sys_seconds()) {
115-
// if (auto T = data["T"].sys_seconds(); T && *T > *t)
116-
// return *T;
117-
// return *t;
118-
// }
114+
if (auto t = data["t"].sys_seconds()) {
115+
if (auto T = data["T"].sys_seconds(); T && *T > *t)
116+
return *T;
117+
return *t;
118+
}
119119
return std::chrono::sys_seconds{};
120120
}
121121

src/session_network.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,10 @@ size_t Network::min_snode_cache_size() const {
821821
// having issues) then the minimum size should be the full cache size (minus enough to build a
822822
// path) or at least the size of a path
823823
auto min_path_size = static_cast<size_t>(path_size);
824+
825+
if (use_testnet)
826+
return min_path_size;
827+
824828
return std::min(
825829
std::max(min_path_size, *seed_node_cache_size - min_path_size), min_snode_cache_count);
826830
}

tests/test_config_userprofile.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ TEST_CASE("user profile C API", "[config][user_profile][c]") {
460460
CHECK(session::to_vector(std::span<const unsigned char>{pic.key, 32}) ==
461461
"qwert\0yuio1234567890123456789012"_bytes);
462462

463-
#if 0
464463
// Reupload the "current" pic and confirm it gets returned
465464
strcpy(p.url, "testUrl");
466465
memcpy(p.key, "secret78901234567890123456789000", 32);
@@ -532,14 +531,4 @@ TEST_CASE("user profile C API", "[config][user_profile][c]") {
532531
INFO("Checking if raw_value " << raw_value << " is within the range [" << before_seconds << ", "
533532
<< after_seconds << "]");
534533
CHECK((raw_value >= before_seconds && raw_value <= after_seconds));
535-
#else
536-
// Ensure the timestamp doesn't get updated
537-
strcpy(p.url, "testUrl");
538-
memcpy(p.key, "secret78901234567890123456789000", 32);
539-
CHECK(0 == user_profile_set_reupload_pic(conf, p));
540-
CHECK(0 == user_profile_set_pic(conf, p));
541-
CHECK(0 == user_profile_set_name(conf, "Test"));
542-
user_profile_set_blinded_msgreqs(conf, 1);
543-
CHECK(user_profile_get_profile_updated(conf) == 0);
544-
#endif
545534
}

0 commit comments

Comments
 (0)