From 1f12dc8e8862da8546fd9d984abdc7f69dd95f11 Mon Sep 17 00:00:00 2001
From: 赵智超 <1012112796@qq.com>
Date: Thu, 30 Jul 2020 03:20:54 +0800
Subject: Add action feed for new release (#12324)

* Add action feed for new release

Signed-off-by: a1012112796 <1012112796@qq.com>

* fix lint

* Apply suggestions from code review

* Add ReleaseID to the action table
* Remove error message
* Fold the attachments download list

* remove attchment download list

* simplify code

* fix create release from existing tag

* simplify ui

* translation change

* fix test

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
---
 modules/notification/action/action.go | 19 +++++++++++++++++++
 modules/templates/helper.go           |  2 ++
 2 files changed, 21 insertions(+)

(limited to 'modules')

diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go
index 9956940f30..040cf3df10 100644
--- a/modules/notification/action/action.go
+++ b/modules/notification/action/action.go
@@ -314,3 +314,22 @@ func (a *actionNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Rep
 		log.Error("notifyWatchers: %v", err)
 	}
 }
+
+func (a *actionNotifier) NotifyNewRelease(rel *models.Release) {
+	if err := rel.LoadAttributes(); err != nil {
+		log.Error("NotifyNewRelease: %v", err)
+		return
+	}
+	if err := models.NotifyWatchers(&models.Action{
+		ActUserID: rel.PublisherID,
+		ActUser:   rel.Publisher,
+		OpType:    models.ActionPublishRelease,
+		RepoID:    rel.RepoID,
+		Repo:      rel.Repo,
+		IsPrivate: rel.Repo.IsPrivate,
+		Content:   rel.Title,
+		RefName:   rel.TagName,
+	}); err != nil {
+		log.Error("notifyWatchers: %v", err)
+	}
+}
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 8c078a0e82..8f3fba618d 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -640,6 +640,8 @@ func ActionIcon(opType models.ActionType) string {
 		return "check"
 	case models.ActionRejectPullRequest:
 		return "diff"
+	case models.ActionPublishRelease:
+		return "tag"
 	default:
 		return "question"
 	}
-- 
cgit v1.2.3