TRY 2: MM-56201, MM-56280: Suppress typing and emoji events (#26282)
* Revert "Revert "MM-56201, MM-56280: Suppress typing and emoji events (#25794)…"
This reverts commit 6808a1c733.
* Remove bad ff merge
```release-note
NONE
```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6808a1c733
Коммит
64504b80e6
@@ -4,6 +4,7 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -15,6 +16,8 @@ import (
|
||||
)
|
||||
|
||||
func TestWebConnShouldSendEvent(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_WEBSOCKETEVENTSCOPE", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_WEBSOCKETEVENTSCOPE")
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
session, err := th.App.CreateSession(th.Context, &model.Session{UserId: th.BasicUser.Id, Roles: th.BasicUser.GetRawRoles(), TeamMembers: []*model.TeamMember{
|
||||
@@ -162,6 +165,63 @@ func TestWebConnShouldSendEvent(t *testing.T) {
|
||||
assert.False(t, adminUserWc.ShouldSendEvent(event), "did not expect admin")
|
||||
})
|
||||
|
||||
t.Run("should not send typing event unless in scope", func(t *testing.T) {
|
||||
event2 := model.NewWebSocketEvent(model.WebsocketEventTyping, "", th.BasicChannel.Id, "", nil, "")
|
||||
// Basic, unset case
|
||||
basicUserWc.SetActiveChannelID(platform.UnsetPresenceIndicator)
|
||||
basicUserWc.SetActiveRHSThreadChannelID(platform.UnsetPresenceIndicator)
|
||||
basicUserWc.SetActiveThreadViewThreadChannelID(platform.UnsetPresenceIndicator)
|
||||
assert.True(t, basicUserWc.ShouldSendEvent(event2))
|
||||
|
||||
// Active channel is set to something else, thread unset
|
||||
basicUserWc.SetActiveChannelID("ch1")
|
||||
basicUserWc.SetActiveRHSThreadChannelID(platform.UnsetPresenceIndicator)
|
||||
basicUserWc.SetActiveThreadViewThreadChannelID(platform.UnsetPresenceIndicator)
|
||||
assert.True(t, basicUserWc.ShouldSendEvent(event2))
|
||||
|
||||
// Active channel is unset, thread set
|
||||
basicUserWc.SetActiveChannelID(platform.UnsetPresenceIndicator)
|
||||
basicUserWc.SetActiveRHSThreadChannelID("ch1")
|
||||
basicUserWc.SetActiveThreadViewThreadChannelID("ch2")
|
||||
assert.True(t, basicUserWc.ShouldSendEvent(event2))
|
||||
|
||||
// both are set to correct channel
|
||||
basicUserWc.SetActiveChannelID(th.BasicChannel.Id)
|
||||
basicUserWc.SetActiveRHSThreadChannelID(th.BasicChannel.Id)
|
||||
basicUserWc.SetActiveThreadViewThreadChannelID(th.BasicChannel.Id)
|
||||
assert.True(t, basicUserWc.ShouldSendEvent(event2))
|
||||
|
||||
// channel is correct, thread is something else.
|
||||
basicUserWc.SetActiveChannelID(th.BasicChannel.Id)
|
||||
basicUserWc.SetActiveRHSThreadChannelID("ch1")
|
||||
basicUserWc.SetActiveThreadViewThreadChannelID("ch2")
|
||||
assert.True(t, basicUserWc.ShouldSendEvent(event2))
|
||||
|
||||
// channel is wrong, thread is correct.
|
||||
basicUserWc.SetActiveChannelID("ch1")
|
||||
basicUserWc.SetActiveRHSThreadChannelID(th.BasicChannel.Id)
|
||||
basicUserWc.SetActiveThreadViewThreadChannelID(th.BasicChannel.Id)
|
||||
assert.True(t, basicUserWc.ShouldSendEvent(event2))
|
||||
|
||||
// FINALLY, both are set to something else.
|
||||
basicUserWc.SetActiveChannelID("ch1")
|
||||
basicUserWc.SetActiveRHSThreadChannelID("ch1")
|
||||
basicUserWc.SetActiveThreadViewThreadChannelID("ch2")
|
||||
assert.False(t, basicUserWc.ShouldSendEvent(event2))
|
||||
|
||||
// Different threads and channel
|
||||
basicUserWc.SetActiveChannelID("ch1")
|
||||
basicUserWc.SetActiveRHSThreadChannelID("ch2")
|
||||
basicUserWc.SetActiveThreadViewThreadChannelID("ch3")
|
||||
assert.False(t, basicUserWc.ShouldSendEvent(event2))
|
||||
|
||||
// Other channel. Thread unset explicitly.
|
||||
basicUserWc.SetActiveChannelID("ch1")
|
||||
basicUserWc.SetActiveRHSThreadChannelID("")
|
||||
basicUserWc.SetActiveThreadViewThreadChannelID("")
|
||||
assert.False(t, basicUserWc.ShouldSendEvent(event2))
|
||||
})
|
||||
|
||||
t.Run("should send to basic user and admin in channel2", func(t *testing.T) {
|
||||
event = event.SetBroadcast(&model.WebsocketBroadcast{ChannelId: channel2.Id})
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user