Publishing now has a space for an article and a title. Also reduced amount of copying

This commit is contained in:
Blue 2025-03-31 18:46:40 +03:00
parent 98bfab4ba5
commit 8187d045cd
Signed by: blue
GPG key ID: 9B203B252A63EE38
8 changed files with 76 additions and 35 deletions

View file

@ -9,26 +9,27 @@ Module::Actor::Actor(const std::shared_ptr<Core>& core, const Config::Module& co
Module::Actor::~Actor() noexcept {}
Shared::Result Module::Actor::message(const std::shared_ptr<::Actor>& actor, const Shared::Strings& args) {
std::string result;
Shared::Result Module::Actor::message(const std::shared_ptr<::Actor>& actor, std::string_view view) {
std::string_view command = pop(view);
if (args.front() == "list") {
if (command == "list") {
if (!hasPermission("read", actor))
return Shared::forbidden;
result = list();
} else if (args.front() == "set") {
core->send(actor->jid, list());
return Shared::success;
}
if (command == "set") {
if (!hasPermission("write", actor))
return Shared::forbidden;
if (args.size() < 3)
std::string_view jid = pop(view);
std::string_view group = pop(view);
if (jid.empty() || group.empty())
return Shared::error;
result = set(args[1], args[2]);
}
if (!result.empty()) {
core->send(actor->jid, result);
core->send(actor->jid, set(jid, group));
return Shared::success;
}
@ -50,8 +51,11 @@ std::string Module::Actor::list() {
return result;
}
std::string Module::Actor::set(const std::string& jid, const std::string& group) {
core->setGroup(lower(jid), group);
std::string Module::Actor::set(const std::string_view& jid, const std::string_view& group) {
std::string j(lower(std::string(jid)));
std::string g(group);
core->setGroup(j, g);
return jid + " is now " + core->router.getGroup(jid);
return j + " is now " + core->router.getGroup(j);
}