summary refs log tree commit diff
path: root/src/ui/UserProfile.cpp
diff options
context:
space:
mode:
authorCH Chethan Reddy <40890937+Chethan2k1@users.noreply.github.com>2020-07-18 01:46:30 +0530
committerCH Chethan Reddy <40890937+Chethan2k1@users.noreply.github.com>2020-07-30 22:10:27 +0530
commit1fcd768f88f7e84978d19283c9fa6205624f2544 (patch)
tree97afdac31c014c4eedb5d0da45362835d7c04d22 /src/ui/UserProfile.cpp
parentUpdating keys of outdated encrypted users (diff)
downloadnheko-1fcd768f88f7e84978d19283c9fa6205624f2544.tar.xz
Adding Room Key Verification Stuff
Diffstat (limited to 'src/ui/UserProfile.cpp')
-rw-r--r--src/ui/UserProfile.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp

index 6ae04d0b..3499384c 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp
@@ -6,6 +6,8 @@ #include "Utils.h" #include "mtx/responses/crypto.hpp" +#include <iostream> // only for debugging + UserProfile::UserProfile(QString roomid, QString userid, QObject *parent) : QObject(parent) , roomid_(roomid) @@ -74,6 +76,12 @@ UserProfile::avatarUrl() return cache::avatarUrl(roomid_, userid_); } +bool +UserProfile::getUserStatus() +{ + return isUserVerified; +} + void UserProfile::callback_fn(const mtx::responses::QueryKeys &res, mtx::http::RequestErr err, @@ -100,6 +108,7 @@ UserProfile::callback_fn(const mtx::responses::QueryKeys &res, // TODO: Verify signatures and ignore those that don't pass. verification::Status verified = verification::Status::UNVERIFIED; + isUserVerified = device_verified->is_user_verified; if (device_verified.has_value()) { if (std::find(device_verified->cross_verified.begin(), device_verified->cross_verified.end(), @@ -174,4 +183,29 @@ UserProfile::startChat() if (utils::localUser() != this->userid_) req.invite = {this->userid_.toStdString()}; emit ChatPage::instance()->createRoom(req); +} + +void +UserProfile::verifyUser() +{ + std::cout << "Checking if to start to device verification or room message verification" + << std::endl; + auto joined_rooms = cache::joinedRooms(); + auto room_infos = cache::getRoomInfo(joined_rooms); + + for (std::string room_id : joined_rooms) { + if ((room_infos[QString::fromStdString(room_id)].member_count == 2) && + cache::isRoomEncrypted(room_id)) { + auto room_members = cache::roomMembers(room_id); + if (std::find(room_members.begin(), + room_members.end(), + (this->userid()).toStdString()) != room_members.end()) { + std::cout << "FOUND A ENCRYPTED ROOM WITH THIS USER : " << room_id + << std::endl; + return; + } + } + } + + std::cout << "DIDN'T FIND A ENCRYPTED ROOM WITH THIS USER" << std::endl; } \ No newline at end of file