Skip to content
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

Add custom subject for all kinds of mail templates #27861

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lng2020
Copy link
Member

@lng2020 lng2020 commented Nov 1, 2023

Apply template subject to all mail types (activate account, reset password, etc.).
Follow #8329 (it's in the future enhancement list of that PR but it got forgotten for 4 years)
Fix #27793

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 1, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 1, 2023
@lng2020 lng2020 changed the title Add mail template subject for all kinds Add custom subject for all kinds of mail templates Nov 1, 2023
Comment on lines +78 to +82
subjectFromTemplate := subjectFromTemplate(string(tpl), data)
if subjectFromTemplate != "" {
subject = subjectFromTemplate
}
data["Subject"] = subject
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we extract this into a new function setSubject that takes as parameters data, defaultSubject and always call that instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. Will change it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Em...Now I think the current way is better.
subject var is also used in NewMessage(u.Email, subject, content.String()). If using setSubject and removing the subject var, then we should use NewMessage(u.Email, data["Subject"].(string), content.String()) instead. I don't know if it's a good idea to use type assertion in such simple code.

@delvh delvh added the type/enhancement An improvement of existing functionality label Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot change email subjects
3 participants