]> source.dussan.org Git - gitea.git/commitdiff
fix: Add feed for organization (#3594)
authorBo-Yi Wu <appleboy.tw@gmail.com>
Sat, 3 Mar 2018 05:21:16 +0000 (13:21 +0800)
committerGitHub <noreply@github.com>
Sat, 3 Mar 2018 05:21:16 +0000 (13:21 +0800)
* feat: Add feed for organization

* fix: testing

* fix: testing

* fix: testing

* fix: testing

models/action_test.go
models/repo_watch.go

index e0a3e2123731a74083cde35dca95edf8ef49f75b..d0e0a5d8fab1f1b62bba7e0bfca2967e0a76c114 100644 (file)
@@ -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)
index cf9dba900af6460b1d0c5b78d48861cf34c3b4a3..fb89a55a11edf86669ed4cd1acc3074036d79357 100644 (file)
@@ -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