Changeset View
Changeset View
Standalone View
Standalone View
src/client/device-list-tracker.cpp
| Show All 21 Lines | |||||
| namespace Kazv | namespace Kazv | ||||
| { | { | ||||
| static bool cryptographicallyEqual(DeviceKeyInfo a, DeviceKeyInfo b) | static bool cryptographicallyEqual(DeviceKeyInfo a, DeviceKeyInfo b) | ||||
| { | { | ||||
| a.displayName = std::nullopt; | a.displayName = std::nullopt; | ||||
| b.displayName = std::nullopt; | b.displayName = std::nullopt; | ||||
| a.trustLevel = Unseen; | a.trustLevel = Unseen; | ||||
| b.trustLevel = Unseen; | b.trustLevel = Unseen; | ||||
| a.deleted = false; | |||||
| b.deleted = false; | |||||
| return std::move(a) == std::move(b); | return std::move(a) == std::move(b); | ||||
| } | } | ||||
| static bool cryptographicallyEqual(const DeviceListTracker::DeviceMapT &a, const DeviceListTracker::DeviceMapT &b) | static bool cryptographicallyEqual(const DeviceListTracker::DeviceMapT &a, const DeviceListTracker::DeviceMapT &b) | ||||
| { | { | ||||
| auto changed = false; | auto changed = false; | ||||
| auto markChanged = [&changed](const auto &) { changed = true; }; | auto markChanged = [&changed](const auto &) { changed = true; }; | ||||
| immer::diff(a, b, immer::make_differ( | immer::diff(a, b, immer::make_differ( | ||||
| ▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | bool DeviceListTracker::addDevice(std::string userId, std::string deviceId, Api::QueryKeysJob::DeviceInformation deviceInfo) | ||||
| return true; | return true; | ||||
| } | } | ||||
| void DeviceListTracker::addVerifiedDeviceKeyInfo(std::string userId, std::string deviceId, DeviceKeyInfo info) | void DeviceListTracker::addVerifiedDeviceKeyInfo(std::string userId, std::string deviceId, DeviceKeyInfo info) | ||||
| { | { | ||||
| deviceLists = std::move(deviceLists) | deviceLists = std::move(deviceLists) | ||||
| .update(userId, [=](auto deviceMap) { | .update(userId, [=](auto deviceMap) { | ||||
| return std::move(deviceMap).set(deviceId, info); | |||||
| }); | |||||
| } | |||||
| void DeviceListTracker::markDeviceAsDeleted(std::string userId, std::string deviceId) | |||||
| { | |||||
| deviceLists = std::move(deviceLists) | |||||
| .update(userId, [=](auto deviceMap) { | |||||
| auto info = deviceMap[deviceId]; | |||||
| info.deleted = true; | |||||
| return std::move(deviceMap).set(deviceId, info); | return std::move(deviceMap).set(deviceId, info); | ||||
| }); | }); | ||||
| } | } | ||||
| void DeviceListTracker::markUpToDate(std::string userId) | void DeviceListTracker::markUpToDate(std::string userId) | ||||
| { | { | ||||
| usersToTrackDeviceLists = std::move(usersToTrackDeviceLists).set(userId, false); | usersToTrackDeviceLists = std::move(usersToTrackDeviceLists).set(userId, false); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines | |||||