1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2024-10-28 08:49:35 +01:00

swarm-call: do not create 1:1 conversation for incoming calls in swarm

There was no way to differentiate a 1:1 incoming call and a call
from a swarm, because username couldn't be checked. Now, create
conversation only if it's a 1:1 call

Change-Id: I0094967914b4888d083b9adc1d2b11de467d6f48
This commit is contained in:
Sébastien Blin 2023-11-01 11:03:21 -04:00
parent 5776ab7c7d
commit fc7109950b
6 changed files with 42 additions and 34 deletions

2
daemon

@ -1 +1 @@
Subproject commit a7e2c494d1d16bec68b7e098734884062a4b2505
Subproject commit a5a46c0385a224f27456c9b0d271cede9622ea72

View file

@ -451,11 +451,13 @@ Q_SIGNALS:
* @param callId
* @param displayname
* @param isOutgoing
* @param toUri Generally account's uri for 1:1 calls, rdv uri for swarm-call
*/
void newCall(const QString& peerId,
const QString& callId,
const QString& displayname,
bool isOutgoing) const;
bool isOutgoing,
const QString& toUri) const;
/**
* Emitted when a call is added to a conference
* @param callId

View file

@ -156,8 +156,9 @@ Q_SIGNALS:
* @param fromId peer profile uri
* @param callId call id
* @param isOutgoing
* @param toUri
*/
void newCall(const QString& from, const QString& callId, bool isOutgoing) const;
void newCall(const QString& from, const QString& callId, bool isOutgoing, const QString& toUri) const;
/**
* Connect this signal to know when a text message arrives for this account
* @param accountId

View file

@ -1440,7 +1440,7 @@ CallModelPimpl::slotCallStateChanged(const QString& accountId,
qDebug() << displayname;
qDebug() << peerId;
Q_EMIT linked.newCall(peerId, callId, displayname, details["CALL_TYPE"] == "1");
Q_EMIT linked.newCall(peerId, callId, displayname, details["CALL_TYPE"] == "1", details["TO_USERNAME"]);
// NOTE: signal emission order matters, always emit CallStatusChanged before CallEnded
Q_EMIT linked.callStatusChanged(callId, code);

View file

@ -164,8 +164,9 @@ public Q_SLOTS:
* @param callId
* @param displayName
* @param isOutgoing
* @param toUri
*/
void slotNewCall(const QString& fromId, const QString& callId, const QString& displayname, bool isOutgoing);
void slotNewCall(const QString& fromId, const QString& callId, const QString& displayname, bool isOutgoing, const QString& toUri);
/**
* Listen from callbacksHandler for new account interaction and add pending contact if not present
@ -1022,9 +1023,10 @@ void
ContactModelPimpl::slotNewCall(const QString& fromId,
const QString& callId,
const QString& displayname,
bool isOutgoing)
bool isOutgoing,
const QString& toUri)
{
if (!isOutgoing) {
if (!isOutgoing && toUri == linked.owner.profileInfo.uri) {
bool emitContactAdded = false;
{
std::lock_guard<std::mutex> lk(contactsMtx_);
@ -1053,7 +1055,7 @@ ContactModelPimpl::slotNewCall(const QString& fromId,
} else
Q_EMIT linked.profileUpdated(fromId);
}
Q_EMIT linked.newCall(fromId, callId, isOutgoing);
Q_EMIT linked.newCall(fromId, callId, isOutgoing, toUri);
}
void

View file

@ -271,8 +271,9 @@ public Q_SLOTS:
* @param fromId caller uri
* @param callId
* @param isOutgoing
* @param toUri
*/
void slotNewCall(const QString& fromId, const QString& callId, bool isOutgoing = false);
void slotNewCall(const QString& fromId, const QString& callId, bool isOutgoing, const QString& toUri);
/**
* Listen from callmodel for calls status changed.
* @param callId
@ -3367,7 +3368,7 @@ ConversationModelPimpl::getIndicesForContact(const QString& uri) const
}
void
ConversationModelPimpl::slotNewCall(const QString& fromId, const QString& callId, bool isOutgoing)
ConversationModelPimpl::slotNewCall(const QString& fromId, const QString& callId, bool isOutgoing, const QString& toUri)
{
if (isOutgoing) {
// search contact
@ -3379,33 +3380,35 @@ ConversationModelPimpl::slotNewCall(const QString& fromId, const QString& callId
Q_EMIT linked.filterChanged();
}
auto convIds = storage::getConversationsWithPeer(db, fromId);
if (convIds.empty()) {
// in case if we receive call after removing contact add conversation request;
try {
auto contact = linked.owner.contactModel->getContact(fromId);
if (!isOutgoing && !contact.isBanned && fromId != linked.owner.profileInfo.uri) {
addContactRequest(fromId);
if (toUri == linked.owner.profileInfo.uri) {
auto convIds = storage::getConversationsWithPeer(db, fromId);
if (convIds.empty()) {
// in case if we receive call after removing contact add conversation request;
try {
auto contact = linked.owner.contactModel->getContact(fromId);
if (!isOutgoing && !contact.isBanned && fromId != linked.owner.profileInfo.uri) {
addContactRequest(fromId);
}
if (isOutgoing && contact.profileInfo.type == profile::Type::TEMPORARY) {
linked.owner.contactModel->addContact(contact);
}
} catch (const std::out_of_range&) {
}
if (isOutgoing && contact.profileInfo.type == profile::Type::TEMPORARY) {
linked.owner.contactModel->addContact(contact);
}
} catch (const std::out_of_range&) {
}
auto conversationIndices = getIndicesForContact(fromId);
if (conversationIndices.empty()) {
qDebug() << "ConversationModelPimpl::slotNewCall, but conversation not found";
return; // Not a contact
}
auto& conversation = conversations.at(conversationIndices.at(0));
qDebug() << "Add call to conversation " << conversation.uid << " - " << callId;
conversation.callId = callId;
addOrUpdateCallMessage(callId, fromId, true);
Q_EMIT behaviorController.showIncomingCallView(linked.owner.id, conversation.uid);
}
auto conversationIndices = getIndicesForContact(fromId);
if (conversationIndices.empty()) {
qDebug() << "ConversationModelPimpl::slotNewCall, but conversation not found";
return; // Not a contact
}
auto& conversation = conversations.at(conversationIndices.at(0));
qDebug() << "Add call to conversation " << conversation.uid << " - " << callId;
conversation.callId = callId;
addOrUpdateCallMessage(callId, fromId, true);
Q_EMIT behaviorController.showIncomingCallView(linked.owner.id, conversation.uid);
}
void