]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/channel.c
Start moving parts of join to channels.c so they can be used in more places.
[irc/rqf/shadowircd.git] / src / channel.c
index c959687a57d0c79742ec5b72c4bd77e51d36a878..61332aa21430b91cda8504066e1706695c2abe68 100644 (file)
@@ -1357,3 +1357,42 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
                        sendto_server(client_p, chptr, cap, nocap, "%s %s", modebuf, parabuf);
        }
 }
+
+/* Check what we will forward to, without sending any notices to the user
+ * -- jilles
+ */
+struct Channel *
+check_forward(struct Client *source_p, struct Channel *chptr,
+               char *key)
+{
+       int depth = 0, i;
+
+       /* User is +Q */
+       if (IsNoForward(source_p))
+               return NULL;
+
+       while (depth < 16)
+       {
+               chptr = find_channel(chptr->mode.forward);
+               /* Can only forward to existing channels */
+               if (chptr == NULL)
+                       return NULL;
+               /* Already on there, show original error message */
+               if (IsMember(source_p, chptr))
+                       return NULL;
+               /* Juped. Sending a warning notice would be unfair */
+               if (hash_find_resv(chptr->chname))
+                       return NULL;
+               /* Don't forward to +Q channel */
+               if (chptr->mode.mode & MODE_DISFORWARD)
+                       return NULL;
+               i = can_join(source_p, chptr, key);
+               if (i == 0)
+                       return chptr;
+               if (i != ERR_INVITEONLYCHAN && i != ERR_NEEDREGGEDNICK && i != ERR_THROTTLE && i != ERR_CHANNELISFULL)
+                       return NULL;
+               depth++;
+       }
+
+       return NULL;
+}