forked from mirrors/linphone-iphone
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 (
|
||||
const shared_ptr<Core> &core,
|
||||
const ChatRoomId &chatRoomId,
|
||||
const IdentityAddress &peerAddress,
|
||||
shared_ptr<Participant> &me,
|
||||
const string &subject,
|
||||
list<shared_ptr<Participant>> &&participants
|
||||
) : ChatRoom(*new ClientGroupChatRoomPrivate, core, chatRoomId),
|
||||
RemoteConference(core, chatRoomId.getLocalAddress(), nullptr) {
|
||||
) : ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(peerAddress, me->getAddress())),
|
||||
RemoteConference(core, me->getAddress(), nullptr) {
|
||||
L_D();
|
||||
L_D_T(RemoteConference, dConference);
|
||||
const IdentityAddress &peerAddress = chatRoomId.getPeerAddress();
|
||||
dConference->focus = make_shared<Participant>(peerAddress);
|
||||
dConference->conferenceAddress = peerAddress;
|
||||
dConference->subject = subject;
|
||||
dConference->participants = move(participants);
|
||||
d->state = ChatRoom::State::Created;
|
||||
getMe()->getPrivate()->setAdmin(me->isAdmin());
|
||||
}
|
||||
|
||||
shared_ptr<Core> ClientGroupChatRoom::getCore () const {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@ public:
|
|||
|
||||
ClientGroupChatRoom (
|
||||
const std::shared_ptr<Core> &core,
|
||||
const ChatRoomId &chatRoomId,
|
||||
const IdentityAddress &peerAddress,
|
||||
std::shared_ptr<Participant> &me,
|
||||
const std::string &subject,
|
||||
std::list<std::shared_ptr<Participant>> &&participants
|
||||
);
|
||||
|
|
|
|||
|
|
@ -37,15 +37,14 @@ public:
|
|||
std::string subject;
|
||||
|
||||
protected:
|
||||
Conference *mPublic = nullptr;
|
||||
|
||||
std::shared_ptr<Participant> activeParticipant;
|
||||
std::shared_ptr<Participant> me;
|
||||
|
||||
Conference *mPublic = nullptr;
|
||||
|
||||
private:
|
||||
CallListener *callListener = nullptr;
|
||||
|
||||
std::shared_ptr<Participant> me;
|
||||
|
||||
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());
|
||||
|
||||
id = q->getLastInsertId();
|
||||
shared_ptr<Participant> me = chatRoom->getMe();
|
||||
insertChatRoomParticipant(id, insertSipAddress(me->getAddress().asString()), me->isAdmin());
|
||||
for (const auto &participant : chatRoom->getParticipants())
|
||||
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";
|
||||
|
||||
soci::rowset<soci::row> rows = (session->prepare << query);
|
||||
shared_ptr<Participant> me;
|
||||
for (const auto &row : rows) {
|
||||
shared_ptr<Participant> participant = make_shared<Participant>(IdentityAddress(row.get<string>(0)));
|
||||
participant->getPrivate()->setAdmin(!!row.get<int>(1));
|
||||
participants.push_back(participant);
|
||||
|
||||
if (participant->getAddress() == chatRoomId.getPeerAddress())
|
||||
me = participant;
|
||||
else
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue