Allow TOPIC from off-channel services. Preserve user's visibility in
[ircu2.10.12-pk.git] / ircd / m_topic.c
index d0c674c757d4a62cdd693818f855eb241bb122e1..d646907596e24728d845deeca8325d1769d4e319 100644 (file)
 static void do_settopic(struct Client *sptr, struct Client *cptr, 
                        struct Channel *chptr, char *topic, time_t ts)
 {
-   struct Membership *member;
    struct Client *from;
    int newtopic;
 
@@ -108,14 +107,18 @@ static void do_settopic(struct Client *sptr, struct Client *cptr,
        from = &me;
    else
        from = sptr;
-   member = find_channel_member(sptr, chptr);
-   /* if +t and not @'d, return an error and ignore the topic */
-   if ((chptr->mode.mode & MODE_TOPICLIMIT) != 0 && (!member || !IsChanOp(member)))
+   if (IsChannelService(sptr))
    {
+       /* allow off-channel services to set the topic of any channel */
+   }
+   else if ((chptr->mode.mode & MODE_TOPICLIMIT) != 0 && is_chan_op(sptr, chptr))
+   {
+      /* if +t and not @'d, return an error and ignore the topic */
       send_reply(sptr, ERR_CHANOPRIVSNEEDED, chptr->chname);
       return;
    }
-   if (!client_can_send_to_channel(sptr, chptr, 1) && !IsChannelService(sptr)) {
+   else if (!client_can_send_to_channel(sptr, chptr, 1))
+   {
       send_reply(sptr, ERR_CANNOTSENDTOCHAN, chptr->chname);
       return;
    }