]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
Make oaccept work for multiple opers on the same target.
authorB.Greenham <redacted>
Fri, 5 Mar 2010 19:26:40 +0000 (14:26 -0500)
committerB.Greenham <redacted>
Fri, 5 Mar 2010 19:26:40 +0000 (14:26 -0500)
extensions/m_oaccept.c
modules/core/m_message.c

index a136f66f361f568a863527d0e8c2ecc32c28d649..a01a962653ac9dcb227fc26996318f90b67521b8 100644 (file)
@@ -28,9 +28,14 @@ mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const cha
                return;
        }
 
-       /* only allow one OACCEPT entry per user, so if there's an old one clear it */
-       if(!(md = user_metadata_find(target_p, "OACCEPT")))
-               user_metadata_delete(target_p, "OACCEPT", 1);
+       /* Don't allow someone to pointlessly fill up someone's metadata
+        * with identical OACCEPT entries. */
+       if((md = user_metadata_find(target_p, "OACCEPT")))
+               if(!strcmp(source_p->name, md->value))
+               {
+                       sendto_one_notice(source_p, ":You're already on %s's OACCEPT list", target_p->name);
+                       return;
+               }
 
        user_metadata_add(target_p, "OACCEPT", source_p->name, 1);
 
index cc980432fd80e789ef70218b8e2aff546d8f1399..ad727e24d144306fb305ce7be3c397ee9843cbe6 100644 (file)
@@ -45,6 +45,7 @@
 #include "s_stats.h"
 #include "tgchange.h"
 #include "inline/stringops.h"
+#include "irc_dictionary.h"
 
 static int m_message(int, const char *, struct Client *, struct Client *, int, const char **);
 static int m_privmsg(struct Client *, struct Client *, int, const char **);
@@ -731,6 +732,7 @@ msg_client(int p_or_n, const char *command,
 {
        int do_floodcount = 0;
        struct Metadata *md;
+       struct DictionaryIter iter;
 
        if(MyClient(source_p))
        {
@@ -791,7 +793,6 @@ msg_client(int p_or_n, const char *command,
                                        (IsSetSCallerId(target_p) && !has_common_channel(source_p, target_p)) ||
                                        (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])))
                {
-                       md = user_metadata_find(target_p, "OACCEPT");
                        /* Here is the anti-flood bot/spambot code -db */
                        if(accept_message(source_p, target_p))
                        {
@@ -801,16 +802,19 @@ msg_client(int p_or_n, const char *command,
                                           source_p->username,
                                           source_p->host, command, target_p->name, text);
                        }
-                       /* slightly ugly, meh. if anyone can think of a cleaner way to do this, by all means, do it. */
-                       else if(md)
+                       else if (IsOper(source_p))
                        {
-                               if(!strcmp(md->value, source_p->name))
+                               DICTIONARY_FOREACH(md, &iter, target_p->user->metadata)
                                {
-                                       add_reply_target(target_p, source_p);
-                                       sendto_one(target_p, ":%s!%s@%s %s %s :%s",
-                                                source_p->name,
-                                                source_p->username,
-                                                source_p->host, command, target_p->name, text);
+                                       if(!strcmp(md->value, source_p->name))
+                                       {
+                                               add_reply_target(target_p, source_p);
+                                               sendto_one(target_p, ":%s!%s@%s %s %s :%s",
+                                                        source_p->name,
+                                                        source_p->username,
+                                                        source_p->host, command, target_p->name, text);
+                                               break;
+                                       }
                                }
                        }
                        else if (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])