From 42238034490fb5479d787bd1695750387d508200 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 Nov 2014 14:27:23 -0500 Subject: 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. --- modules/commands/ms_ignore.cpp | 81 ++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 34 deletions(-) (limited to 'modules/commands/ms_ignore.cpp') 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::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 replies; - list.Process(replies); + std::vector 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, ""); -- cgit