]> jfr.im git - solanum.git/blobdiff - modules/m_invite.c
m_list: fail on invalid parameters
[solanum.git] / modules / m_invite.c
index e097930c7562e1a8d40eb1fc994332bfd62b166f..af65e1b5231c21723a774703e072b31cbf95f951 100644 (file)
@@ -37,6 +37,7 @@
 #include "modules.h"
 #include "packet.h"
 #include "tgchange.h"
+#include "s_newconf.h"
 
 static const char invite_desc[] = "Provides /invite";
 
@@ -145,27 +146,25 @@ m_invite(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
                return;
        }
 
-       hdata.chptr = chptr;
-       hdata.msptr = msptr;
-       hdata.client = source_p;
-       hdata.target = target_p;
-       hdata.approved = !(is_chanop(msptr) || (chptr->mode.mode & MODE_FREEINVITE));
-
-       call_hook(can_invite_hook, &hdata);
-       if (hdata.approved)
+       if (MyClient(source_p))
        {
-               if (MyClient(target_p))
+               hdata.chptr = chptr;
+               hdata.msptr = msptr;
+               hdata.client = source_p;
+               hdata.target = target_p;
+               hdata.approved = !(is_chanop(msptr) || (chptr->mode.mode & MODE_FREEINVITE));
+
+               call_hook(can_invite_hook, &hdata);
+               if (hdata.approved)
                {
                        if (hdata.error)
                                sendto_one_numeric(source_p, hdata.approved, "%s", hdata.error);
-                       else if (hdata.approved == ERR_CHANOPRIVSNEEDED)
+                       else
                                sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
-                                          me.name, source_p->name, parv[2]);
+                                                me.name, source_p->name, parv[2]);
 
-                       add_reply_target(target_p, source_p);
+                       return;
                }
-
-               return;
        }
 
        /* store invites when they could affect the ability to join
@@ -178,7 +177,7 @@ m_invite(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
 
        if(MyConnect(source_p))
        {
-               if (ConfigFileEntry.target_change && !IsOper(source_p) &&
+               if (ConfigFileEntry.target_change && !IsOperGeneral(source_p) &&
                                !find_allowing_channel(source_p, target_p) &&
                                !add_target(source_p, target_p))
                {
@@ -203,30 +202,6 @@ m_invite(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
 
        if(MyConnect(target_p))
        {
-               if(!IsOper(source_p) && IsSetCallerId(target_p) && !accept_message(source_p, target_p))
-               {
-                       sendto_one_numeric(source_p, ERR_TARGUMODEG,
-                                          form_str(ERR_TARGUMODEG),
-                                          target_p->name);
-
-                       if((target_p->localClient->last_caller_id_time +
-                           ConfigFileEntry.caller_id_wait) < rb_current_time())
-                       {
-                               sendto_one_numeric(source_p, RPL_TARGNOTIFY,
-                                                       form_str(RPL_TARGNOTIFY),
-                                                       target_p->name);
-
-                               add_reply_target(target_p, source_p);
-                               sendto_one(target_p, form_str(RPL_UMODEGMSG),
-                                          me.name, target_p->name, source_p->name,
-                                          source_p->username, source_p->host);
-
-                               target_p->localClient->last_caller_id_time = rb_current_time();
-                       }
-
-                       return;
-               }
-
                hdata.chptr = chptr;
                hdata.msptr = msptr;
                hdata.client = source_p;
@@ -243,9 +218,7 @@ m_invite(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
                }
 
                add_reply_target(target_p, source_p);
-               sendto_one(target_p, ":%s!%s@%s INVITE %s :%s",
-                          source_p->name, source_p->username, source_p->host,
-                          target_p->name, chptr->chname);
+               sendto_anywhere(target_p, source_p, "INVITE", ":%s", chptr->chname);
 
                if(store_invite)
                        add_invite(chptr, target_p);