]> jfr.im git - solanum.git/blobdiff - modules/um_callerid.c
reference.conf: add drain_reason
[solanum.git] / modules / um_callerid.c
index afbd624b4e2f4de85a91ab529846d8c6d7c8b8ef..897435982064c7eadf7833c25b8d93ffec649198 100644 (file)
@@ -87,21 +87,6 @@ um_callerid_moddeinit(void)
 static const char um_callerid_desc[] =
        "Provides usermodes +g and +G which restrict messages from unauthorized users.";
 
-static bool
-has_common_channel(struct Client *source_p, struct Client *target_p)
-{
-       rb_dlink_node *ptr;
-
-       RB_DLINK_FOREACH(ptr, source_p->user->channel.head)
-       {
-               struct membership *msptr = ptr->data;
-               if (IsMember(target_p, msptr->chptr))
-                       return true;
-       }
-
-       return false;
-}
-
 static bool
 allow_message(struct Client *source_p, struct Client *target_p)
 {
@@ -111,14 +96,16 @@ allow_message(struct Client *source_p, struct Client *target_p)
        if (!IsSetAnyCallerID(target_p))
                return true;
 
-       if (IsSetRelaxedCallerID(target_p) && has_common_channel(source_p, target_p) && !IsSetStrictCallerID(target_p))
+       if (!IsPerson(source_p))
                return true;
 
-       if (IsServer(source_p))
+       if (IsSetRelaxedCallerID(target_p) &&
+                       !IsSetStrictCallerID(target_p) &&
+                       has_common_channel(source_p, target_p))
                return true;
 
        /* XXX: controversial?  allow opers to send through +g */
-       if (IsOper(source_p))
+       if (MayHavePrivilege(source_p, "oper:message"))
                return true;
 
        if (accept_message(source_p, target_p))
@@ -168,7 +155,7 @@ add_callerid_accept_for_source(enum message_type msgtype, struct Client *source_
        if(msgtype != MESSAGE_TYPE_NOTICE &&
                IsSetAnyCallerID(source_p) &&
                !accept_message(target_p, source_p) &&
-               !IsOper(target_p))
+               !IsOperGeneral(target_p))
        {
                if(rb_dlink_list_length(&source_p->localClient->allow_list) <
                                (unsigned long)ConfigFileEntry.max_accept)
@@ -180,7 +167,7 @@ add_callerid_accept_for_source(enum message_type msgtype, struct Client *source_
                {
                        sendto_one_numeric(source_p, ERR_OWNMODE,
                                        form_str(ERR_OWNMODE),
-                                       target_p->name, "+g");
+                                       target_p->name, IsSetStrictCallerID(target_p) ? "+g" : "+G");
                        return false;
                }
        }