From 78b54b49fa110ed3350c1fa4c46c9ba7cf7ab68c Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sat, 3 Mar 2018 13:21:16 +0800 Subject: [PATCH] fix: Add feed for organization (#3594) * feat: Add feed for organization * fix: testing * fix: testing * fix: testing * fix: testing --- models/action_test.go | 1 + models/repo_watch.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/models/action_test.go b/models/action_test.go index e0a3e2123731..d0e0a5d8fab1 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 cf9dba900af6..fb89a55a11ed 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