[MM-16232] ID loaded push notifications (#13137)
* Update BuildPushNotificationMessage (#12974) * Update BuildPushNotificationMessage * Included Category, Version, and Type * Remove unnecessary function args * [MM-16232] Build and return fetched notification (#13085) * Build and return fetched notification * Remove check on PushNotificationContents * Ran i18n-extract * Get UserId from session * Re-add ReturnStatusOK * Remove UserId from PushNotificationAck * Always include channel name * [MM-16232] Return after writing response and add default message (#13127) * Return after writing response and add default message * Include channel ID as well * Localize default message * Fix i18n
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
2571d97723
Коммит
d44d563ef3
@@ -898,7 +898,7 @@ func TestGetPushNotificationMessage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildPushNotificationMessage(t *testing.T) {
|
||||
func TestBuildPushNotificationMessageMentions(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -947,3 +947,64 @@ func TestBuildPushNotificationMessage(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildPushNotificationMessageContents(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
team := th.CreateTeam()
|
||||
sender := th.CreateUser()
|
||||
receiver := th.CreateUser()
|
||||
th.LinkUserToTeam(sender, team)
|
||||
th.LinkUserToTeam(receiver, team)
|
||||
channel := th.CreateChannel(team)
|
||||
th.AddUserToChannel(sender, channel)
|
||||
th.AddUserToChannel(receiver, channel)
|
||||
|
||||
post := th.CreatePost(channel)
|
||||
|
||||
explicitMention := false
|
||||
channelWideMention := false
|
||||
replyToThreadType := ""
|
||||
|
||||
receiverLocale := utils.GetUserTranslations(receiver.Locale)
|
||||
|
||||
for name, tc := range map[string]struct {
|
||||
contentsConfig string
|
||||
expectedMsg model.PushNotification
|
||||
}{
|
||||
"only post ID, channel ID, and message included in push notification": {
|
||||
contentsConfig: model.ID_LOADED_NOTIFICATION,
|
||||
expectedMsg: model.PushNotification{
|
||||
PostId: post.Id,
|
||||
ChannelId: post.ChannelId,
|
||||
Category: model.CATEGORY_CAN_REPLY,
|
||||
Version: model.PUSH_MESSAGE_V2,
|
||||
Type: model.PUSH_TYPE_ID_LOADED,
|
||||
Message: receiverLocale("api.push_notification.id_loaded.default_message"),
|
||||
},
|
||||
},
|
||||
"full contents included in push notification": {
|
||||
contentsConfig: model.GENERIC_NOTIFICATION,
|
||||
expectedMsg: model.PushNotification{
|
||||
Category: model.CATEGORY_CAN_REPLY,
|
||||
Version: model.PUSH_MESSAGE_V2,
|
||||
Type: model.PUSH_TYPE_MESSAGE,
|
||||
PostId: post.Id,
|
||||
TeamId: channel.TeamId,
|
||||
ChannelId: channel.Id,
|
||||
ChannelName: channel.Name,
|
||||
RootId: post.RootId,
|
||||
SenderId: post.UserId,
|
||||
SenderName: sender.Username,
|
||||
Message: fmt.Sprintf("%s posted a message.", sender.Username),
|
||||
},
|
||||
},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.EmailSettings.PushNotificationContents = tc.contentsConfig })
|
||||
msg := th.App.BuildPushNotificationMessage(post, receiver, channel, channel.Name, sender.Username, explicitMention, channelWideMention, replyToThreadType)
|
||||
assert.Equal(t, tc.expectedMsg, msg)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user