service: send summary when executing "server notice"

Sometimes this command times out. Display the number of skipped
users.

git-svn-id: file:///srv/svn/repo/suika/trunk@755 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
contact 2021-12-08 13:55:31 +00:00
parent 6487d245a4
commit fcac9d5cdd

View File

@ -1090,12 +1090,20 @@ func handleServiceServerNotice(ctx context.Context, dc *downstreamConn, params [
Params: []string{"$" + dc.srv.Config().Hostname, text},
}
var err error
sent := 0
total := 0
dc.srv.forEachUser(func(u *user) {
total++
select {
case <-ctx.Done():
err = ctx.Err()
case u.events <- eventBroadcast{broadcastMsg}:
sent++
}
})
dc.logger.Printf("broadcast bouncer-wide NOTICE to %v/%v downstreams", sent, total)
sendServicePRIVMSG(dc, fmt.Sprintf("sent to %v/%v downstream connections", sent, total))
return err
}