From aafb565511521372d99691bfbbb90f71fa7e0649 Mon Sep 17 00:00:00 2001 From: lxsang Date: Tue, 22 Sep 2020 19:50:59 +0200 Subject: [PATCH] support author notification --- blog/views/default/layout.ls | 4 ++++ doc/views/default/layout.ls | 4 ++++ talk/assets/quicktalk.js | 4 ++++ talk/controllers/CommentController.lua | 11 +++++++++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/blog/views/default/layout.ls b/blog/views/default/layout.ls index fabae3f..e1e626f 100644 --- a/blog/views/default/layout.ls +++ b/blog/views/default/layout.ls @@ -57,6 +57,10 @@ target: "quick_talk_comment_thread", api_uri: "https://chat.iohub.dev/comment", uri: "", + author: { + first: "mrsang", + last: "iohub.dev" + }, onload: function(){ renderMathInElement($("#desktop")[0]); $('pre code').each(function(i, block) { diff --git a/doc/views/default/layout.ls b/doc/views/default/layout.ls index 941f2e4..85c81a0 100644 --- a/doc/views/default/layout.ls +++ b/doc/views/default/layout.ls @@ -149,6 +149,10 @@ local url = __main__:get("url") target: "quick_talk_comment_thread", api_uri: "https://chat.iohub.dev/comment", uri: "", + author: { + first: "mrsang", + last: "iohub.dev" + }, onload: function(){ renderMathInElement($("#book")[0]); $('pre code').each(function(i, block) { diff --git a/talk/assets/quicktalk.js b/talk/assets/quicktalk.js index 1566a51..e9f3222 100644 --- a/talk/assets/quicktalk.js +++ b/talk/assets/quicktalk.js @@ -164,6 +164,10 @@ class QuickTalk { content: ta.value, }, }; + if (this.options.author) { + data.author = + this.options.author.first + "@" + this.options.author.last; + } this.request(this.options.api_uri + "/post", data, (ret) => { if (ret.result) { // TODO: more check goes here diff --git a/talk/controllers/CommentController.lua b/talk/controllers/CommentController.lua index e67d5ad..4cf9260 100644 --- a/talk/controllers/CommentController.lua +++ b/talk/controllers/CommentController.lua @@ -111,7 +111,14 @@ function CommentController:post(...) rq.comment.id = self.comment.db:lastInsertID() rq.comment.content = process_md(rq.comment.content) - + -- notify the author + if rq.author then + sendmail(rq.author, rq.comment.name .. + " has commented on one of your pages", + rq.comment.name .. " has commented on your page: " .. + rq.page.uri .. + ".\nBest regards,\nEmail automatically sent by QuickTalk API") + end -- send mail to all users of current page local cmts, cmti = self.comment:select("MIN(id) as id,email", "pid=" .. rq.comment.pid .. @@ -125,7 +132,7 @@ function CommentController:post(...) rq.comment.name .. " has written something on a page that you've commented. \nPlease visit this page: " .. rq.page.uri .. - " for updates on the discussion.\nBest regard,\nEmail automatically sent by QuickTalk API") + " for updates on the discussion.\nBest regards,\nEmail automatically sent by QuickTalk API") end end rq.comment.email = ""