Commit 310637f2 authored by Ronan's avatar Ronan

feat(core): add a find one to one chat room function

parent 71757bbc
......@@ -23,6 +23,7 @@
#include "chat/chat-room/basic-chat-room.h"
#include "chat/chat-room/chat-room-p.h"
#include "chat/chat-room/real-time-text-chat-room.h"
#include "conference/participant.h"
#include "core-p.h"
#include "logger/logger.h"
......@@ -127,6 +128,22 @@ list<shared_ptr<ChatRoom>> Core::findChatRooms (const IdentityAddress &peerAddre
return output;
}
shared_ptr<ChatRoom> Core::findOneToOneChatRoom (
const IdentityAddress &localAddress,
const IdentityAddress &participantAddress
) {
L_D();
for (const auto &chatRoom : d->chatRooms) {
if (
chatRoom->getNbParticipants() == 1 &&
chatRoom->getLocalAddress() == localAddress &&
participantAddress == chatRoom->getParticipants().front()->getAddress()
)
return chatRoom;
}
return nullptr;
}
shared_ptr<ChatRoom> Core::createClientGroupChatRoom (const string &subject) {
L_D();
return L_GET_CPP_PTR_FROM_C_OBJECT(
......
......@@ -70,6 +70,11 @@ public:
std::shared_ptr<ChatRoom> findChatRoom (const ChatRoomId &chatRoomId) const;
std::list<std::shared_ptr<ChatRoom>> findChatRooms (const IdentityAddress &peerAddress) const;
std::shared_ptr<ChatRoom> findOneToOneChatRoom (
const IdentityAddress &localAddress,
const IdentityAddress &participantAddress
);
std::shared_ptr<ChatRoom> createClientGroupChatRoom (const std::string &subject);
std::shared_ptr<ChatRoom> createClientGroupChatRoom (const std::string &subject, const IdentityAddress &localAddress);
......
......@@ -897,7 +897,7 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
// Chatroom subject.
" subject VARCHAR(255),"
" last_notify_id INT UNSIGNED,"
" last_notify_id INT UNSIGNED DEFAULT 0,"
" flags INT UNSIGNED DEFAULT 0,"
......
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