mirror of
https://gitee.com/gitea/gitea
synced 2026-03-10 06:25:38 +08:00
37 lines
667 B
Go
37 lines
667 B
Go
package notification
|
|
|
|
import (
|
|
"code.gitea.io/gitea/models"
|
|
"code.gitea.io/gitea/modules/log"
|
|
)
|
|
|
|
type notificationService struct {
|
|
issueQueue chan *models.Issue
|
|
}
|
|
|
|
var (
|
|
// Service is the notification service
|
|
Service = ¬ificationService{
|
|
issueQueue: make(chan *models.Issue),
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
go Service.Run()
|
|
}
|
|
|
|
func (ns *notificationService) Run() {
|
|
for {
|
|
select {
|
|
case issue := <-ns.issueQueue:
|
|
if err := models.CreateOrUpdateIssueNotifications(issue); err != nil {
|
|
log.Error(4, "Was unable to create issue notification: %v", err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func (ns *notificationService) NotifyIssue(issue *models.Issue) {
|
|
ns.issueQueue <- issue
|
|
}
|