- log(DEBUG, "m_safelist.so: resuming spool of list to client %s at channel %ld", u->nick, ld->list_position);
- chan = NULL;
- /* Attempt to fill up to half the user's sendq with /LIST output */
- long amount_sent = 0;
- do
- {
- log(DEBUG,"Channel %ld",ld->list_position);
- 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 / 2",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);
- }
- }
+ ServerInstance->Log(DEBUG, "m_safelist.so: resuming spool of list to client %s at channel %ld", u->nick, ld->list_position);
+ chan = NULL;
+ /* Attempt to fill up to half the user's sendq with /LIST output */
+ long amount_sent = 0;
+ do
+ {
+ ServerInstance->Log(DEBUG,"Channel %ld",ld->list_position);
+ if (!ld->list_position)
+ 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);
+ }
+ }
+ }