Commit f7b64d5a authored by Ghislain MARY's avatar Ghislain MARY

When adding participants to a ClientGroupChatRoom, check that they are not...

When adding participants to a ClientGroupChatRoom, check that they are not already in the chat room.
parent 4cd5e7ae
......@@ -31,6 +31,7 @@ class ClientGroupChatRoomPrivate : public ChatRoomPrivate {
public:
ClientGroupChatRoomPrivate () = default;
std::list<Address> cleanAddressesList (const std::list<Address> &addresses) const;
std::shared_ptr<CallSession> createSession ();
void notifyReceived (std::string body);
......
......@@ -39,6 +39,20 @@ LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
list<Address> ClientGroupChatRoomPrivate::cleanAddressesList (const list<Address> &addresses) const {
L_Q();
list<Address> cleanedList(addresses);
cleanedList.sort();
cleanedList.unique();
for (auto it = cleanedList.begin(); it != cleanedList.end();) {
if (q->findParticipant(*it))
it = cleanedList.erase(it);
else
it++;
}
return cleanedList;
}
shared_ptr<CallSession> ClientGroupChatRoomPrivate::createSession () {
L_Q();
L_Q_T(RemoteConference, qConference);
......@@ -94,7 +108,8 @@ void ClientGroupChatRoom::addParticipants (
L_D();
L_D_T(RemoteConference, dConference);
if (addresses.empty())
list<Address> addressesList = d->cleanAddressesList(addresses);
if (addressesList.empty())
return;
if ((d->state != ChatRoom::State::Instantiated) && (d->state != ChatRoom::State::Created)) {
......@@ -102,12 +117,8 @@ void ClientGroupChatRoom::addParticipants (
return;
}
list<Address> sortedAddresses(addresses);
sortedAddresses.sort();
sortedAddresses.unique();
Content content;
content.setBody(getResourceLists(sortedAddresses));
content.setBody(getResourceLists(addressesList));
content.setContentType("application/resource-lists+xml");
content.setContentDisposition("recipient-list");
......
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