summaryrefslogtreecommitdiffstats
path: root/services/mailer/mailer.go
diff options
context:
space:
mode:
authorguillep2k <18600385+guillep2k@users.noreply.github.com>2019-11-18 05:08:20 -0300
committerzeripath <art27@cantab.net>2019-11-18 08:08:20 +0000
commit08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc (patch)
treec64e9a1c9cfaeb6cd0c2ee012d3ad32c38e78ce3 /services/mailer/mailer.go
parent9ff63126274b0df6e035541eafd48970c402e61e (diff)
downloadgitea-08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc.tar.gz
gitea-08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc.zip
Rewrite delivery of issue and comment mails (#9009)
* Mail issue subscribers, rework the function * Simplify a little more * Fix unused variable * Refactor mail delivery to avoid heavy load on server * Avoid splitting into too many goroutines * Fix comments and optimize GetMaileableUsersByIDs() * Fix return on errors
Diffstat (limited to 'services/mailer/mailer.go')
-rw-r--r--services/mailer/mailer.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/services/mailer/mailer.go b/services/mailer/mailer.go
index d19ae7b2f4..2e4aa8d71b 100644
--- a/services/mailer/mailer.go
+++ b/services/mailer/mailer.go
@@ -295,9 +295,18 @@ func NewContext() {
go processMailQueue()
}
-// SendAsync send mail asynchronous
+// SendAsync send mail asynchronously
func SendAsync(msg *Message) {
go func() {
mailQueue <- msg
}()
}
+
+// SendAsyncs send mails asynchronously
+func SendAsyncs(msgs []*Message) {
+ go func() {
+ for _, msg := range msgs {
+ mailQueue <- msg
+ }
+ }()
+}