jay/module/publish.h
2025-04-03 22:53:32 +03:00

51 lines
1.4 KiB
C++

// SPDX-FileCopyrightText: 2024 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <map>
#include <string>
#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>& 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<std::string, Dialog> dialogs;
};
}