Implement invitation announcements (RPL_ISSUEDINVITE).
[ircu2.10.12-pk.git] / ircd / m_burst.c
index 5b70eabd5d029f2a70f45781d70dc97ff199c5ad..c03a6c004bcfc5ab16d2b5dc30b57de86dee3929 100644 (file)
@@ -86,7 +86,7 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
-#include "ircd_policy.h"
+#include "ircd_features.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "list.h"
@@ -178,7 +178,7 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   struct ModeBuf modebuf, *mbuf = 0;
   struct Channel *chptr;
   time_t timestamp;
-  struct Membership *member;
+  struct Membership *member, *nmember;
   struct SLink *lp, **lp_p;
   unsigned int parse_flags = (MODE_PARSE_FORCE | MODE_PARSE_BURST);
   int param, nickpos = 0, banpos = 0;
@@ -192,6 +192,38 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 
   timestamp = atoi(parv[2]);
 
+  if (!chptr->creationtime || chptr->creationtime > timestamp) {
+    /*
+     * Kick local members if channel is +i or +k and our TS was larger
+     * than the burst TS (anti net.ride). The modes hack is here because
+     * we have to do this before mode_parse, as chptr may go away.
+     */
+    for (param = 3; param < parc; param++)
+    {
+      if (parv[param][0] != '+')
+        continue;
+      if (strchr(parv[param], 'i') || strchr(parv[param], 'k'))
+      {
+        /* Clear any outstanding rogue invites */
+        mode_invite_clear(chptr);
+        for (member = chptr->members; member; member = nmember)
+        {
+          nmember = member->next_member;
+          if (!MyUser(member->user) || IsZombie(member))
+            continue;
+          sendcmdto_serv_butone(&me, CMD_KICK, NULL, "%H %C :Net Rider", chptr, member->user);
+          sendcmdto_channel_butserv_butone(&me, CMD_KICK, chptr, NULL, 0, "%H %C :Net Rider", chptr, member->user);
+          make_zombie(member, member->user, &me, &me, chptr);
+        }
+      }
+      break;
+    }
+
+    /* If the channel had only locals, it went away by now. */
+    if (!(chptr = get_channel(sptr, parv[1], CGT_CREATE)))
+      return 0; /* can't create the channel? */
+  }
+
   /* turn off burst joined flag */
   for (member = chptr->members; member; member = member->next_member)
     member->status &= ~(CHFL_BURST_JOINED|CHFL_BURST_ALREADY_OPPED|CHFL_BURST_ALREADY_VOICED);
@@ -208,13 +240,22 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     modebuf_mode(mbuf, MODE_DEL | chptr->mode.mode); /* wipeout modes */
     chptr->mode.mode &= ~(MODE_ADD | MODE_DEL | MODE_PRIVATE | MODE_SECRET |
                          MODE_MODERATED | MODE_TOPICLIMIT | MODE_INVITEONLY |
-                         MODE_NOPRIVMSGS);
+                         MODE_NOPRIVMSGS | MODE_DELJOINS);
 
     parse_flags |= (MODE_PARSE_SET | MODE_PARSE_WIPEOUT); /* wipeout keys */
 
     /* mark bans for wipeout */
     for (lp = chptr->banlist; lp; lp = lp->next)
       lp->flags |= CHFL_BURST_BAN_WIPEOUT;
+
+    /* clear topic set by netrider (if set) */
+    if (*chptr->topic) {
+      *chptr->topic = '\0';
+      *chptr->topic_nick = '\0';
+      chptr->topic_time = 0;
+      sendcmdto_channel_butserv_butone(&me, CMD_TOPIC, chptr, NULL, 0,
+                                       "%H :%s", chptr, chptr->topic);
+    }
   } else if (chptr->creationtime == timestamp) {
     modebuf_init(mbuf = &modebuf, &me, cptr, chptr,
                 MODEBUF_DEST_CHANNEL | MODEBUF_DEST_NOKEY);
@@ -277,11 +318,9 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
            newban = make_link(); /* create new ban */
 
            DupString(newban->value.ban.banstr, ban);
-#ifdef HEAD_IN_SAND_BANWHO
-           DupString(newban->value.ban.who, cli_name(&me));
-#else
-           DupString(newban->value.ban.who, cli_name(sptr));
-#endif
+
+            DupString(newban->value.ban.who, 
+                      cli_name(feature_bool(FEAT_HIS_BANWHO) ? &me : sptr));
            newban->value.ban.when = TStime();
 
            newban->flags = CHFL_BAN | CHFL_BURST_BAN; /* set flags */
@@ -303,12 +342,16 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
       {
        struct Client *acptr;
        char *nicklist = parv[param], *p = 0, *nick, *ptr;
-       int current_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
-       int last_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
+       int current_mode, last_mode, base_mode;
        int oplevel = -1;       /* Mark first field with digits: means the same as 'o' (but with level). */
        int last_oplevel = 0;
        struct Membership* member;
 
+        base_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
+        if (chptr->mode.mode & MODE_DELJOINS)
+            base_mode |= CHFL_DELAYED;
+        current_mode = last_mode = base_mode;
+
        for (nick = ircd_strtok(&p, nicklist, ","); nick;
             nick = ircd_strtok(&p, 0, ",")) {
 
@@ -326,29 +369,29 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
                   */
                  oplevel = MAXOPLEVEL;
                  if (current_mode_needs_reset) {
-                   current_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
+                   current_mode = base_mode;
                    current_mode_needs_reset = 0;
                  }
-                 current_mode = (current_mode & ~CHFL_DEOPPED) | CHFL_CHANOP;
+                 current_mode = (current_mode & ~(CHFL_DEOPPED | CHFL_DELAYED)) | CHFL_CHANOP;
                }
                else if (*ptr == 'v') { /* has voice status */
                  if (current_mode_needs_reset) {
-                   current_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
+                    current_mode = base_mode;
                    current_mode_needs_reset = 0;
                  }
-                 current_mode |= CHFL_VOICE;
+                 current_mode = (current_mode & ~CHFL_DELAYED) | CHFL_VOICE;
                  oplevel = -1; /* subsequential digits are an absolute op-level value. */
                 }
                else if (isdigit(*ptr)) {
                  int level_increment = 0;
                  if (oplevel == -1) { /* op-level is absolute value? */
                    if (current_mode_needs_reset) {
-                     current_mode = CHFL_DEOPPED | CHFL_BURST_JOINED;
+                     current_mode = base_mode;
                      current_mode_needs_reset = 0;
                    }
                    oplevel = 0;
                  }
-                 current_mode = (current_mode & ~CHFL_DEOPPED) | CHFL_CHANOP;
+                 current_mode = (current_mode & ~(CHFL_DEOPPED | CHFL_DELAYED)) | CHFL_CHANOP;
                  do {
                    level_increment = 10 * level_increment + *ptr++ - '0';
                  } while(isdigit(*ptr));
@@ -388,7 +431,8 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
          if (IsBurst(sptr) || !(member = find_member_link(chptr, acptr)))
          {
            add_user_to_channel(chptr, acptr, current_mode, oplevel);
-           sendcmdto_channel_butserv_butone(acptr, CMD_JOIN, chptr, NULL, "%H", chptr);
+            if (!(current_mode & CHFL_DELAYED))
+              sendcmdto_channel_butserv_butone(acptr, CMD_JOIN, chptr, NULL, 0, "%H", chptr);
          }
          else
          {