Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Quotient/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,21 @@ bool Connection::isKnownE2eeCapableDevice(const QString& userId, const QString&
return query.next();
}

Connection::VerificationState Connection::getDeviceVerificationState(const QString& userId,
const QString& deviceId) const
{
auto query = database()->prepareQuery(
"SELECT verified, selfVerified FROM tracked_devices WHERE deviceId=:deviceId AND matrixId=:matrixId;"_L1);
query.bindValue(":deviceId"_L1, deviceId);
query.bindValue(":matrixId"_L1, userId);
database()->execute(query);
return query.next() ? query.value("verified"_L1).toBool() ? Verified
: isUserVerified(userId) && query.value("selfVerified"_L1).toBool()
? SelfVerified
: Unverified
: NoE2EE;
}

bool Connection::hasConflictingDeviceIdsAndCrossSigningKeys(const QString& userId)
{
if (d->encryptionData) {
Expand Down
11 changes: 11 additions & 0 deletions Quotient/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ class QUOTIENT_API Connection : public QObject {
//! Returns true if this megolm session comes from a verified device
bool isVerifiedSession(const QByteArray& megolmSessionId) const;

#if Quotient_VERSION_MAJOR == 0 && Quotient_VERSION_MINOR <= 10
//! Returns whether the device is verified
bool isVerifiedDevice(const QString& userId, const QString& deviceId) const;

Expand All @@ -381,7 +382,17 @@ class QUOTIENT_API Connection : public QObject {
//! This might give unexpected results for users we're not tracking,
//! i.e., users that we don't share an encrypted room with
bool isKnownE2eeCapableDevice(const QString& userId, const QString& deviceId) const;
#endif

enum VerificationState : uint8_t { NoE2EE = 0, Unverified, SelfVerified, Verified };
Q_ENUM(VerificationState)

//! \brief Returns whether the device is E2EE-capable and verified/self-verified
//!
//! \note This may give unexpected results for users not tracked in this account,
//! e.g. users that have no common encrypted room with the current account
VerificationState getDeviceVerificationState(const QString& userId,
const QString& deviceId) const;

void sendSessionKeyToDevices(const QString& roomId,
const QOlmOutboundGroupSession& outboundSession,
Expand Down