Publishing now has a space for an article and a title. Also reduced amount of copying
This commit is contained in:
parent
98bfab4ba5
commit
8187d045cd
8 changed files with 76 additions and 35 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue