Extracting email functions into a service (#14802)
* Extracting email functions into a service * Fixing two shadowing errors * Address PR review comments Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
10f5a8890c
Коммит
b977017ca7
@@ -23,7 +23,7 @@ func TestHandleNewNotifications(t *testing.T) {
|
||||
id3 := model.NewId()
|
||||
|
||||
// test queueing of received posts by user
|
||||
job := NewEmailBatchingJob(th.Server, 128)
|
||||
job := NewEmailBatchingJob(th.Server.EmailService, 128)
|
||||
|
||||
job.handleNewNotifications()
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestHandleNewNotifications(t *testing.T) {
|
||||
require.Len(t, job.pendingNotifications[id3], 1, "should have received 1 post for user3")
|
||||
|
||||
// test ordering of received posts
|
||||
job = NewEmailBatchingJob(th.Server, 128)
|
||||
job = NewEmailBatchingJob(th.Server.EmailService, 128)
|
||||
|
||||
job.Add(&model.User{Id: id1}, &model.Post{UserId: id1, Message: "test1"}, &model.Team{Name: "team"})
|
||||
job.Add(&model.User{Id: id1}, &model.Post{UserId: id1, Message: "test2"}, &model.Team{Name: "team"})
|
||||
@@ -77,7 +77,7 @@ func TestCheckPendingNotifications(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
job := NewEmailBatchingJob(th.Server, 128)
|
||||
job := NewEmailBatchingJob(th.Server.EmailService, 128)
|
||||
job.pendingNotifications[th.BasicUser.Id] = []*batchedNotification{
|
||||
{
|
||||
post: &model.Post{
|
||||
@@ -205,7 +205,7 @@ func TestCheckPendingNotificationsDefaultInterval(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
job := NewEmailBatchingJob(th.Server, 128)
|
||||
job := NewEmailBatchingJob(th.Server.EmailService, 128)
|
||||
|
||||
// bypasses recent user activity check
|
||||
channelMember, err := th.App.Srv().Store.Channel().GetMember(th.BasicChannel.Id, th.BasicUser.Id)
|
||||
@@ -243,7 +243,7 @@ func TestCheckPendingNotificationsCantParseInterval(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
job := NewEmailBatchingJob(th.Server, 128)
|
||||
job := NewEmailBatchingJob(th.Server.EmailService, 128)
|
||||
|
||||
// bypasses recent user activity check
|
||||
channelMember, err := th.App.Srv().Store.Channel().GetMember(th.BasicChannel.Id, th.BasicUser.Id)
|
||||
@@ -304,7 +304,7 @@ func TestRenderBatchedPostGeneric(t *testing.T) {
|
||||
return translationID
|
||||
}
|
||||
|
||||
var rendered = th.Server.renderBatchedPost(notification, channel, sender, "http://localhost:8065", "", translateFunc, "en", model.EMAIL_NOTIFICATION_CONTENTS_GENERIC)
|
||||
var rendered = th.Server.EmailService.renderBatchedPost(notification, channel, sender, "http://localhost:8065", "", translateFunc, "en", model.EMAIL_NOTIFICATION_CONTENTS_GENERIC)
|
||||
require.NotContains(t, rendered, post.Message, "Rendered email should not contain post contents when email notification contents type is set to Generic.")
|
||||
}
|
||||
|
||||
@@ -329,6 +329,6 @@ func TestRenderBatchedPostFull(t *testing.T) {
|
||||
return translationID
|
||||
}
|
||||
|
||||
var rendered = th.Server.renderBatchedPost(notification, channel, sender, "http://localhost:8065", "", translateFunc, "en", model.EMAIL_NOTIFICATION_CONTENTS_FULL)
|
||||
var rendered = th.Server.EmailService.renderBatchedPost(notification, channel, sender, "http://localhost:8065", "", translateFunc, "en", model.EMAIL_NOTIFICATION_CONTENTS_FULL)
|
||||
require.Contains(t, rendered, post.Message, "Rendered email should contain post contents when email notification contents type is set to Full.")
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user