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

[Bug]: 邮件提醒里的超链接错误,导致不能通过邮件直达评论地址 || [Bug]: The hyperlink in the email reminder is wrong, resulting in the comment address not being directly accessible via email. #2144

Closed
skyreeves opened this issue Nov 7, 2023 · 1 comment
Labels
bug Something isn't working Inactive

Comments

@skyreeves
Copy link

skyreeves commented Nov 7, 2023

问题描述 | Describe the bug

邮件提醒里设置了点击前往原文查看完整的评论内容。也正如现在这个超链接,它是错误的,在comabout之间应该还有一个/才对。
于是我在Vercle的环境变量里将SITE_URL的值从https://skyreeves.com改为https://skyreeves.com/,发现问题可以解决,超链接就正常了。

但新的问题出现了,这样一来在文章里的评论,得到的邮件提醒超链接会变成https://skyreeves.com//post/xxx,com后面多了一个/导致打不开。

邮件提醒使用的官方模板,相关的4个环境变量没有配置,可能是大小超过了Vercle的限制,会失败,所以我是写在Github的index.js里:

const Application = require('@waline/vercel');

module.exports = Application({
  mailSubject: '{{parent.nick | safe}},您在「{{site.name | safe}}」上的评论收到了回复',
  mailTemplate: `
    <div style="border-top:2px solid #12ADDB;box-shadow:0 1px 3px #AAAAAA;line-height:180%;padding:0 15px 12px;margin:50px auto;font-size:12px;">
      <h2 style="border-bottom:1px solid #DDD;font-size:14px;font-weight:normal;padding:13px 0 10px 8px;">        
        您在博客<a style="text-decoration:none;color: #12ADDB;" href="{{site.url}}" target="_blank">{{site.name}}</a>上的评论有了新的回复
      </h2>
      <div style="padding:0 12px 0 12px;margin-top:18px">
		<p>{{parent.nick}},您曾发表评论:</p>
        <div style="background-color: #f5f5f5;padding: 10px 15px;margin:18px 0;word-wrap:break-word;">{{parent.comment | safe}}</div>
        <p><strong>{{self.nick}}</strong> 回复说:</p>
        <div style="background-color: #f5f5f5;padding: 10px 15px;margin:18px 0;word-wrap:break-word;">{{self.comment | safe}}</div>
        <p>您可以点击<a style="text-decoration:none; color:#12addb" href="{{site.postUrl}}" target="_blank">前往原文查看完整的回复內容</a>,欢迎再次光临<a style="text-decoration:none; color:#12addb" href="{{site.url}}" target="_blank">{{site.name}}</a>。</p>
        <br/>
      </div>
	  <div style="border-top:1px solid #DDD; padding:13px 0 0 8px;">
		该邮件为系统自动发送的邮件,请勿直接回复。
	  </div>
	  <br/>
    </div>`,
  mailSubjectAdmin: '您的博客「{{site.name | safe}}」收到了新评论',
  mailTemplateAdmin: `
    <div style="border-top:2px solid #12ADDB;box-shadow:0 1px 3px #AAAAAA;line-height:180%;padding:0 15px 12px;margin:50px auto;font-size:12px;">
      <h2 style="border-bottom:1px solid #DDD;font-size:14px;font-weight:normal;padding:13px 0 10px 8px;">        
        有人在<a style="text-decoration:none;color: #12ADDB;" href="{{site.url}}" target="_blank">{{site.name}}</a>发表了新的评论
      </h2>
      <div style="padding:0 12px 0 12px;margin-top:18px">
		<p><strong>{{self.nick}}</strong> 评论说:</p>
		<div style="background-color: #f5f5f5;padding: 10px 15px;margin:18px 0;word-wrap:break-word;">{{self.comment | safe}}</div>
        <p>您可以点击<a style="text-decoration:none; color:#12addb" href="{{site.postUrl}}" target="_blank">前往原文查看完整的评论内容。</a></p>
        <br/>
      </div>
	  <div style="border-top:1px solid #DDD; padding:13px 0 0 8px;">
		该邮件为系统自动发送的邮件,请勿直接回复。
	  </div>
	  <br/>
    </div>`
});

另外,我在Leancloud里查看评论数据,发现只要是在文章里的评论,链接显示为 "url": "/post/xxx.html,而在关于页面的评论链接显示为"url": "about"。是不是这里少了一个/导致的。
于是我将数据导出,将相关的部分修改为"url": "/about",再导入回,结果评论数据丢失。
我原本关于页面设置了评论id:comment_id: 'about',我将其改为comment_id: '/about',测试发现Leancloud 的数据链接还是显示为"url": "about"。所以我的猜想可能是错的。

其他使用hexo,与我相同主题的博客都没有这个问题。

问题网站 | Website URL

https://skyreeves.com/about

服务部署在哪里? | Where your waline deploy?

Vercel (Default)

数据存储在哪里?| Where your comment data store?

LeanCloud(https://leancloud.cn)


Problem description | Describe the bug

The email reminder is set to click Go to the original text to view the complete comment content. Just like the current hyperlink, it is wrong. There should be a / between com and about.
So I changed the value of SITE_URL from https://skyreeves.com to https://skyreeves.com/ in the Vercle environment variable and found that the problem could be solved and the hyperlink became normal.

But a new problem arises. As a result, the hyperlink in the email reminder for comments in the article will become https://skyreeves.com//post/xxx, and there is an extra / after com, causing the hit not open.

The official template used for email reminders has not configured the four related environment variables. It may be that the size exceeds the limit of Vercle and will fail, so I wrote it in Github's index.js:

const Application = require('@waline/vercel');

module.exports = Application({
  mailSubject: '{{parent.nick | safe}}, your comment on "{{site.name | safe}}" received a reply',
  mailTemplate: `
    <div style="border-top:2px solid #12ADDB;box-shadow:0 1px 3px #AAAAAA;line-height:180%;padding:0 15px 12px;margin:50px auto;font-size:12px;">
      <h2 style="border-bottom:1px solid #DDD;font-size:14px;font-weight:normal;padding:13px 0 10px 8px;">
        Your blog <a style="text-decoration:none;color: #12ADDB;" href="{{site.url}}" target="_blank">{{site.name}}</a> There is a new reply to the comment
      </h2>
      <div style="padding:0 12px 0 12px;margin-top:18px">
<p>{{parent.nick}}, you commented:</p>
        <div style="background-color: #f5f5f5;padding: 10px 15px;margin:18px 0;word-wrap:break-word;">{{parent.comment | safe}}</div>
        <p><strong>{{self.nick}}</strong> replied:</p>
        <div style="background-color: #f5f5f5;padding: 10px 15px;margin:18px 0;word-wrap:break-word;">{{self.comment | safe}}</div>
        <p>You can click <a style="text-decoration:none; color:#12addb" href="{{site.postUrl}}" target="_blank">to view the full reply content</a> , welcome to visit again<a style="text-decoration:none; color:#12addb" href="{{site.url}}" target="_blank">{{site.name}}</a>. </p>
        <br/>
      </div>
<div style="border-top:1px solid #DDD; padding:13px 0 0 8px;">
This email is automatically sent by the system, please do not reply directly.
</div>
<br/>
    </div>`,
  mailSubjectAdmin: 'Your blog "{{site.name | safe}}" has received new comments',
  mailTemplateAdmin: `
    <div style="border-top:2px solid #12ADDB;box-shadow:0 1px 3px #AAAAAA;line-height:180%;padding:0 15px 12px;margin:50px auto;font-size:12px;">
      <h2 style="border-bottom:1px solid #DDD;font-size:14px;font-weight:normal;padding:13px 0 10px 8px;">
        Someone posted something new at <a style="text-decoration:none;color: #12ADDB;" href="{{site.url}}" target="_blank">{{site.name}}</a> comment of
      </h2>
      <div style="padding:0 12px 0 12px;margin-top:18px">
<p><strong>{{self.nick}}</strong> commented:</p>
<div style="background-color: #f5f5f5;padding: 10px 15px;margin:18px 0;word-wrap:break-word;">{{self.comment | safe}}</div>
        <p>You can click <a style="text-decoration:none; color:#12addb" href="{{site.postUrl}}" target="_blank"> to view the full review content. </a></p>
        <br/>
      </div>
<div style="border-top:1px solid #DDD; padding:13px 0 0 8px;">
This email is automatically sent by the system, please do not reply directly.
</div>
<br/>
    </div>`
});

In addition, I checked the comment data in Leancloud and found that as long as the comment is in the article, the link is displayed as "url": "/post/xxx.html, while the comment link on the About page is displayed as "url": "about". Is it caused by missing a / here?
So I exported the data, changed the relevant part to "url": "/about", and then imported it back, but the comment data was lost.
I originally set the comment id on the About page: comment_id: 'about'. I changed it to comment_id: '/about'. After testing, I found that the data link of Leancloud is still displayed as "url": " about". So my guess may be wrong.

Other blogs using hexo with the same theme as mine don't have this problem.

Question Website | Website URL

https://skyreeves.com/about

Where is the service deployed? | Where your waline deploy?

Vercel (Default)

Where is the data stored? | Where your comment data store?

LeanCloud(https://leancloud.cn)

@skyreeves skyreeves added the bug Something isn't working label Nov 7, 2023
@github-actions github-actions bot changed the title [Bug]: 邮件提醒里的超链接错误,导致不能通过邮件直达评论地址 [Bug]: 邮件提醒里的超链接错误,导致不能通过邮件直达评论地址 || [Bug]: The hyperlink in the email reminder is wrong, resulting in the comment address not being directly accessible via email. Nov 7, 2023
@lizheming
Copy link
Collaborator

lizheming commented Feb 17, 2024

目前邮件提醒的完整 url 的生成是依赖 comment_id 需要为当前 url 的 pathname 这个潜规则的。需要将你的页面的 comment_id 设置成 /about,SITE_URL 不增加 / 后缀,就能保持正常。另外此处配置修改不会影响历史数据,历史的评论需要手动修改迁移。


Currently, the generation of the complete URL of the email reminder relies on the unspoken rule that comment_id needs to be the pathname of the current URL. You need to set the comment_id of your page to /about, and the SITE_URL will remain normal without adding the / suffix. In addition, configuration modifications here will not affect historical data, and historical comments need to be manually modified and migrated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Inactive
Projects
None yet
Development

No branches or pull requests

2 participants