* @brief Resolves a group by id or title against project.group.list. */
| 876 | * @brief Resolves a group by id or title against project.group.list. |
| 877 | */ |
| 878 | static QJsonObject resolveGroup(const QJsonObject& args) |
| 879 | { |
| 880 | const auto listReply = runCommand(QStringLiteral("project.group.list")); |
| 881 | if (!listReply.value(QStringLiteral("ok")).toBool()) |
| 882 | return listReply; |
| 883 | |
| 884 | const auto rows = |
| 885 | listReply.value(QStringLiteral("result")).toObject().value(QStringLiteral("groups")).toArray(); |
| 886 | const int wantedId = args.value(QStringLiteral("groupId")).toInt(-1); |
| 887 | const auto title = args.value(QStringLiteral("group")).toString().toCaseFolded(); |
| 888 | |
| 889 | for (const auto& value : rows) { |
| 890 | const auto row = value.toObject(); |
| 891 | if (wantedId >= 0 |
| 892 | && (row.value(QStringLiteral("groupId")).toInt(-1) == wantedId |
| 893 | || row.value(QStringLiteral("id")).toInt(-1) == wantedId)) { |
| 894 | QJsonObject out; |
| 895 | out[QStringLiteral("ok")] = true; |
| 896 | out[QStringLiteral("group")] = row; |
| 897 | return out; |
| 898 | } |
| 899 | |
| 900 | if (!title.isEmpty() && row.value(QStringLiteral("title")).toString().toCaseFolded() == title) { |
| 901 | QJsonObject out; |
| 902 | out[QStringLiteral("ok")] = true; |
| 903 | out[QStringLiteral("group")] = row; |
| 904 | return out; |
| 905 | } |
| 906 | } |
| 907 | |
| 908 | QJsonObject out; |
| 909 | out[QStringLiteral("ok")] = false; |
| 910 | out[QStringLiteral("error")] = QStringLiteral("group_not_resolved"); |
| 911 | out[QStringLiteral("groups")] = rows; |
| 912 | return out; |
| 913 | } |
| 914 | |
| 915 | /** |
| 916 | * @brief Maps a widget slug to the dataset option slug that enables that widget. |
no test coverage detected