Skip to content

email: fix unable to override templates in custom directory #7905

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

Merged
merged 3 commits into from
Feb 13, 2025
Merged

email: fix unable to override templates in custom directory #7905

merged 3 commits into from
Feb 13, 2025

Conversation

SongZihuan
Copy link
Contributor

@SongZihuan SongZihuan commented Jan 31, 2025

Describe the pull request

cusmtor/templates/mail目录下放置tmpl文件,无法被正确读取。

Checklist

  • [√] I agree to follow the Code of Conduct by submitting this pull request.
  • [√] I have read and acknowledge the Contributing guide.
  • [√] I have added test cases to cover the new code or have provided the test plan.

Test plan

FIleSystem在加载文件时,把customer + name目录拼接,然后在该目录下寻找文件是否存在,不存在则使用系统默认模板。
这个在web系统工作起来没有问题,但是在email系统工作旧出现了问题。因为email中,传入的custormcustorm/templates/mail,而FileSystem检索到的文件名是mail/xxx.tmpl,两者相加得到custorm/templates/mail/mail/xxx.tmpl,这将导致文件不存在。因为文件实际的路径是custorm/templates/mail/xxx.tmpl

我修复了传入调用NewTemplateFileSystem时传入的curstomDir参数,问题得到了解决。

Introduce a `customDir` variable to store the custom template directory path, improving code readability and reducing redundancy in both `web.go` and `email.go`. This change ensures that the custom directory is consistently referenced throughout the configuration.
@SongZihuan SongZihuan requested a review from unknwon as a code owner January 31, 2025 19:46
@unknwon
Copy link
Member

unknwon commented Feb 3, 2025

Thanks for the PR! Will review and test sometime soon.

@SongZihuan
Copy link
Contributor Author

Thanks for the PR! Will review and test sometime soon.

Thank you for your reply. Since English is not my native language, I used Chinese. If you need English or more help, please contact me. I will be happy to help you.

@unknwon
Copy link
Member

unknwon commented Feb 13, 2025

Thanks for the PR! Will review and test sometime soon.

Thank you for your reply. Since English is not my native language, I used Chinese. If you need English or more help, please contact me. I will be happy to help you.

Sorry for taking a while, looking at it now. And no worries I can speak Chinese, it's just for the sake of others watching/looking back to this PR, we only try to communicate in English (and I will update your PR title to reflect that upon merging).

@unknwon unknwon changed the title 解决邮件模板无法正确覆盖的问题 email: fix unable to override with custom template Feb 13, 2025
Copy link
Member

@unknwon unknwon left a comment

Choose a reason for hiding this comment

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

Thank you!

@unknwon unknwon added this to the 0.13.3 milestone Feb 13, 2025
@unknwon unknwon changed the title email: fix unable to override with custom template email: fix unable to override templates in custom directory Feb 13, 2025
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 10.73%. Comparing base (3650b32) to head (75ff247).
Report is 101 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7905      +/-   ##
==========================================
- Coverage   15.28%   10.73%   -4.55%     
==========================================
  Files         106      209     +103     
  Lines       13864    28867   +15003     
==========================================
+ Hits         2119     3099     +980     
- Misses      11465    25477   +14012     
- Partials      280      291      +11     

@unknwon unknwon merged commit 46a84fd into gogs:main Feb 13, 2025
14 checks passed
unknwon added a commit that referenced this pull request Jun 8, 2025
@unknwon
Copy link
Member

unknwon commented Jun 9, 2025

The 0.13.3 has been released that includes this patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants