From 59a420a358cd74726335a21abd659b154e57a1ed Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 14 Jun 2017 13:53:50 -0700 Subject: [PATCH] Fix replicated nodes not being properly updated when logging in or changing settings --- domain-server/src/DomainServer.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 65f85215cb..dddc1c2942 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -2234,17 +2234,24 @@ void DomainServer::updateReplicatedNodes() { } auto nodeList = DependencyManager::get(); - nodeList->eachNode([&](const SharedNodePointer& otherNode) { - if (shouldReplicateNode(*otherNode)) { - qDebug() << "Setting node to replicated: " << otherNode->getUUID(); - otherNode->setIsReplicated(true); + nodeList->eachMatchingNode([this](const SharedNodePointer& otherNode) -> bool { + return otherNode->getType() == NodeType::Agent; + }, [this](const SharedNodePointer& otherNode) { + auto shouldReplicate = shouldReplicateNode(*otherNode); + auto isReplicated = otherNode->isReplicated(); + qDebug() << "Checking " << otherNode->getPermissions().getVerifiedUserName(); + if (isReplicated && !shouldReplicate) { + qDebug() << "Setting node to NOT be replicated: " << otherNode->getUUID(); + } else if (!isReplicated && shouldReplicate) { + qDebug() << "Setting node to replicated: " << otherNode->getUUID(); + } + otherNode->setIsReplicated(shouldReplicate); } - }); + ); } bool DomainServer::shouldReplicateNode(const Node& node) { QString verifiedUsername = node.getPermissions().getVerifiedUserName(); - qDebug() << "Verified username: " << verifiedUsername; auto it = find(_replicatedUsernames.cbegin(), _replicatedUsernames.cend(), verifiedUsername); return it != _replicatedUsernames.end() && node.getType() == NodeType::Agent; };