fix hs order back to front

This commit is contained in:
Green Sky 2024-01-17 19:15:59 +01:00
parent 5227731ed3
commit e6f0127357
No known key found for this signature in database

View File

@ -257,17 +257,25 @@ bool ZoxNGCHistorySync::onEvent(const Events::ZoxNGC_ngch_request& e) {
const int64_t sync_delta_offset_ms = int64_t(e.sync_delta) * 1000 * 60; const int64_t sync_delta_offset_ms = int64_t(e.sync_delta) * 1000 * 60;
const uint64_t ts_start = Message::getTimeMS() - sync_delta_offset_ms; const uint64_t ts_start = Message::getTimeMS() - sync_delta_offset_ms;
auto view = reg.view<Message::Components::ContactFrom, Message::Components::ContactTo, Message::Components::Timestamp, Message::Components::MessageText, Message::Components::ToxGroupMessageID>(); auto view = reg.view<Message::Components::Timestamp>();
view.use<Message::Components::Timestamp>(); for (auto it = view.rbegin(), it_end = view.rend(); it != it_end; it++) {
view.each([&](const Message3 e, const auto&, const auto& c_t, const auto& ts, const auto&, const auto&) { const Message3 e = *it;
if (!reg.all_of<Message::Components::ContactFrom, Message::Components::ContactTo, Message::Components::MessageText, Message::Components::ToxGroupMessageID>(e)) {
continue; // manual view filter
}
const auto& c_t = reg.get<Message::Components::ContactTo>(e);
const auto& ts = view.get<Message::Components::Timestamp>(e);
// private // private
if (!_cr.all_of<Contact::Components::TagBig>(c_t.c)) { if (!_cr.all_of<Contact::Components::TagBig>(c_t.c)) {
return; continue;
} }
if (ts.ts < ts_start) { if (ts.ts < ts_start) {
//std::cout << "---- " << ts.ts << " < " << ts_start << " -> too old\n"; //std::cout << "---- " << ts.ts << " < " << ts_start << " -> too old\n";
return; continue;
} }
if (reg.all_of<Message::Components::SyncedBy>(e)) { if (reg.all_of<Message::Components::SyncedBy>(e)) {
@ -284,14 +292,14 @@ bool ZoxNGCHistorySync::onEvent(const Events::ZoxNGC_ngch_request& e) {
) { ) {
// self not found // self not found
// TODO: config for self only // TODO: config for self only
return; continue;
} }
} }
std::cout << "---- " << ts.ts << " >= " << ts_start << " -> selected\n"; std::cout << "---- " << ts.ts << " >= " << ts_start << " -> selected\n";
msg_send_queue.push(e); msg_send_queue.push(e);
}); }
std::cout << "ZOX ngch_request selected " << msg_send_queue.size() << " messages\n"; std::cout << "ZOX ngch_request selected " << msg_send_queue.size() << " messages\n";