// SPDX-FileCopyrightText: 2024 Yury Gubich // SPDX-License-Identifier: GPL-3.0-or-later #pragma once #include #include #include "shared/definitions.h" #include "shared/result.h" #include "shared/utils.h" #include "module.h" namespace Module { class Publish : public Module { struct Dialog { enum class Stage { address, title, article }; Dialog(); Dialog(Stage stage); Stage stage; std::string node; std::string service; std::string title; }; public: Publish(const std::shared_ptr& core, const Config::Module& conf); ~Publish() noexcept; virtual Shared::Result message(const std::shared_ptr<::Actor>& actor, std::string_view message) override; virtual void cancelDialog(const std::shared_ptr<::Actor>& actor) override; private: Shared::Result handleDialog(const std::shared_ptr<::Actor>& actor, std::string_view message); Shared::Result dialogAddress(const std::string& jid, Dialog& dialog, std::string_view address); Shared::Result dialogTitle(const std::string& jid, Dialog& dialog, std::string_view title); Shared::Result dialogArticle(const std::string& jid, Dialog& dialog, std::string_view article); private: Shared::Result to(std::string_view address, std::string_view title, std::string_view body); std::map dialogs; }; }