mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-22 15:38:33 +00:00
fix(MainDb): add me in db
This commit is contained in:
parent
5c941ca635
commit
a6b6b7aeb4
4 changed files with 25 additions and 11 deletions
|
|
@ -99,19 +99,20 @@ RemoteConference(core, me, nullptr) {
|
||||||
|
|
||||||
ClientGroupChatRoom::ClientGroupChatRoom (
|
ClientGroupChatRoom::ClientGroupChatRoom (
|
||||||
const shared_ptr<Core> &core,
|
const shared_ptr<Core> &core,
|
||||||
const ChatRoomId &chatRoomId,
|
const IdentityAddress &peerAddress,
|
||||||
|
shared_ptr<Participant> &me,
|
||||||
const string &subject,
|
const string &subject,
|
||||||
list<shared_ptr<Participant>> &&participants
|
list<shared_ptr<Participant>> &&participants
|
||||||
) : ChatRoom(*new ClientGroupChatRoomPrivate, core, chatRoomId),
|
) : ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(peerAddress, me->getAddress())),
|
||||||
RemoteConference(core, chatRoomId.getLocalAddress(), nullptr) {
|
RemoteConference(core, me->getAddress(), nullptr) {
|
||||||
L_D();
|
L_D();
|
||||||
L_D_T(RemoteConference, dConference);
|
L_D_T(RemoteConference, dConference);
|
||||||
const IdentityAddress &peerAddress = chatRoomId.getPeerAddress();
|
|
||||||
dConference->focus = make_shared<Participant>(peerAddress);
|
dConference->focus = make_shared<Participant>(peerAddress);
|
||||||
dConference->conferenceAddress = peerAddress;
|
dConference->conferenceAddress = peerAddress;
|
||||||
dConference->subject = subject;
|
dConference->subject = subject;
|
||||||
dConference->participants = move(participants);
|
dConference->participants = move(participants);
|
||||||
d->state = ChatRoom::State::Created;
|
d->state = ChatRoom::State::Created;
|
||||||
|
getMe()->getPrivate()->setAdmin(me->isAdmin());
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Core> ClientGroupChatRoom::getCore () const {
|
shared_ptr<Core> ClientGroupChatRoom::getCore () const {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,8 @@ public:
|
||||||
|
|
||||||
ClientGroupChatRoom (
|
ClientGroupChatRoom (
|
||||||
const std::shared_ptr<Core> &core,
|
const std::shared_ptr<Core> &core,
|
||||||
const ChatRoomId &chatRoomId,
|
const IdentityAddress &peerAddress,
|
||||||
|
std::shared_ptr<Participant> &me,
|
||||||
const std::string &subject,
|
const std::string &subject,
|
||||||
std::list<std::shared_ptr<Participant>> &&participants
|
std::list<std::shared_ptr<Participant>> &&participants
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,14 @@ public:
|
||||||
std::string subject;
|
std::string subject;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Conference *mPublic = nullptr;
|
|
||||||
|
|
||||||
std::shared_ptr<Participant> activeParticipant;
|
std::shared_ptr<Participant> activeParticipant;
|
||||||
|
std::shared_ptr<Participant> me;
|
||||||
|
|
||||||
|
Conference *mPublic = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CallListener *callListener = nullptr;
|
CallListener *callListener = nullptr;
|
||||||
|
|
||||||
std::shared_ptr<Participant> me;
|
|
||||||
|
|
||||||
L_DECLARE_PUBLIC(Conference);
|
L_DECLARE_PUBLIC(Conference);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,8 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
||||||
soci::use(static_cast<int>(chatRoom->getCapabilities())), soci::use(chatRoom->getSubject());
|
soci::use(static_cast<int>(chatRoom->getCapabilities())), soci::use(chatRoom->getSubject());
|
||||||
|
|
||||||
id = q->getLastInsertId();
|
id = q->getLastInsertId();
|
||||||
|
shared_ptr<Participant> me = chatRoom->getMe();
|
||||||
|
insertChatRoomParticipant(id, insertSipAddress(me->getAddress().asString()), me->isAdmin());
|
||||||
for (const auto &participant : chatRoom->getParticipants())
|
for (const auto &participant : chatRoom->getParticipants())
|
||||||
insertChatRoomParticipant(id, insertSipAddress(participant->getAddress().asString()), participant->isAdmin());
|
insertChatRoomParticipant(id, insertSipAddress(participant->getAddress().asString()), participant->isAdmin());
|
||||||
|
|
||||||
|
|
@ -1577,13 +1579,24 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
|
||||||
" AND chat_room_participant.chat_room_id = chat_room.id";
|
" AND chat_room_participant.chat_room_id = chat_room.id";
|
||||||
|
|
||||||
soci::rowset<soci::row> rows = (session->prepare << query);
|
soci::rowset<soci::row> rows = (session->prepare << query);
|
||||||
|
shared_ptr<Participant> me;
|
||||||
for (const auto &row : rows) {
|
for (const auto &row : rows) {
|
||||||
shared_ptr<Participant> participant = make_shared<Participant>(IdentityAddress(row.get<string>(0)));
|
shared_ptr<Participant> participant = make_shared<Participant>(IdentityAddress(row.get<string>(0)));
|
||||||
participant->getPrivate()->setAdmin(!!row.get<int>(1));
|
participant->getPrivate()->setAdmin(!!row.get<int>(1));
|
||||||
|
|
||||||
|
if (participant->getAddress() == chatRoomId.getPeerAddress())
|
||||||
|
me = participant;
|
||||||
|
else
|
||||||
participants.push_back(participant);
|
participants.push_back(participant);
|
||||||
}
|
}
|
||||||
|
|
||||||
chatRoom = make_shared<ClientGroupChatRoom>(core, chatRoomId, subject, move(participants));
|
if (!me) {
|
||||||
|
lError() << "Unable to find me in: (peer=" + chatRoomId.getPeerAddress().asString() +
|
||||||
|
", local=" + chatRoomId.getLocalAddress().asString() + ").";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
chatRoom = make_shared<ClientGroupChatRoom>(core, chatRoomId.getPeerAddress(), me, subject, move(participants));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chatRoom)
|
if (!chatRoom)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue