MM-53924 - Implement push notifications plugin hook and plugin api method (#24350)
* Revert "MM-52804 - Implement SendPushNotification plugin api method (#24273)" This reverts commit8418eefb75. * Revert "MM-53924 - Implement NotificationWillBePushed plugin hook (#24263)" This reverts commitf13a531bca. * implement NotificationWillBePushed plugin hook * implement SendPushNotification plugin api method * move where we're setting post and channel type * fix comment --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
dad579daee
Коммит
69c11cfe14
@@ -1344,20 +1344,28 @@ func TestHookNotificationWillBePushed(t *testing.T) {
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
testCode string
|
||||
expectedNotifications int
|
||||
name string
|
||||
testCode string
|
||||
expectedNotifications int
|
||||
expectedNotificationMessage string
|
||||
}{
|
||||
{
|
||||
name: "successfully pushed",
|
||||
testCode: `return false`,
|
||||
testCode: `return nil, ""`,
|
||||
expectedNotifications: 6,
|
||||
},
|
||||
{
|
||||
name: "push notification rejected",
|
||||
testCode: `return true`,
|
||||
testCode: `return nil, "rejected"`,
|
||||
expectedNotifications: 0,
|
||||
},
|
||||
{
|
||||
name: "push notification modified",
|
||||
testCode: `notification.Message = "brand new message"
|
||||
return notification, ""`,
|
||||
expectedNotifications: 6,
|
||||
expectedNotificationMessage: "brand new message",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
@@ -1440,7 +1448,11 @@ func TestHookNotificationWillBePushed(t *testing.T) {
|
||||
case model.PushTypeMessage:
|
||||
numMessages++
|
||||
assert.Equal(t, th.BasicChannel.Id, n.ChannelId)
|
||||
assert.Contains(t, n.Message, "mentioned you")
|
||||
if tt.expectedNotificationMessage != "" {
|
||||
assert.Equal(t, tt.expectedNotificationMessage, n.Message)
|
||||
} else {
|
||||
assert.Contains(t, n.Message, "mentioned you")
|
||||
}
|
||||
default:
|
||||
assert.Fail(t, "should not receive any other push notification types")
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user