-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Refine mail templates #35150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Refine mail templates #35150
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
061d817
MOVE
NorthRealm 9993fc6
MOVE
NorthRealm d890db1
MOVE
NorthRealm 5c6c94e
UPDATE
NorthRealm 547df2a
Merge remote-tracking branch 'origin/main' into patch-mail-templates-1
NorthRealm 1ebc80b
Merge branch 'main' into patch-mail-templates-1
NorthRealm 3ff5727
UPDATE
NorthRealm 08e9d8b
Merge branch 'main' into patch-mail-templates-1
NorthRealm d767417
Merge branch 'main' into patch-mail-templates-1
NorthRealm 77f0fb6
R
NorthRealm 6f1fe2b
UPDATE
NorthRealm 00705e6
S*****S LINTER WHAT ARE YOU TALKING ABOUT
NorthRealm f335280
not working
NorthRealm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,7 +116,7 @@ func TestComposeIssueComment(t *testing.T) { | |
setting.IncomingEmail.Enabled = true | ||
defer func() { setting.IncomingEmail.Enabled = false }() | ||
|
||
prepareMailTemplates("issue/comment", subjectTpl, bodyTpl) | ||
prepareMailTemplates("repo/issue/comment", subjectTpl, bodyTpl) | ||
|
||
recipients := []*user_model.User{{Name: "Test", Email: "[email protected]"}, {Name: "Test2", Email: "[email protected]"}} | ||
msgs, err := composeIssueCommentMessages(t.Context(), &mailComment{ | ||
|
@@ -161,7 +161,7 @@ func TestComposeIssueComment(t *testing.T) { | |
func TestMailMentionsComment(t *testing.T) { | ||
doer, _, issue, comment := prepareMailerTest(t) | ||
comment.Poster = doer | ||
prepareMailTemplates("issue/comment", subjectTpl, bodyTpl) | ||
prepareMailTemplates("repo/issue/comment", subjectTpl, bodyTpl) | ||
mails := 0 | ||
|
||
defer test.MockVariableValue(&SendAsync, func(msgs ...*sender_service.Message) { | ||
|
@@ -176,7 +176,7 @@ func TestMailMentionsComment(t *testing.T) { | |
func TestComposeIssueMessage(t *testing.T) { | ||
doer, _, issue, _ := prepareMailerTest(t) | ||
|
||
prepareMailTemplates("issue/new", subjectTpl, bodyTpl) | ||
prepareMailTemplates("repo/issue/new", subjectTpl, bodyTpl) | ||
recipients := []*user_model.User{{Name: "Test", Email: "[email protected]"}, {Name: "Test2", Email: "[email protected]"}} | ||
msgs, err := composeIssueCommentMessages(t.Context(), &mailComment{ | ||
Issue: issue, Doer: doer, ActionType: activities_model.ActionCreateIssue, | ||
|
@@ -205,14 +205,14 @@ func TestTemplateSelection(t *testing.T) { | |
doer, repo, issue, comment := prepareMailerTest(t) | ||
recipients := []*user_model.User{{Name: "Test", Email: "[email protected]"}} | ||
|
||
prepareMailTemplates("issue/default", "issue/default/subject", "issue/default/body") | ||
prepareMailTemplates("repo/issue/default", "repo/issue/default/subject", "repo/issue/default/body") | ||
|
||
texttmpl.Must(LoadedTemplates().SubjectTemplates.New("issue/new").Parse("issue/new/subject")) | ||
texttmpl.Must(LoadedTemplates().SubjectTemplates.New("pull/comment").Parse("pull/comment/subject")) | ||
texttmpl.Must(LoadedTemplates().SubjectTemplates.New("issue/close").Parse("")) // Must default to a fallback subject | ||
template.Must(LoadedTemplates().BodyTemplates.New("issue/new").Parse("issue/new/body")) | ||
template.Must(LoadedTemplates().BodyTemplates.New("pull/comment").Parse("pull/comment/body")) | ||
template.Must(LoadedTemplates().BodyTemplates.New("issue/close").Parse("issue/close/body")) | ||
texttmpl.Must(LoadedTemplates().SubjectTemplates.New("repo/issue/new").Parse("repo/issue/new/subject")) | ||
texttmpl.Must(LoadedTemplates().SubjectTemplates.New("repo/pull/comment").Parse("repo/pull/comment/subject")) | ||
texttmpl.Must(LoadedTemplates().SubjectTemplates.New("repo/issue/close").Parse("")) // Must default to a fallback subject | ||
template.Must(LoadedTemplates().BodyTemplates.New("repo/issue/new").Parse("repo/issue/new/body")) | ||
template.Must(LoadedTemplates().BodyTemplates.New("repo/pull/comment").Parse("repo/pull/comment/body")) | ||
template.Must(LoadedTemplates().BodyTemplates.New("repo/issue/close").Parse("repo/issue/close/body")) | ||
|
||
expect := func(t *testing.T, msg *sender_service.Message, expSubject, expBody string) { | ||
subject := msg.ToMessage().GetGenHeader("Subject") | ||
|
@@ -227,27 +227,27 @@ func TestTemplateSelection(t *testing.T) { | |
Issue: issue, Doer: doer, ActionType: activities_model.ActionCreateIssue, | ||
Content: "test body", | ||
}, recipients, false, "TestTemplateSelection") | ||
expect(t, msg, "issue/new/subject", "issue/new/body") | ||
expect(t, msg, "repo/issue/new/subject", "repo/issue/new/body") | ||
|
||
msg = testComposeIssueCommentMessage(t, &mailComment{ | ||
Issue: issue, Doer: doer, ActionType: activities_model.ActionCommentIssue, | ||
Content: "test body", Comment: comment, | ||
}, recipients, false, "TestTemplateSelection") | ||
expect(t, msg, "issue/default/subject", "issue/default/body") | ||
expect(t, msg, "repo/issue/default/subject", "repo/issue/default/body") | ||
|
||
pull := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2, Repo: repo, Poster: doer}) | ||
comment = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 4, Issue: pull}) | ||
msg = testComposeIssueCommentMessage(t, &mailComment{ | ||
Issue: pull, Doer: doer, ActionType: activities_model.ActionCommentPull, | ||
Content: "test body", Comment: comment, | ||
}, recipients, false, "TestTemplateSelection") | ||
expect(t, msg, "pull/comment/subject", "pull/comment/body") | ||
expect(t, msg, "repo/pull/comment/subject", "repo/pull/comment/body") | ||
|
||
msg = testComposeIssueCommentMessage(t, &mailComment{ | ||
Issue: issue, Doer: doer, ActionType: activities_model.ActionCloseIssue, | ||
Content: "test body", Comment: comment, | ||
}, recipients, false, "TestTemplateSelection") | ||
expect(t, msg, "Re: [user2/repo1] issue1 (#1)", "issue/close/body") | ||
expect(t, msg, "Re: [user2/repo1] issue1 (#1)", "repo/issue/close/body") | ||
} | ||
|
||
func TestTemplateServices(t *testing.T) { | ||
|
@@ -257,7 +257,7 @@ func TestTemplateServices(t *testing.T) { | |
expect := func(t *testing.T, issue *issues_model.Issue, comment *issues_model.Comment, doer *user_model.User, | ||
actionType activities_model.ActionType, fromMention bool, tplSubject, tplBody, expSubject, expBody string, | ||
) { | ||
prepareMailTemplates("issue/default", tplSubject, tplBody) | ||
prepareMailTemplates("repo/issue/default", tplSubject, tplBody) | ||
recipients := []*user_model.User{{Name: "Test", Email: "[email protected]"}} | ||
msg := testComposeIssueCommentMessage(t, &mailComment{ | ||
Issue: issue, Doer: doer, ActionType: actionType, | ||
|
@@ -524,7 +524,7 @@ func TestEmbedBase64Images(t *testing.T) { | |
att2ImgBase64 := fmt.Sprintf(`<img src="%s"/>`, att2Base64) | ||
|
||
t.Run("ComposeMessage", func(t *testing.T) { | ||
prepareMailTemplates("issue/new", subjectTpl, bodyTpl) | ||
prepareMailTemplates("repo/issue/new", subjectTpl, bodyTpl) | ||
|
||
issue.Content = fmt.Sprintf(`MSG-BEFORE <image src="attachments/%s"> MSG-AFTER`, att1.UUID) | ||
require.NoError(t, issues_model.UpdateIssueCols(t.Context(), issue, "content")) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Inviter: | ||
DisplayName: Inviter Display Name | ||
|
||
Team: | ||
Name: Team name | ||
|
||
Organization: | ||
DisplayName: Organization Display Name | ||
|
||
InviteURL: http://localhost/org/team/invite | ||
|
||
Invite: | ||
Email: [email protected] |
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.