diff --git a/src/core/core.cpp b/src/core/core.cpp index 36d05d589..9ba8add83 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -573,9 +573,15 @@ void Core::acceptFriendRequest(const QString& userId) void Core::requestFriendship(const QString& friendAddress, const QString& message) { + ToxId friendToxId(friendAddress); const QString userId = friendAddress.mid(0, TOX_PUBLIC_KEY_SIZE * 2); - if (message.isEmpty()) + if (!friendToxId.isValid()) + { + emit failedToAddFriend(userId, + tr("Invalid Tox ID")); + } + else if (message.isEmpty()) { emit failedToAddFriend(userId, tr("You need to write a message with your request")); } @@ -583,7 +589,7 @@ void Core::requestFriendship(const QString& friendAddress, const QString& messag { emit failedToAddFriend(userId, tr("Your message is too long!")); } - else if (hasFriendWithAddress(friendAddress)) + else if (hasFriendWithAddress(userId)) { emit failedToAddFriend(userId, tr("Friend is already added")); } @@ -602,7 +608,7 @@ void Core::requestFriendship(const QString& friendAddress, const QString& messag { qDebug() << "Requested friendship of "<(toxId.constData()); + if(isValid()) + { + return reinterpret_cast(toxId.constData()); + } + + return nullptr; } /** diff --git a/src/nexus.cpp b/src/nexus.cpp index 7512124e4..0f8c4aa29 100644 --- a/src/nexus.cpp +++ b/src/nexus.cpp @@ -100,7 +100,6 @@ void Nexus::start() qRegisterMetaType("ToxFile::FileDirection"); qRegisterMetaType>("std::shared_ptr"); qRegisterMetaType("ToxId"); - qRegisterMetaType("ToxKey"); loginScreen = new LoginScreen();