summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2018-03-03 13:21:16 +0800
committerGitHub <noreply@github.com>2018-03-03 13:21:16 +0800
commit78b54b49fa110ed3350c1fa4c46c9ba7cf7ab68c (patch)
treefc5f656e1f2ba9999da9dc545e666251f92d7544
parent990709da8fa64d51d8005146da1728f960444abd (diff)
downloadgitea-78b54b49fa110ed3350c1fa4c46c9ba7cf7ab68c.tar.gz
gitea-78b54b49fa110ed3350c1fa4c46c9ba7cf7ab68c.zip
fix: Add feed for organization (#3594)
* feat: Add feed for organization * fix: testing * fix: testing * fix: testing * fix: testing
-rw-r--r--models/action_test.go1
-rw-r--r--models/repo_watch.go15
2 files changed, 16 insertions, 0 deletions
diff --git a/models/action_test.go b/models/action_test.go
index e0a3e21237..d0e0a5d8fa 100644
--- a/models/action_test.go
+++ b/models/action_test.go
@@ -339,6 +339,7 @@ func TestCommitRepoAction(t *testing.T) {
s.action.ActUserID = user.ID
s.action.RepoID = repo.ID
+ s.action.Repo = repo
s.action.IsPrivate = repo.IsPrivate
testCorrectRepoAction(t, s.commitRepoActionOptions, &s.action)
diff --git a/models/repo_watch.go b/models/repo_watch.go
index cf9dba900a..fb89a55a11 100644
--- a/models/repo_watch.go
+++ b/models/repo_watch.go
@@ -87,6 +87,21 @@ func notifyWatchers(e Engine, act *Action) error {
return fmt.Errorf("insert new actioner: %v", err)
}
+ act.loadRepo()
+ // check repo owner exist.
+ if err := act.Repo.getOwner(e); err != nil {
+ return fmt.Errorf("can't get repo owner: %v", err)
+ }
+
+ // Add feed for organization
+ if act.Repo.Owner.IsOrganization() && act.ActUserID != act.Repo.Owner.ID {
+ act.ID = 0
+ act.UserID = act.Repo.Owner.ID
+ if _, err = e.InsertOne(act); err != nil {
+ return fmt.Errorf("insert new actioner: %v", err)
+ }
+ }
+
for i := range watches {
if act.ActUserID == watches[i].UserID {
continue