- WriteServ(u->fd,"321 %s Channel :Users Name",u->nick);
- chan = Srv->GetChannelIndex(ld->list_position);
- /* spool details */
- if (chan)
- {
- /* Increment total plus linefeed */
- int counter = snprintf(buffer,MAXBUF,"322 %s %s %d :[+%s] %s",u->nick,chan->name,usercount_i(chan),chanmodes(chan,has_channel(u,chan)),chan->topic);
- amount_sent += counter + 4 + Srv->GetServerName().length();
- log(DEBUG,"m_safelist.so: Sent %ld of safe %ld / 4",amount_sent,u->sendqmax);
- WriteServ_NoFormat(u->fd,buffer);
- }
- else
- {
- if (!ld->list_ended)
- {
- ld->list_ended = true;
- WriteServ(u->fd,"323 %s :End of channel list.",u->nick);
- }
- }
+ u->WriteServ("321 %s Channel :Users Name",u->nick);
+ chan = ServerInstance->GetChannelIndex(ld->list_position);
+ /* spool details */
+ bool has_user = (chan && chan->HasUser(u));
+ if ((chan) && (((!(chan->modes[CM_PRIVATE])) && (!(chan->modes[CM_SECRET]))) || (has_user)))
+ {
+ long users = chan->GetUserCounter();
+ if (users)
+ {
+ int counter = snprintf(buffer,MAXBUF,"322 %s %s %ld :[+%s] %s",u->nick,chan->name,users,chan->ChanModes(has_user),chan->topic);
+ /* Increment total plus linefeed */
+ amount_sent += counter + 4 + strlen(ServerInstance->Config->ServerName);
+ ServerInstance->Log(DEBUG,"m_safelist.so: Sent %ld of safe %ld / 4",amount_sent,u->sendqmax);
+ u->WriteServ(std::string(buffer));
+ }
+ }
+ else
+ {
+ if (!chan)
+ {
+ if (!ld->list_ended)
+ {
+ ld->list_ended = true;
+ u->WriteServ("323 %s :End of channel list.",u->nick);
+ }
+ }
+ }