// SPDX-FileCopyrightText: 2024 Yury Gubich // SPDX-License-Identifier: GPL-3.0-or-later #include "module.h" #include #include "gloox/message.h" Module::Module::Module(const std::shared_ptr& core, const Shared::Permissions& permissions): core(core), permissions(permissions) {} bool Module::Module::hasPermission(const std::string& permission, const std::shared_ptr<::Actor>& actor) const { Shared::Permissions::const_iterator itr = permissions.find(permission); if (itr == permissions.end()) return false; return std::find(itr->second.begin(), itr->second.end(), actor->getGroup()) != itr->second.end(); } Module::Module::~Module() noexcept {} std::vector Module::Module::split(const std::string& string, const std::string& delimiter) { std::vector result; std::size_t last = 0; std::size_t next = string.find(delimiter, last); while (next != std::string::npos) { result.emplace_back(string.substr(last, next - last)); last = next + 1; next = string.find(delimiter, last); } result.emplace_back(string.substr(last)); return result; }