[MM-58500] Turn off PostedAck when the connection is no longer registered (#27212)
* [MM-58500] Turn off PostedAck when the connection is no longer registered * Expose active and just check for active instead
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4163db4e5e
Коммит
4ec50a7ddd
@@ -91,6 +91,7 @@ func TestPostedAckHook_Process(t *testing.T) {
|
||||
Platform: &platform.PlatformService{},
|
||||
PostedAck: true,
|
||||
}
|
||||
webConn.Active.Store(true)
|
||||
webConn.SetSession(&model.Session{})
|
||||
|
||||
t.Run("should ack if user is in the list of users to notify", func(t *testing.T) {
|
||||
@@ -142,14 +143,33 @@ func TestPostedAckHook_Process(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should not ack if posted ack is false", func(t *testing.T) {
|
||||
mobileWebConn := &platform.WebConn{
|
||||
noAckWebConn := &platform.WebConn{
|
||||
UserId: userID,
|
||||
Platform: &platform.PlatformService{},
|
||||
PostedAck: false,
|
||||
}
|
||||
noAckWebConn.Active.Store(true)
|
||||
msg := platform.MakeHookedWebSocketEvent(model.NewWebSocketEvent(model.WebsocketEventPosted, "", "", "", nil, ""))
|
||||
|
||||
hook.Process(msg, mobileWebConn, map[string]any{
|
||||
hook.Process(msg, noAckWebConn, map[string]any{
|
||||
"posted_user_id": model.NewId(),
|
||||
"channel_type": model.ChannelTypeDirect,
|
||||
"users": []string{},
|
||||
})
|
||||
|
||||
assert.Nil(t, msg.Event().GetData()["should_ack"])
|
||||
})
|
||||
|
||||
t.Run("should not ack if connection is not active", func(t *testing.T) {
|
||||
inactiveWebConn := &platform.WebConn{
|
||||
UserId: userID,
|
||||
Platform: &platform.PlatformService{},
|
||||
PostedAck: false,
|
||||
}
|
||||
inactiveWebConn.Active.Store(true)
|
||||
msg := platform.MakeHookedWebSocketEvent(model.NewWebSocketEvent(model.WebsocketEventPosted, "", "", "", nil, ""))
|
||||
|
||||
hook.Process(msg, inactiveWebConn, map[string]any{
|
||||
"posted_user_id": model.NewId(),
|
||||
"channel_type": model.ChannelTypeDirect,
|
||||
"users": []string{},
|
||||
|
||||
Ссылка в новой задаче
Block a user