Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo
Commits
a6929dad
Commit
a6929dad
authored
Oct 01, 2015
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
运行在本地的话不发送评论/回复提醒邮件
parent
0875bc87
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
58 deletions
+65
-58
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
...b3log/solo/event/comment/ArticleCommentReplyNotifier.java
+13
-8
src/main/java/org/b3log/solo/service/CommentMgmtService.java
src/main/java/org/b3log/solo/service/CommentMgmtService.java
+52
-50
No files found.
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
View file @
a6929dad
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
*/
*/
package
org
.
b3log
.
solo
.
event
.
comment
;
package
org
.
b3log
.
solo
.
event
.
comment
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.event.AbstractEventListener
;
import
org.b3log.latke.event.AbstractEventListener
;
...
@@ -39,12 +38,11 @@ import org.b3log.solo.repository.impl.CommentRepositoryImpl;
...
@@ -39,12 +38,11 @@ import org.b3log.solo.repository.impl.CommentRepositoryImpl;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
/**
/**
* This listener is responsible for processing article comment reply.
* This listener is responsible for processing article comment reply.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
0.1.6, May 17, 2013
* @version 1.
1.1.6, Oct 1, 2015
* @since 0.3.1
* @since 0.3.1
*/
*/
public
final
class
ArticleCommentReplyNotifier
extends
AbstractEventListener
<
JSONObject
>
{
public
final
class
ArticleCommentReplyNotifier
extends
AbstractEventListener
<
JSONObject
>
{
...
@@ -66,11 +64,18 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
...
@@ -66,11 +64,18 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
final
JSONObject
article
=
eventData
.
optJSONObject
(
Article
.
ARTICLE
);
final
JSONObject
article
=
eventData
.
optJSONObject
(
Article
.
ARTICLE
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Processing an event[type={0}, data={1}] in listener[className={2}]"
,
LOGGER
.
log
(
Level
.
DEBUG
,
"Processing an event[type={0}, data={1}] in listener[className={2}]"
,
new
Object
[]
{
event
.
getType
(),
eventData
,
ArticleCommentReplyNotifier
.
class
.
getName
()});
new
Object
[]
{
event
.
getType
(),
eventData
,
ArticleCommentReplyNotifier
.
class
.
getName
()});
final
String
originalCommentId
=
comment
.
optString
(
Comment
.
COMMENT_ORIGINAL_COMMENT_ID
);
final
String
originalCommentId
=
comment
.
optString
(
Comment
.
COMMENT_ORIGINAL_COMMENT_ID
);
if
(
Strings
.
isEmptyOrNull
(
originalCommentId
))
{
if
(
Strings
.
isEmptyOrNull
(
originalCommentId
))
{
LOGGER
.
log
(
Level
.
DEBUG
,
"This comment[id={0}] is not a reply"
,
comment
.
optString
(
Keys
.
OBJECT_ID
));
LOGGER
.
log
(
Level
.
DEBUG
,
"This comment[id={0}] is not a reply"
,
comment
.
optString
(
Keys
.
OBJECT_ID
));
return
;
}
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
LOGGER
.
log
(
Level
.
INFO
,
"Solo runs on local server, so should not send mail"
);
return
;
return
;
}
}
...
@@ -124,7 +129,7 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
...
@@ -124,7 +129,7 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
message
.
setHtmlBody
(
mailBody
);
message
.
setHtmlBody
(
mailBody
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]"
,
LOGGER
.
log
(
Level
.
DEBUG
,
"Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]"
,
new
Object
[]
{
mailSubject
,
mailBody
,
originalCommentEmail
});
new
Object
[]
{
mailSubject
,
mailBody
,
originalCommentEmail
});
mailService
.
send
(
message
);
mailService
.
send
(
message
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
...
...
src/main/java/org/b3log/solo/service/CommentMgmtService.java
View file @
a6929dad
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
*/
*/
package
org
.
b3log
.
solo
.
service
;
package
org
.
b3log
.
solo
.
service
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -50,12 +49,11 @@ import org.b3log.solo.util.Thumbnails;
...
@@ -50,12 +49,11 @@ import org.b3log.solo.util.Thumbnails;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
/**
/**
* Comment management service.
* Comment management service.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
0.0.6, Jan 7, 2014
* @version 1.
1.0.6, Oct 1, 2015
* @since 0.3.5
* @since 0.3.5
*/
*/
@Service
@Service
...
@@ -156,13 +154,12 @@ public class CommentMgmtService {
...
@@ -156,13 +154,12 @@ public class CommentMgmtService {
+
" received a new comment:</p>"
+
"{commenter}: <span><a href=\"{commentSharpURL}\">"
+
"{commentContent}</a></span>"
;
+
" received a new comment:</p>"
+
"{commenter}: <span><a href=\"{commentSharpURL}\">"
+
"{commentContent}</a></span>"
;
/**
/**
* Sends a notification mail to administrator for notifying the specified
* Sends a notification mail to administrator for notifying the specified
article or page received the specified
*
article or page received the specified
comment and original comment.
* comment and original comment.
*
*
* @param articleOrPage the specified article or page
* @param articleOrPage the specified article or page
* @param comment the specified comment
* @param comment the specified comment
* @param originalComment original comment, if not exists, set it as
* @param originalComment original comment, if not exists, set it as {@code null}
* {@code null}
* @param preference the specified preference
* @param preference the specified preference
* @throws IOException io exception
* @throws IOException io exception
* @throws JSONException json exception
* @throws JSONException json exception
...
@@ -180,6 +177,13 @@ public class CommentMgmtService {
...
@@ -180,6 +177,13 @@ public class CommentMgmtService {
if
(
adminEmail
.
equalsIgnoreCase
(
commentEmail
))
{
if
(
adminEmail
.
equalsIgnoreCase
(
commentEmail
))
{
LOGGER
.
log
(
Level
.
DEBUG
,
"Do not send comment notification mail to admin itself[{0}]"
,
adminEmail
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Do not send comment notification mail to admin itself[{0}]"
,
adminEmail
);
return
;
}
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
LOGGER
.
log
(
Level
.
INFO
,
"Solo runs on local server, so should not send mail"
);
return
;
return
;
}
}
...
@@ -237,15 +241,15 @@ public class CommentMgmtService {
...
@@ -237,15 +241,15 @@ public class CommentMgmtService {
message
.
setHtmlBody
(
mailBody
);
message
.
setHtmlBody
(
mailBody
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Sending a mail[mailSubject={0}, mailBody=[{1}] to admin[email={2}]"
,
LOGGER
.
log
(
Level
.
DEBUG
,
"Sending a mail[mailSubject={0}, mailBody=[{1}] to admin[email={2}]"
,
new
Object
[]
{
mailSubject
,
mailBody
,
adminEmail
});
new
Object
[]{
mailSubject
,
mailBody
,
adminEmail
});
mailService
.
send
(
message
);
mailService
.
send
(
message
);
}
}
/**
/**
* Checks the specified comment adding request.
* Checks the specified comment adding request.
*
*
* @param requestJSONObject the specified comment adding request, for example,
* @param requestJSONObject the specified comment adding request, for example, <pre>
* <pre>
* {
* {
* "type": "", // "article"/"page"
* "type": "", // "article"/"page"
* "oId": "",
* "oId": "",
...
@@ -255,8 +259,8 @@ public class CommentMgmtService {
...
@@ -255,8 +259,8 @@ public class CommentMgmtService {
* "commentContent": "",
* "commentContent": "",
* }
* }
* </pre>
* </pre>
*
@return check result, for example,
*
* <pre>
*
@return check result, for example,
<pre>
* {
* {
* "sc": boolean,
* "sc": boolean,
* "msg": "" // Exists if "sc" equals to false
* "msg": "" // Exists if "sc" equals to false
...
@@ -350,8 +354,7 @@ public class CommentMgmtService {
...
@@ -350,8 +354,7 @@ public class CommentMgmtService {
/**
/**
* Adds page comment with the specified request json object.
* Adds page comment with the specified request json object.
*
*
* @param requestJSONObject the specified request json object, for example,
* @param requestJSONObject the specified request json object, for example, <pre>
* <pre>
* {
* {
* "oId": "", // page id
* "oId": "", // page id
* "commentName": "",
* "commentName": "",
...
@@ -361,8 +364,8 @@ public class CommentMgmtService {
...
@@ -361,8 +364,8 @@ public class CommentMgmtService {
* "commentOriginalCommentId": "" // optional
* "commentOriginalCommentId": "" // optional
* }
* }
* </pre>
* </pre>
*
@return add result, for example,
*
* <pre>
*
@return add result, for example,
<pre>
* {
* {
* "oId": "", // generated comment id
* "oId": "", // generated comment id
* "commentDate": "", // format: yyyy-MM-dd hh:mm:ss
* "commentDate": "", // format: yyyy-MM-dd hh:mm:ss
...
@@ -371,6 +374,7 @@ public class CommentMgmtService {
...
@@ -371,6 +374,7 @@ public class CommentMgmtService {
* "commentSharpURL": ""
* "commentSharpURL": ""
* }
* }
* </pre>
* </pre>
*
* @throws ServiceException service exception
* @throws ServiceException service exception
*/
*/
public
JSONObject
addPageComment
(
final
JSONObject
requestJSONObject
)
throws
ServiceException
{
public
JSONObject
addPageComment
(
final
JSONObject
requestJSONObject
)
throws
ServiceException
{
...
@@ -466,8 +470,7 @@ public class CommentMgmtService {
...
@@ -466,8 +470,7 @@ public class CommentMgmtService {
/**
/**
* Adds an article comment with the specified request json object.
* Adds an article comment with the specified request json object.
*
*
* @param requestJSONObject the specified request json object, for example,
* @param requestJSONObject the specified request json object, for example, <pre>
* <pre>
* {
* {
* "oId": "", // article id
* "oId": "", // article id
* "commentName": "",
* "commentName": "",
...
@@ -477,8 +480,8 @@ public class CommentMgmtService {
...
@@ -477,8 +480,8 @@ public class CommentMgmtService {
* "commentOriginalCommentId": "" // optional
* "commentOriginalCommentId": "" // optional
* }
* }
* </pre>
* </pre>
*
@return add result, for example,
*
* <pre>
*
@return add result, for example,
<pre>
* {
* {
* "oId": "", // generated comment id
* "oId": "", // generated comment id
* "commentDate": "", // format: yyyy-MM-dd hh:mm:ss
* "commentDate": "", // format: yyyy-MM-dd hh:mm:ss
...
@@ -487,6 +490,7 @@ public class CommentMgmtService {
...
@@ -487,6 +490,7 @@ public class CommentMgmtService {
* "commentSharpURL": ""
* "commentSharpURL": ""
* }
* }
* </pre>
* </pre>
*
* @throws ServiceException service exception
* @throws ServiceException service exception
*/
*/
public
JSONObject
addArticleComment
(
final
JSONObject
requestJSONObject
)
throws
ServiceException
{
public
JSONObject
addArticleComment
(
final
JSONObject
requestJSONObject
)
throws
ServiceException
{
...
@@ -535,7 +539,7 @@ public class CommentMgmtService {
...
@@ -535,7 +539,7 @@ public class CommentMgmtService {
ret
.
put
(
Comment
.
COMMENT_ORIGINAL_COMMENT_NAME
,
originalCommentName
);
ret
.
put
(
Comment
.
COMMENT_ORIGINAL_COMMENT_NAME
,
originalCommentName
);
}
else
{
}
else
{
LOGGER
.
log
(
Level
.
WARN
,
"Not found orginal comment[id={0}] of reply[name={1}, content={2}]"
,
LOGGER
.
log
(
Level
.
WARN
,
"Not found orginal comment[id={0}] of reply[name={1}, content={2}]"
,
new
String
[]
{
originalCommentId
,
commentName
,
commentContent
});
new
String
[]
{
originalCommentId
,
commentName
,
commentContent
});
}
}
}
}
setCommentThumbnailURL
(
comment
);
setCommentThumbnailURL
(
comment
);
...
@@ -650,8 +654,7 @@ public class CommentMgmtService {
...
@@ -650,8 +654,7 @@ public class CommentMgmtService {
}
}
/**
/**
* Page comment count +1 for an page specified by the given page
* Page comment count +1 for an page specified by the given page id.
* id.
*
*
* @param pageId the given page id
* @param pageId the given page id
* @throws JSONException json exception
* @throws JSONException json exception
...
@@ -668,8 +671,7 @@ public class CommentMgmtService {
...
@@ -668,8 +671,7 @@ public class CommentMgmtService {
}
}
/**
/**
* Article comment count -1 for an article specified by the given
* Article comment count -1 for an article specified by the given article id.
* article id.
*
*
* @param articleId the given article id
* @param articleId the given article id
* @throws JSONException json exception
* @throws JSONException json exception
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment