From 40230a02c0630be311fb27aa68cd5e441801e67d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 2 Dec 2023 12:55:46 +0100 Subject: Accept extended identity from device attachment --- src/attach.cpp | 9 ++++----- src/identity.cpp | 2 +- src/main.cpp | 8 ++++++-- src/state.cpp | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/attach.cpp b/src/attach.cpp index 74bc875..3d351f8 100644 --- a/src/attach.cpp +++ b/src/attach.cpp @@ -34,14 +34,13 @@ void AttachService::attachTo(const Peer & peer) Stored AttachService::handlePairingComplete(const Peer & peer) { auto owner = peer.server().identity().finalOwner(); - auto id = peer.identity()->ref(); - auto prev = Stored>::load(*peer.identity()->ref()); + auto pid = peer.identity(); auto idata = peer.tempStorage().store(IdentityData { - .prev = { prev }, + .prev = pid->data(), .name = nullopt, - .owner = Stored>::load(*owner.ref()), - .keyIdentity = prev->data->keyIdentity, + .owner = owner.data()[0], + .keyIdentity = pid->keyIdentity(), .keyMessage = nullopt, }); diff --git a/src/identity.cpp b/src/identity.cpp index f2912c5..ae20b3b 100644 --- a/src/identity.cpp +++ b/src/identity.cpp @@ -145,7 +145,7 @@ bool Identity::operator!=(const Identity & other) const optional Identity::ref() const { if (p->data.size() == 1) - return p->data[0].ref(); + return p->data[0].base().ref(); return nullopt; } diff --git a/src/main.cpp b/src/main.cpp index b39130a..0eb379b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -417,8 +417,12 @@ void watchLocalIdentity(const vector &) if (idt) { ostringstream ss; ss << "local-identity"; - for (optional i = idt; i; i = i->owner()) - ss << " " << i->name().value(); + for (optional i = idt; i; i = i->owner()) { + if (auto name = i->name()) + ss << " " << i->name().value(); + else + ss << " "; + } printLine(ss.str()); } }); diff --git a/src/state.cpp b/src/state.cpp index 8e5dcad..40d4eec 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -25,9 +25,9 @@ LocalState::LocalState(const Ref & ref): p->shared.tip = rec->items("shared").as(); if (p->identity) { - vector>> updates; + vector updates; for (const auto & r : lookupShared(SharedType>::id)) - updates.push_back(Stored>::load(r)); + updates.push_back(StoredIdentityPart::load(r)); if (!updates.empty()) p->identity = p->identity->update(updates); } -- cgit v1.2.3