This commit is contained in:
+10
-4
@@ -93,7 +93,8 @@ func (s *Server) handleCreatePost(w http.ResponseWriter, r *http.Request) {
|
||||
)
|
||||
}
|
||||
|
||||
// notifyPostReply asynchronously emails the direct parent post's author.
|
||||
// notifyPostReply emails the root homeowner for admin replies and the direct
|
||||
// parent author for homeowner replies.
|
||||
func (s *Server) notifyPostReply(
|
||||
parent *store.Post,
|
||||
root *store.Post,
|
||||
@@ -104,13 +105,19 @@ func (s *Server) notifyPostReply(
|
||||
root == nil ||
|
||||
reply == nil ||
|
||||
replyAuthor == nil ||
|
||||
s.cfg.Mail == nil ||
|
||||
parent.AuthorID == replyAuthor.ID {
|
||||
s.cfg.Mail == nil {
|
||||
return
|
||||
}
|
||||
if _, disabled := s.cfg.Mail.(mail.Nop); disabled {
|
||||
return
|
||||
}
|
||||
recipientID := parent.AuthorID
|
||||
if replyAuthor.Admin() {
|
||||
recipientID = root.AuthorID
|
||||
}
|
||||
if recipientID == replyAuthor.ID {
|
||||
return
|
||||
}
|
||||
msg := mail.PostReply{
|
||||
RootID: root.ID,
|
||||
RootTitle: root.Title,
|
||||
@@ -118,7 +125,6 @@ func (s *Server) notifyPostReply(
|
||||
ReplyBody: reply.Body,
|
||||
ReplyAuthorName: replyAuthor.Name,
|
||||
}
|
||||
recipientID := parent.AuthorID
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
Reference in New Issue
Block a user