From 05082cb2bb59ebbf096be2e2d50c518d1a9ae4b6 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Wed, 14 Jun 2023 17:53:25 +0200 Subject: [PATCH] Consider live location beacon timeouts for their --- src/models/livelocationsmodel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/models/livelocationsmodel.cpp b/src/models/livelocationsmodel.cpp index 61e1587b7..4fed3b275 100644 --- a/src/models/livelocationsmodel.cpp +++ b/src/models/livelocationsmodel.cpp @@ -76,8 +76,15 @@ QVariant LiveLocationsModel::data(const QModelIndex &index, int roleName) const return data.beaconInfo["org.matrix.msc3488.asset"_ls].toObject()["type"].toString(); case AuthorRole: return m_room->getUser(data.senderId); - case IsLiveRole: - return data.beaconInfo["live"_ls].toBool(); + case IsLiveRole: { + if (!data.beaconInfo["live"_ls].toBool()) { + return false; + } + // TODO Qt6: port to toInteger(), timestamps are in ms since epoch, ie. 64 bit values + const auto lastTs = std::max(data.beaconInfo.value("org.matrix.msc3488.ts"_ls).toDouble(), data.beacon.value("org.matrix.msc3488.ts"_ls).toDouble()); + const auto timeout = data.beaconInfo.value("timeout"_ls).toDouble(600000); + return lastTs + timeout >= QDateTime::currentDateTime().toMSecsSinceEpoch(); + } } return {};