Commit 9c909cae authored by Matthieu Tanon's avatar Matthieu Tanon

Remove useless server-side code for encrypted chatrooms

parent 3308fe27
......@@ -108,9 +108,7 @@ static void call_received(SalCallOp *h) {
h->release();
return;
}
string endToEndEncrypted = L_C_TO_STRING(sal_custom_header_find(h->getRecvCustomHeaders(), "End-To-End-Encrypted"));
bool encrypted = (endToEndEncrypted == "true");
IdentityAddress confAddr = L_GET_PRIVATE_FROM_C_OBJECT(lc)->mainDb->findOneToOneConferenceChatRoomAddress(from, identAddresses.front(), encrypted);
IdentityAddress confAddr = L_GET_PRIVATE_FROM_C_OBJECT(lc)->mainDb->findOneToOneConferenceChatRoomAddress(from, identAddresses.front());
if (confAddr.isValid()) {
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(ConferenceId(confAddr, confAddr));
L_GET_PRIVATE(static_pointer_cast<ServerGroupChatRoom>(chatRoom))->confirmRecreation(h);
......@@ -852,10 +850,8 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
ConferenceId(addr, IdentityAddress(op->getTo()))
);
if (!chatRoom) {
bool encrypted = false;
chatRoom = L_GET_PRIVATE_FROM_C_OBJECT(lc)->createClientGroupChatRoom("", addr.asString(), Content(), false, encrypted);
}
if (!chatRoom)
chatRoom = L_GET_PRIVATE_FROM_C_OBJECT(lc)->createClientGroupChatRoom("", addr.asString(), Content(), false, false);
chatRoom->join();
static_cast<SalReferOp *>(op)->reply(SalReasonNone);
return;
......
......@@ -485,8 +485,7 @@ void ServerGroupChatRoomPrivate::addCompatibleParticipants (const IdentityAddres
q->addParticipants(compatibleParticipants, nullptr, false);
if ((capabilities & ServerGroupChatRoom::Capabilities::OneToOne) && (q->getParticipantCount() == 2)) {
// Insert the one-to-one chat room in Db if participants count is 2.
bool encrypted = (capabilities & ServerGroupChatRoom::Capabilities::Encrypted);
q->getCore()->getPrivate()->mainDb->insertOneToOneConferenceChatRoom(q->getSharedFromThis(), encrypted);
q->getCore()->getPrivate()->mainDb->insertOneToOneConferenceChatRoom(q->getSharedFromThis());
}
}
}
......
......@@ -41,7 +41,7 @@ class EncryptionEngine : public CoreAccessor {
public:
enum class EngineType {
Undefined = -1,
LimeX3DH = 0,
LimeX3dh = 0,
};
virtual ~EncryptionEngine () = default;
......
......@@ -123,7 +123,7 @@ LimeX3dhEncryptionEngine::LimeX3dhEncryptionEngine (
belle_http_provider_t *prov,
const shared_ptr<Core> core
) : EncryptionEngine(core) {
engineType = EncryptionEngine::EngineType::LimeX3DH;
engineType = EncryptionEngine::EngineType::LimeX3dh;
curve = lime::CurveId::c25519; // c448
_dbAccess = dbAccess;
auto cCore = core->getCCore();
......@@ -799,7 +799,8 @@ void LimeX3dhEncryptionEngine::onRegistrationStateChanged (
lastLimeUpdate = ms_time(NULL);
lp_config_set_int(lpconfig, "lime", "last_update_time", (int)lastLimeUpdate);
} catch (const exception &e) {
lInfo() << e.what() << " while creating lime user";
// lInfo() << e.what() << " while creating lime user";
lInfo() << "LIME X3DH user already exists or the creation went wrong";
// update keys if necessary
int limeUpdateThreshold = lp_config_get_int(lpconfig, "lime", "lime_update_threshold", 86400); // 24 hours = 86400 s
......
......@@ -228,7 +228,7 @@ void Core::enableLimeX3dh (bool enable) {
bool Core::limeX3dhEnabled () const {
L_D();
if (d->imee && d->imee->getEngineType() == EncryptionEngine::EngineType::LimeX3DH)
if (d->imee && d->imee->getEngineType() == EncryptionEngine::EngineType::LimeX3dh)
return true;
return false;
}
......
......@@ -78,7 +78,6 @@ namespace Statements {
FROM one_to_one_chat_room
WHERE participant_a_sip_address_id IN (:1, :2)
AND participant_b_sip_address_id IN (:3, :4)
AND (capabilities & :5) = :6
)",
/* SelectConferenceEvent */ R"(
......
......@@ -68,7 +68,7 @@ private:
long long selectChatRoomId (long long peerSipAddressId, long long localSipAddressId) const;
long long selectChatRoomId (const ConferenceId &conferenceId) const;
long long selectChatRoomParticipantId (long long chatRoomId, long long participantSipAddressId) const;
long long selectOneToOneChatRoomId (long long sipAddressIdA, long long sipAddressIdB, bool encrypted) const;
long long selectOneToOneChatRoomId (long long sipAddressIdA, long long sipAddressIdB) const;
void deleteContents (long long chatMessageId);
void deleteChatRoomParticipant (long long chatRoomId, long long participantSipAddressId);
......
......@@ -480,16 +480,13 @@ long long MainDbPrivate::selectChatRoomParticipantId (long long chatRoomId, long
return session->got_data() ? id : -1;
}
long long MainDbPrivate::selectOneToOneChatRoomId (long long sipAddressIdA, long long sipAddressIdB, bool encrypted) const {
long long MainDbPrivate::selectOneToOneChatRoomId (long long sipAddressIdA, long long sipAddressIdB) const {
long long id;
const int encryptedCapability = int(ChatRoom::Capabilities::Encrypted);
const int expectedCapabilities = encrypted ? encryptedCapability : 0;
soci::session *session = dbSession.getBackendSession();
*session << Statements::get(Statements::SelectOneToOneChatRoomId),
soci::use(sipAddressIdA), soci::use(sipAddressIdB),
soci::use(sipAddressIdA), soci::use(sipAddressIdB),
soci::use(encryptedCapability), soci::use(expectedCapabilities),
soci::into(id);
return session->got_data() ? id : -1;
......@@ -2756,8 +2753,7 @@ IdentityAddress MainDb::findMissingOneToOneConferenceChatRoomParticipantAddress
IdentityAddress MainDb::findOneToOneConferenceChatRoomAddress (
const IdentityAddress &participantA,
const IdentityAddress &participantB,
bool encrypted
const IdentityAddress &participantB
) const {
return L_DB_TRANSACTION {
L_D();
......@@ -2767,7 +2763,7 @@ IdentityAddress MainDb::findOneToOneConferenceChatRoomAddress (
if (participantASipAddressId == -1 || participantBSipAddressId == -1)
return IdentityAddress();
const long long &chatRoomId = d->selectOneToOneChatRoomId(participantASipAddressId, participantBSipAddressId, encrypted);
const long long &chatRoomId = d->selectOneToOneChatRoomId(participantASipAddressId, participantBSipAddressId);
string chatRoomAddress;
*d->dbSession.getBackendSession() << "SELECT sip_address.value"
......@@ -2779,7 +2775,7 @@ IdentityAddress MainDb::findOneToOneConferenceChatRoomAddress (
};
}
void MainDb::insertOneToOneConferenceChatRoom (const shared_ptr<AbstractChatRoom> &chatRoom, bool encrypted) {
void MainDb::insertOneToOneConferenceChatRoom (const shared_ptr<AbstractChatRoom> &chatRoom) {
L_ASSERT(linphone_core_conference_server_enabled(chatRoom->getCore()->getCCore()));
L_ASSERT(chatRoom->getCapabilities() & ChatRoom::Capabilities::OneToOne);
......@@ -2792,7 +2788,7 @@ void MainDb::insertOneToOneConferenceChatRoom (const shared_ptr<AbstractChatRoom
L_ASSERT(participantASipAddressId != -1);
L_ASSERT(participantBSipAddressId != -1);
long long chatRoomId = d->selectOneToOneChatRoomId(participantASipAddressId, participantBSipAddressId, encrypted);
long long chatRoomId = d->selectOneToOneChatRoomId(participantASipAddressId, participantBSipAddressId);
if (chatRoomId == -1) {
chatRoomId = d->selectChatRoomId(chatRoom->getConferenceId());
*d->dbSession.getBackendSession() << Statements::get(Statements::InsertOneToOneChatRoom, getBackend()),
......
......@@ -180,10 +180,9 @@ public:
);
IdentityAddress findOneToOneConferenceChatRoomAddress (
const IdentityAddress &participantA,
const IdentityAddress &participantB,
bool encrypted
const IdentityAddress &participantB
) const;
void insertOneToOneConferenceChatRoom (const std::shared_ptr<AbstractChatRoom> &chatRoom, bool encrypted);
void insertOneToOneConferenceChatRoom (const std::shared_ptr<AbstractChatRoom> &chatRoom);
void updateChatRoomParticipantDevice (
const std::shared_ptr<AbstractChatRoom> &chatRoom,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment