You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

indexer.go 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package indexer
  5. import (
  6. "code.gitea.io/gitea/models"
  7. "code.gitea.io/gitea/modules/notification/base"
  8. )
  9. type indexerNotifier struct {
  10. base.NullNotifier
  11. }
  12. var (
  13. _ base.Notifier = &indexerNotifier{}
  14. )
  15. // NewNotifier create a new indexerNotifier notifier
  16. func NewNotifier() base.Notifier {
  17. return &indexerNotifier{}
  18. }
  19. func (r *indexerNotifier) NotifyCreateIssueComment(doer *models.User, repo *models.Repository,
  20. issue *models.Issue, comment *models.Comment) {
  21. if comment.Type == models.CommentTypeComment {
  22. models.UpdateIssueIndexer(issue.ID)
  23. }
  24. }
  25. func (r *indexerNotifier) NotifyNewIssue(issue *models.Issue) {
  26. models.UpdateIssueIndexer(issue.ID)
  27. }
  28. func (r *indexerNotifier) NotifyNewPullRequest(pr *models.PullRequest) {
  29. models.UpdateIssueIndexer(pr.Issue.ID)
  30. }
  31. func (r *indexerNotifier) NotifyUpdateComment(doer *models.User, c *models.Comment, oldContent string) {
  32. if c.Type == models.CommentTypeComment {
  33. models.UpdateIssueIndexer(c.IssueID)
  34. }
  35. }
  36. func (r *indexerNotifier) NotifyDeleteComment(doer *models.User, comment *models.Comment) {
  37. if comment.Type == models.CommentTypeComment {
  38. models.UpdateIssueIndexer(comment.IssueID)
  39. }
  40. }
  41. func (r *indexerNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) {
  42. models.DeleteRepoFromIndexer(repo)
  43. }
  44. func (r *indexerNotifier) NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string) {
  45. models.UpdateIssueIndexer(issue.ID)
  46. }
  47. func (r *indexerNotifier) NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string) {
  48. models.UpdateIssueIndexer(issue.ID)
  49. }