]> jfr.im git - irc/freenode/solanum.git/commitdiff
callerid: align soft caller-id behavior with ircd-hybrid implementation
authorAriadne Conill <redacted>
Sat, 11 Jul 2020 00:17:50 +0000 (18:17 -0600)
committerAriadne Conill <redacted>
Sat, 11 Jul 2020 00:18:28 +0000 (18:18 -0600)
include/messages.h
modules/um_callerid.c

index d37bf3277329649e1885a9ca86f6933c45272369..1fa36d8218db5042543fd5013e129d187f8bab8c 100644 (file)
 #define NUMERIC_STR_713      "%s :Channel is open."
 #define NUMERIC_STR_714      ":%s 714 %s %s :You are already on that channel."
 #define NUMERIC_STR_715      ":%s 715 %s :KNOCKs are disabled."
-#define NUMERIC_STR_716      "%s :is in +g mode (server-side ignore.)"
+#define NUMERIC_STR_716      "%s :is in %s mode (server-side ignore.)"
 #define NUMERIC_STR_717      "%s :has been informed that you messaged them."
-#define NUMERIC_STR_718      ":%s 718 %s %s %s@%s :is messaging you, and you have umode +g."
+#define NUMERIC_STR_718      ":%s 718 %s %s %s@%s :is messaging you, and you have umode %s."
 #define NUMERIC_STR_720      ":%s 720 %s :Start of OPER MOTD"
 #define NUMERIC_STR_721      ":%s 721 %s :%s"
 #define NUMERIC_STR_722      ":%s 722 %s :End of OPER MOTD"
index 92c673b1a95052dca8e0fc82034eee920189aabf..cbd495de7eddf74c5f88725ee3d358936198d9f4 100644 (file)
@@ -80,8 +80,9 @@ um_callerid_moddeinit(void)
        delete_isupport("CALLERID");
 }
 
-#define IsSetCallerID(c)       ((c->umodes & user_modes['g']) == user_modes['g'])
+#define IsSetStrictCallerID(c) ((c->umodes & user_modes['g']) == user_modes['g'])
 #define IsSetRelaxedCallerID(c)        ((c->umodes & user_modes['G']) == user_modes['G'])
+#define IsSetAnyCallerID(c)    (IsSetStrictCallerID(c) || IsSetRelaxedCallerID(c))
 
 static const char um_callerid_desc[] =
        "Provides usermodes +g and +G which restrict messages from unauthorized users.";
@@ -107,10 +108,10 @@ allow_message(struct Client *source_p, struct Client *target_p)
        if (!MyClient(target_p))
                return true;
 
-       if (!IsSetCallerID(target_p))
+       if (!IsSetAnyCallerID(target_p))
                return true;
 
-       if (IsSetRelaxedCallerID(target_p) && has_common_channel(source_p, target_p))
+       if (IsSetRelaxedCallerID(target_p) && has_common_channel(source_p, target_p) && !IsSetStrictCallerID(target_p))
                return true;
 
        if (IsServer(source_p))
@@ -136,7 +137,7 @@ send_callerid_notice(enum message_type msgtype, struct Client *source_p, struct
                return;
 
        sendto_one_numeric(source_p, ERR_TARGUMODEG, form_str(ERR_TARGUMODEG),
-               target_p->name);
+               target_p->name, IsSetStrictCallerID(target_p) ? "+g" : "+G");
 
        if ((target_p->localClient->last_caller_id_time + ConfigFileEntry.caller_id_wait) < rb_current_time())
        {
@@ -145,7 +146,7 @@ send_callerid_notice(enum message_type msgtype, struct Client *source_p, struct
 
                sendto_one(target_p, form_str(RPL_UMODEGMSG),
                           me.name, target_p->name, source_p->name,
-                          source_p->username, source_p->host);
+                          source_p->username, source_p->host, IsSetStrictCallerID(target_p) ? "+g" : "+G");
 
                target_p->localClient->last_caller_id_time = rb_current_time();
        }
@@ -165,7 +166,7 @@ add_callerid_accept_for_source(enum message_type msgtype, struct Client *source_
         * as a way of griefing.  --nenolod
         */
        if(msgtype != MESSAGE_TYPE_NOTICE &&
-               IsSetCallerID(source_p) &&
+               IsSetAnyCallerID(source_p) &&
                !accept_message(target_p, source_p) &&
                !IsOper(target_p))
        {