Skip to content

Commit

Permalink
feat: v3.7.8
Browse files Browse the repository at this point in the history
  • Loading branch information
surmon-china committed Jan 5, 2022
1 parent f5fe154 commit a41699c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 43 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodepress",
"version": "3.7.7",
"version": "3.7.8",
"description": "RESTful API service for Surmon.me blog",
"author": {
"name": "Surmon",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/comment/comment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class CommentService {
if (comment.pid) {
this.commentModel.findOne({ id: comment.pid }).then((parentComment) => {
if (parentComment?.author.email) {
const subject = `Your comment ${parentComment.id} has a new reply`
const subject = `Your comment #${parentComment.id} has a new reply`
this.emailService.sendMailAs(APP_CONFIG.APP.FE_NAME, {
to: parentComment.author.email,
subject,
Expand Down
94 changes: 53 additions & 41 deletions src/modules/vote/vote.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ export class VoteController {
const userInfo = await this.disqusPublicService.getUserInfo(token)
const isAdmin = userInfo.username === APP_CONFIG.DISQUS.adminUsername
const moderator = isAdmin ? ` / Moderator` : ''
return [`(Disqus user${moderator})`, `${userInfo.name}`, userInfo.url, userInfo.profileUrl]
return [`${userInfo.name} (Disqus user${moderator})`, userInfo.url, userInfo.profileUrl]
.filter(Boolean)
.join(' · ')
} catch (error) {}
}
// local user
if (author) {
return `(Guest user) ${author.name}`
return `${author.name} (Guest user)`
}
// guest user
return `Anonymous user`
return null
}

private async getTargetTitle(post_id: number) {
Expand Down Expand Up @@ -148,14 +148,18 @@ export class VoteController {
// Disqus
this.voteDisqusThread(CommentPostID.Guestbook, 1, token?.access_token).catch(() => {})
// email to admin
this.emailToTargetVoteMessage({
to: APP_CONFIG.EMAIL.admin,
subject: `You have a new site vote`,
on: await this.getTargetTitle(CommentPostID.Guestbook),
vote: '+1',
author: await this.getAuthor(voteBody.author, token?.access_token),
location: await this.ipService.queryLocation(visitor.ip),
link: getPermalinkByID(CommentPostID.Guestbook),
this.getAuthor(voteBody.author, token?.access_token).then(async (author) => {
if (author) {
this.emailToTargetVoteMessage({
to: APP_CONFIG.EMAIL.admin,
subject: `You have a new site vote`,
on: await this.getTargetTitle(CommentPostID.Guestbook),
vote: '+1',
author,
location: await this.ipService.queryLocation(visitor.ip),
link: getPermalinkByID(CommentPostID.Guestbook),
})
}
})

return likes
Expand All @@ -173,14 +177,18 @@ export class VoteController {
// Disqus
this.voteDisqusThread(voteBody.article_id, voteBody.vote, token?.access_token).catch(() => {})
// email to admin
this.emailToTargetVoteMessage({
to: APP_CONFIG.EMAIL.admin,
subject: `You have a new article vote`,
on: await this.getTargetTitle(voteBody.article_id),
vote: '+1',
author: await this.getAuthor(voteBody.author, token?.access_token),
location: await this.ipService.queryLocation(visitor.ip),
link: getPermalinkByID(voteBody.article_id),
this.getAuthor(voteBody.author, token?.access_token).then(async (author) => {
if (author) {
this.emailToTargetVoteMessage({
to: APP_CONFIG.EMAIL.admin,
subject: `You have a new article vote`,
on: await this.getTargetTitle(voteBody.article_id),
vote: '+1',
author,
location: await this.ipService.queryLocation(visitor.ip),
link: getPermalinkByID(voteBody.article_id),
})
}
})

return likes
Expand Down Expand Up @@ -209,28 +217,32 @@ export class VoteController {
}
} catch (error) {}
}
// email
this.commentService.getDetailByNumberID(voteBody.comment_id).then(async (comment) => {
const tagetTitle = await this.getTargetTitle(comment.post_id)
const mailParams = {
vote: voteBody.vote > 0 ? '+1' : '-1',
on: `${tagetTitle} #${comment.id}`,
author: await this.getAuthor(voteBody.author, token?.access_token),
location: await this.ipService.queryLocation(visitor.ip),
link: getPermalinkByID(comment.post_id),
}
// email to admin
this.emailToTargetVoteMessage({
to: APP_CONFIG.EMAIL.admin,
subject: `You have a new comment vote`,
...mailParams,
})
// email to author
if (comment.author.email) {
this.emailToTargetVoteMessage({
to: comment.author.email,
subject: `Your comment ${comment.id} has a new vote`,
...mailParams,
// email to user and admin
this.getAuthor(voteBody.author, token?.access_token).then((author) => {
if (author) {
this.commentService.getDetailByNumberID(voteBody.comment_id).then(async (comment) => {
const tagetTitle = await this.getTargetTitle(comment.post_id)
const mailParams = {
vote: voteBody.vote > 0 ? '+1' : '-1',
on: `${tagetTitle} #${comment.id}`,
author,
location: await this.ipService.queryLocation(visitor.ip),
link: getPermalinkByID(comment.post_id),
}
// email to admin
this.emailToTargetVoteMessage({
to: APP_CONFIG.EMAIL.admin,
subject: `You have a new comment vote`,
...mailParams,
})
// email to author
if (comment.author.email) {
this.emailToTargetVoteMessage({
to: comment.author.email,
subject: `Your comment #${comment.id} has a new vote`,
...mailParams,
})
}
})
}
})
Expand Down

0 comments on commit a41699c

Please sign in to comment.