From e4b5eb30af94991e19ac324d5e6ec616e6a71d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 3 Dec 2023 22:52:26 +0100 Subject: Contacts with extended identity --- src/contact.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/contact.cpp') diff --git a/src/contact.cpp b/src/contact.cpp index 01aa710..9ab5699 100644 --- a/src/contact.cpp +++ b/src/contact.cpp @@ -91,7 +91,7 @@ Digest Contact::leastRoot() const void Contact::Priv::init() { std::call_once(initFlag, [this]() { - vector>> idata; + vector idata; for (const auto & c : findPropertyComponents(data, "identity")) for (const auto & i : c->identity) idata.push_back(i); @@ -111,9 +111,13 @@ ContactData ContactData::load(const Ref & ref) if (!rec) return ContactData(); + vector identity; + for (const auto & r : rec->items("identity").asRef()) + identity.push_back(StoredIdentityPart::load(r)); + return ContactData { .prev = rec->items("PREV").as(), - .identity = rec->items("identity").as>(), + .identity = move(identity), .name = rec->item("name").asText(), }; } @@ -125,7 +129,7 @@ Ref ContactData::store(const Storage & st) const for (const auto & prev : prev) items.emplace_back("PREV", prev.ref()); for (const auto & idt : identity) - items.emplace_back("identity", idt); + items.emplace_back("identity", idt.ref()); if (name) items.emplace_back("name", *name); @@ -155,7 +159,7 @@ Stored ContactService::handlePairingComplete(const Peer & peer) server.localHead().update([&] (const Stored & local) { auto cdata = local.ref().storage().store(ContactData { .prev = {}, - .identity = peer.identity()->finalOwner().data(), + .identity = peer.identity()->finalOwner().extData(), .name = std::nullopt, }); @@ -176,7 +180,7 @@ void ContactService::handlePairingResult(Context & ctx, Stored) { auto cdata = ctx.local().ref().storage().store(ContactData { .prev = {}, - .identity = ctx.peer().identity()->finalOwner().data(), + .identity = ctx.peer().identity()->finalOwner().extData(), .name = std::nullopt, }); -- cgit v1.2.3