aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-02 12:21:31 +0200
committerdec05eba <dec05eba@protonmail.com>2018-05-02 12:21:34 +0200
commit4cadc32cca9e2b25d5eddb8c8001471b86406aac (patch)
tree3ead73f4411a7314bb2b96da5d5fa42823ffebdd
parentc3ab4d08bacaf5439a1d31b15f90b9445214eacc (diff)
Replace remote user with local user when added to channel
-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;
}