Fix bad timestamps being stored for room infos

This commit is contained in:
Nicolas Werner 2022-06-28 23:18:26 +02:00
parent 7a29531739
commit b6bbbdeae7
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -1815,7 +1815,7 @@ Cache::saveState(const mtx::responses::Sync &res)
if (!std::visit([](const auto &e) -> bool { return isMessage(e); }, e)) if (!std::visit([](const auto &e) -> bool { return isMessage(e); }, e))
continue; continue;
updatedInfo.approximate_last_modification_ts = updatedInfo.approximate_last_modification_ts =
std::visit([](const auto &e) -> bool { return e.origin_server_ts; }, e); std::visit([](const auto &e) -> uint64_t { return e.origin_server_ts; }, e);
} }
roomsDb_.put(txn, room.first, nlohmann::json(updatedInfo).dump()); roomsDb_.put(txn, room.first, nlohmann::json(updatedInfo).dump());
@ -4850,6 +4850,9 @@ from_json(const nlohmann::json &j, RoomInfo &info)
info.guest_access = j.at("guest_access").get<bool>(); info.guest_access = j.at("guest_access").get<bool>();
info.approximate_last_modification_ts = j.value<uint64_t>("app_l_ts", 0); info.approximate_last_modification_ts = j.value<uint64_t>("app_l_ts", 0);
// workaround for bad values being stored in the past
if (info.approximate_last_modification_ts < 100000000000)
info.approximate_last_modification_ts = 0;
info.notification_count = j.value("notification_count", 0); info.notification_count = j.value("notification_count", 0);
info.highlight_count = j.value("highlight_count", 0); info.highlight_count = j.value("highlight_count", 0);