MM-53924 - Implement push notifications plugin hook and plugin api method (#24350)

* Revert "MM-52804 - Implement SendPushNotification plugin api method (#24273)"

This reverts commit 8418eefb75.

* Revert "MM-53924 - Implement NotificationWillBePushed plugin hook (#24263)"

This reverts commit f13a531bca.

* 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>
Этот коммит содержится в:
Christopher Poile
2023-08-24 12:33:53 -04:00
коммит произвёл GitHub
родитель dad579daee
Коммит 69c11cfe14
16 изменённых файлов: 169 добавлений и 166 удалений

Просмотреть файл

@@ -2266,13 +2266,22 @@ func TestSendPushNotification(t *testing.T) {
defer wg.Done()
post := th.CreatePost(th.BasicChannel)
post.Message = "started a conversation"
notification := &model.PluginPushNotification{
Post: post,
Channel: th.BasicChannel,
UserID: user.Id,
notification := &model.PushNotification{
Category: model.CategoryCanReply,
Version: model.PushMessageV2,
Type: model.PushTypeMessage,
TeamId: th.BasicChannel.TeamId,
ChannelId: th.BasicChannel.Id,
PostId: post.Id,
RootId: post.RootId,
SenderId: post.UserId,
SenderName: "Sender Name",
PostType: post.Type,
ChannelType: th.BasicChannel.Type,
Message: "Custom message",
}
appErr := api.SendPluginPushNotification(notification)
require.NoError(t, appErr)
appErr := api.SendPushNotification(notification, user.Id)
require.Nil(t, appErr)
}(*data.user)
}
wg.Wait()
@@ -2286,7 +2295,7 @@ func TestSendPushNotification(t *testing.T) {
case model.PushTypeMessage:
numMessages++
assert.Equal(t, th.BasicChannel.Id, n.ChannelId)
assert.Equal(t, fmt.Sprintf("@%s: started a conversation", th.BasicUser.GetDisplayName(model.ShowUsername)), n.Message)
assert.Equal(t, "Custom message", n.Message)
default:
assert.Fail(t, "should not receive any other push notification types")
}