diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2023-12-02 12:55:46 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2023-12-02 13:15:58 +0100 |
commit | 40230a02c0630be311fb27aa68cd5e441801e67d (patch) | |
tree | ecebdb9c04c127e6f82e5dda9d41ce535ec0923a | |
parent | f097f6473095fa04ff52ac7ee33a8dc435144a6f (diff) |
Accept extended identity from device attachment
-rw-r--r-- | src/attach.cpp | 9 | ||||
-rw-r--r-- | src/identity.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 8 | ||||
-rw-r--r-- | 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<AttachIdentity> AttachService::handlePairingComplete(const Peer & peer) { auto owner = peer.server().identity().finalOwner(); - auto id = peer.identity()->ref(); - auto prev = Stored<Signed<IdentityData>>::load(*peer.identity()->ref()); + auto pid = peer.identity(); auto idata = peer.tempStorage().store(IdentityData { - .prev = { prev }, + .prev = pid->data(), .name = nullopt, - .owner = Stored<Signed<IdentityData>>::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<Ref> 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<string> &) if (idt) { ostringstream ss; ss << "local-identity"; - for (optional<Identity> i = idt; i; i = i->owner()) - ss << " " << i->name().value(); + for (optional<Identity> i = idt; i; i = i->owner()) { + if (auto name = i->name()) + ss << " " << i->name().value(); + else + ss << " <unnamed>"; + } 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<SharedData>(); if (p->identity) { - vector<Stored<Signed<IdentityData>>> updates; + vector<StoredIdentityPart> updates; for (const auto & r : lookupShared(SharedType<optional<Identity>>::id)) - updates.push_back(Stored<Signed<IdentityData>>::load(r)); + updates.push_back(StoredIdentityPart::load(r)); if (!updates.empty()) p->identity = p->identity->update(updates); } |