0

Do not send user joined events to chat clients if stream is not active. Closes #750

This commit is contained in:
Gabe Kangas 2021-02-21 16:21:12 -08:00
parent b47589fa8f
commit 0bfd9f8e1f
3 changed files with 10 additions and 3 deletions

View File

@ -77,10 +77,11 @@ func (s *server) usernameChanged(msg models.NameChangeEvent) {
}
func (s *server) userJoined(msg models.UserJoinedEvent) {
for _, c := range s.Clients {
c.userJoinedChannel <- msg
if s.listener.IsStreamConnected() {
for _, c := range s.Clients {
c.userJoinedChannel <- msg
}
}
go webhooks.SendChatEventUserJoined(msg)
}

View File

@ -22,6 +22,11 @@ func (cl ChatListenerImpl) ClientRemoved(clientID string) {
func (cl ChatListenerImpl) MessageSent(message models.ChatEvent) {
}
// IsStreamConnected will return if the stream is connected.
func (cl ChatListenerImpl) IsStreamConnected() bool {
return IsStreamConnected()
}
// SendMessageToChat sends a message to the chat server.
func SendMessageToChat(message models.ChatEvent) error {
chat.SendMessage(message)

View File

@ -5,4 +5,5 @@ type ChatListener interface {
ClientAdded(client Client)
ClientRemoved(clientID string)
MessageSent(message ChatEvent)
IsStreamConnected() bool
}