diff options
| author | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
| commit | 42238034490fb5479d787bd1695750387d508200 (patch) | |
| tree | c93c62e0e1c936e656ae5b9ee1b62380ce2a194c /modules/commands/ms_ignore.cpp | |
| parent | d492923610d9c9146b2a2b63de38deab2cfd4ca7 (diff) | |
Rewrite serializable to have field level granularity
Represent serializable objects in a digraph, and as a result made most
object relationships implicitly defined, and use the graph to trace
references between objects to determine relationships. Edges may
also be marked as having a dependency of the object they point to,
which allows for automatic cleanup and deletion of most objects when
no longer needed.
Additionally, this allows not having to require in-memory copies of
everything when using external databases. db_sql has been rewritten
for this and now always requires a database to function. db_sql with
MySQL now requires InnoDB to make use of transactions and foreign
key constraints.
Diffstat (limited to 'modules/commands/ms_ignore.cpp')
| -rw-r--r-- | modules/commands/ms_ignore.cpp | 81 |
1 files changed, 47 insertions, 34 deletions
diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index 18d4143c0..f85545d32 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -53,54 +53,67 @@ class CommandMSIgnore : public Command source.Reply(_("Channel \002{0}\002 isn't registered."), channel); else source.Reply(_("\002{0}\002 isn't registered."), channel); + return; } - else if (ischan && !source.AccessFor(ci).HasPriv("MEMO")) - source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "MEMO", ci->name); - else if (command.equals_ci("ADD") && !param.empty()) + + if (ischan && !source.AccessFor(ci).HasPriv("MEMO")) { - if (std::find(mi->ignores.begin(), mi->ignores.end(), param.ci_str()) == mi->ignores.end()) - { - mi->ignores.push_back(param.ci_str()); - source.Reply(_("\002{0}\002 has been added to your memo ignore list."), param); - } - else - source.Reply(_("\002{0}\002 is already on your memo ignore list."), param); + source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "MEMO", ci->GetName()); + return; + } + + auto ignores = mi->GetIgnores(); + + if (command.equals_ci("ADD") && !param.empty()) + { + for (MemoServ::Ignore *ign : ignores) + if (ign->GetMask().equals_ci(param)) + { + source.Reply(_("\002{0}\002 is already on your memo ignore list."), param); + return; + } + + MemoServ::Ignore *ign = MemoServ::service->CreateIgnore(); + ign->SetMemoInfo(mi); + ign->SetMask(param); + + source.Reply(_("\002{0}\002 has been added to your memo ignore list."), param); } else if (command.equals_ci("DEL") && !param.empty()) { - std::vector<Anope::string>::iterator it = std::find(mi->ignores.begin(), mi->ignores.end(), param.ci_str()); + for (MemoServ::Ignore *ign : ignores) + if (ign->GetMask().equals_ci(param)) + { + delete ign; + source.Reply(_("\002{0}\002 has been removed from your memo ignore list."), param); + return; + } - if (it != mi->ignores.end()) - { - mi->ignores.erase(it); - source.Reply(_("\002{0}\002 has been removed from your memo ignore list."), param); - } - else - source.Reply(_("\002{0}\002 is not on your memo ignore list."), param); + source.Reply(_("\002{0}\002 is not on your memo ignore list."), param); } else if (command.equals_ci("LIST")) { - if (mi->ignores.empty()) + if (ignores.empty()) + { source.Reply(_("Your memo ignore list is empty.")); - else + return; + } + ListFormatter list(source.GetAccount()); + list.AddColumn(_("Mask")); + for (MemoServ::Ignore *ign : ignores) { - ListFormatter list(source.GetAccount()); - list.AddColumn(_("Mask")); - for (unsigned i = 0; i < mi->ignores.size(); ++i) - { - ListFormatter::ListEntry entry; - entry["Mask"] = mi->ignores[i]; - list.AddEntry(entry); - } + ListFormatter::ListEntry entry; + entry["Mask"] = ign->GetMask(); + list.AddEntry(entry); + } - source.Reply(_("Memo ignore list:")); + source.Reply(_("Memo ignore list:")); - std::vector<Anope::string> replies; - list.Process(replies); + std::vector<Anope::string> replies; + list.Process(replies); - for (unsigned i = 0; i < replies.size(); ++i) - source.Reply(replies[i]); - } + for (unsigned i = 0; i < replies.size(); ++i) + source.Reply(replies[i]); } else this->OnSyntaxError(source, ""); |
