diff --git a/pkg/commands.go b/pkg/commands.go index c702eeb..06e4298 100644 --- a/pkg/commands.go +++ b/pkg/commands.go @@ -229,14 +229,11 @@ func (s *Server) BanCommand(words []string, sub *Subscriber) { log.Info("Operator %s bans %s for %d hours", sub.Username, username, duration/time.Hour) - other, err := s.GetSubscriber(username) - if err != nil { - sub.ChatServer("/ban: username not found: %s", username) - } else { - // Ban them. - BanUser(username, duration) + // Add them to the ban list. + BanUser(username, duration) - // Broadcast it to everyone. + // If the target user is currently online, disconnect them and broadcast the ban to everybody. + if other, err := s.GetSubscriber(username); err == nil { s.Broadcast(messages.Message{ Action: messages.ActionPresence, Username: username, @@ -249,8 +246,9 @@ func (s *Server) BanCommand(words []string, sub *Subscriber) { }) other.authenticated = false other.Username = "" - sub.ChatServer("%s has been banned from the room for %d hours.", username, duration/time.Hour) } + + sub.ChatServer("%s has been banned from the room for %d hours.", username, duration/time.Hour) } // UnbanCommand handles the `/unban` operator command. diff --git a/pkg/handlers.go b/pkg/handlers.go index e076f42..599115b 100644 --- a/pkg/handlers.go +++ b/pkg/handlers.go @@ -83,7 +83,6 @@ func (s *Server) OnLogin(sub *Subscriber, msg messages.Message) { sub.SendJSON(messages.Message{ Action: messages.ActionKick, }) - s.DeleteSubscriber(sub) return } diff --git a/src/App.vue b/src/App.vue index 2ca5f2a..71b9028 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1277,12 +1277,22 @@ export default { isJoin = true; } - // Push it to the history of all public channels (depending on user preference). + // Push it to the history of the public channels (respecting user preferences). if ((isJoin && this.prefs.joinMessages) || (isLeave && this.prefs.exitMessages) || (!isJoin && !isLeave)) { - for (let channel of this.config.channels) { + // Always put them in the first public channel. + let channel = this.config.channels[0]; + this.pushHistory({ + channel: channel.ID, + action: msg.action, + username: msg.username, + message: msg.message, + }); + + // If the current user is focused on another public channel, also post it there. + if (!this.isDM && this.channel !== channel.ID) { this.pushHistory({ - channel: channel.ID, + channel: this.channel.ID, action: msg.action, username: msg.username, message: msg.message,