Notify homeowners of plumber replies
CI / test (pull_request) Successful in 6m16s

This commit is contained in:
2026-08-27 09:12:30 -07:00
parent df17e0e6f3
commit 17e73ad2d3
2 changed files with 27 additions and 5 deletions
+10 -4
View File
@@ -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()