Echo: Skip messages sent by blocked usernames
This commit is contained in:
parent
c910e5786a
commit
2e718e15a6
|
@ -27,11 +27,27 @@ var (
|
||||||
func (sub *Subscriber) SendEchoedMessages() {
|
func (sub *Subscriber) SendEchoedMessages() {
|
||||||
var echoes []messages.Message
|
var echoes []messages.Message
|
||||||
|
|
||||||
|
// Gather the subscriber's block list, so we don't echo users who are on it.
|
||||||
|
var blocks = map[string]interface{}{}
|
||||||
|
sub.muteMu.RLock()
|
||||||
|
for username := range sub.blocked {
|
||||||
|
blocks[username] = nil
|
||||||
|
}
|
||||||
|
for username := range sub.muted {
|
||||||
|
blocks[username] = nil
|
||||||
|
}
|
||||||
|
sub.muteMu.RUnlock()
|
||||||
|
|
||||||
// Read lock to collect the messages.
|
// Read lock to collect the messages.
|
||||||
echoLock.RLock()
|
echoLock.RLock()
|
||||||
|
|
||||||
for _, msgs := range echoMessages {
|
for _, msgs := range echoMessages {
|
||||||
echoes = append(echoes, msgs...)
|
for _, msg := range msgs {
|
||||||
|
if _, ok := blocks[msg.Username]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
echoes = append(echoes, msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the lock.
|
// Release the lock.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user