aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6286884..014c9ff 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -162,7 +162,7 @@ int main(int argc, char **argv)
}
});
- database.setOnAddUserCallback([&currentUserKeyPair, &channels, &channelMessageMutex, &waitingToJoin](const odhtdb::DatabaseAddUserRequest &request)
+ database.setOnAddUserCallback([&currentUserKeyPair, &channels, &channelMessageMutex, &waitingToJoin, &database](const odhtdb::DatabaseAddUserRequest &request)
{
lock_guard<recursive_mutex> lock(channelMessageMutex);
printf("Add user callback. Channel to add user to: %s\n", request.nodeHash->toString().c_str());
@@ -174,8 +174,11 @@ int main(int argc, char **argv)
printf("Add user to one of my channels\n");
if(currentUserKeyPair && request.userToAdd->getPublicKey() == currentUserKeyPair->getPublicKey() && channel->getLocalUser()->type != User::Type::ONLINE)
{
+ // Replace remote user with local user, if we are the remote user
+ database.getStorage().getLocalNodeUsers(*currentUserKeyPair);
+ auto userToAdd = database.getStorage().getUserByPublicKey(*request.nodeHash, currentUserKeyPair->getPublicKey());
printf("You were added to channel %s by %s\n", request.nodeHash->toString().c_str(), request.creatorUser->getName().c_str());
- channel->replaceLocalUser(new OnlineUser(request.userToAdd));
+ channel->replaceLocalUser(new OnlineUser(userToAdd));
waitingToJoin = false;
return;
}