Skip to content

Commit c73fd92

Browse files
authored
Merge pull request #67 from mpretty-cyro/feature/disable-profile-updated-timestamp
Disabled the "profile_updated" timestamp updating logic
2 parents 5e3835b + ea7627e commit c73fd92

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
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.5
20+
VERSION 1.5.6
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" : "T");
33-
data[target_timestamp] = ts_now();
32+
// const auto target_timestamp = (data["t"].integer_or(0) >= data["T"].integer_or(0) ? "t" :
33+
// "T"); 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" : "T");
104-
data[target_timestamp] = ts_now();
103+
// const auto target_timestamp = (data["t"].integer_or(0) >= data["T"].integer_or(0) ? "t" :
104+
// "T"); 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

tests/test_config_userprofile.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ 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
463464
// Reupload the "current" pic and confirm it gets returned
464465
strcpy(p.url, "testUrl");
465466
memcpy(p.key, "secret78901234567890123456789000", 32);
@@ -531,4 +532,14 @@ TEST_CASE("user profile C API", "[config][user_profile][c]") {
531532
INFO("Checking if raw_value " << raw_value << " is within the range [" << before_seconds << ", "
532533
<< after_seconds << "]");
533534
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
534545
}

0 commit comments

Comments
 (0)