| 1 | // SPDX-FileCopyrightText: 2018 Kitsune Ral <kitsune-ral@users.sf.net> |
|---|---|
| 2 | // SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | |
| 4 | #include "directchatevent.h" |
| 5 | |
| 6 | using namespace Quotient; |
| 7 | |
| 8 | QMultiHash<QString, QString> DirectChatEvent::usersToDirectChats() const |
| 9 | { |
| 10 | QMultiHash<QString, QString> result; |
| 11 | const auto& json = contentJson(); |
| 12 | for (auto it = json.begin(); it != json.end(); ++it) { |
| 13 | // Beware of range-for's over temporary returned from temporary |
| 14 | // (see the bottom of |
| 15 | // http://en.cppreference.com/w/cpp/language/range-for#Explanation) |
| 16 | const auto roomIds = it.value().toArray(); |
| 17 | for (const auto& roomIdValue : roomIds) |
| 18 | result.insert(key: it.key(), value: roomIdValue.toString()); |
| 19 | } |
| 20 | return result; |
| 21 | } |
| 22 |