Only send 'delete channel' event when channel was removed
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2020-08-09 10:06:12 +02:00
parent 330931742b
commit 08ae30b305
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -260,6 +260,14 @@ func (b *memoryBackend) ChannelsDelete(uid string) error {
conn := b.pool.Get()
defer conn.Close()
removed := false
b.lock.RLock()
if _, e := b.Channels[uid]; e {
removed = true
}
b.lock.RUnlock()
removeChannelFromRedis(conn, uid)
b.lock.Lock()
@ -267,7 +275,9 @@ func (b *memoryBackend) ChannelsDelete(uid string) error {
delete(b.Feeds, uid)
b.lock.Unlock()
if removed {
b.broker.Notifier <- sse.Message{Event: "delete channel", Object: channelDeletedMessage{1, uid}}
}
return nil
}