forked from mirrors/linphone-iphone
feat(MainDb): support fetch of participant devices
This commit is contained in:
parent
e93ed1cc3f
commit
f047ea775b
1 changed files with 23 additions and 7 deletions
|
|
@ -2073,17 +2073,31 @@ static constexpr string &blobToString (string &in) {
|
|||
list<shared_ptr<Participant>> participants;
|
||||
|
||||
const long long &dbChatRoomId = d->resolveId(row, 0);
|
||||
static const string query = "SELECT sip_address.value, is_admin"
|
||||
static const string query = "SELECT chat_room_participant.id, sip_address.value, is_admin"
|
||||
" FROM sip_address, chat_room, chat_room_participant"
|
||||
" WHERE chat_room.id = :chatRoomId"
|
||||
" AND sip_address.id = chat_room_participant.participant_sip_address_id"
|
||||
" AND chat_room_participant.chat_room_id = chat_room.id";
|
||||
|
||||
// Fetch participants.
|
||||
soci::rowset<soci::row> rows = (session->prepare << query, soci::use(dbChatRoomId));
|
||||
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));
|
||||
shared_ptr<Participant> participant = make_shared<Participant>(IdentityAddress(row.get<string>(1)));
|
||||
ParticipantPrivate *dParticipant = participant->getPrivate();
|
||||
dParticipant->setAdmin(!!row.get<int>(2));
|
||||
|
||||
// Fetch devices.
|
||||
{
|
||||
const long long &participantId = d->resolveId(row, 0);
|
||||
static const string query = "SELECT sip_address.value FROM chat_room_participant_device, sip_address"
|
||||
" WHERE chat_room_participant_id = :participantId"
|
||||
" AND participant_device_sip_address_id = sip_address.id";
|
||||
|
||||
soci::rowset<soci::row> rows = (session->prepare << query, soci::use(participantId));
|
||||
for (const auto &row : rows)
|
||||
dParticipant->addDevice(IdentityAddress(row.get<string>(0)));
|
||||
}
|
||||
|
||||
if (participant->getAddress() == chatRoomId.getLocalAddress().getAddressWithoutGruu())
|
||||
me = participant;
|
||||
|
|
@ -2106,8 +2120,9 @@ static constexpr string &blobToString (string &in) {
|
|||
move(participants),
|
||||
lastNotifyId
|
||||
);
|
||||
chatRoom->getPrivate()->setState(LinphonePrivate::ChatRoom::State::Instantiated);
|
||||
chatRoom->getPrivate()->setState(hasBeenLeft
|
||||
AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate();
|
||||
dChatRoom->setState(ChatRoom::State::Instantiated);
|
||||
dChatRoom->setState(hasBeenLeft
|
||||
? ChatRoom::State::Terminated
|
||||
: ChatRoom::State::Created
|
||||
);
|
||||
|
|
@ -2119,8 +2134,9 @@ static constexpr string &blobToString (string &in) {
|
|||
move(participants),
|
||||
lastNotifyId
|
||||
);
|
||||
chatRoom->getPrivate()->setState(LinphonePrivate::ChatRoom::State::Instantiated);
|
||||
chatRoom->getPrivate()->setState(LinphonePrivate::ChatRoom::State::Created);
|
||||
AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate();
|
||||
dChatRoom->setState(ChatRoom::State::Instantiated);
|
||||
dChatRoom->setState(ChatRoom::State::Created);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue