Browse Source

fix: Add feed for organization (#3594)

* feat: Add feed for organization

* fix: testing

* fix: testing

* fix: testing

* fix: testing
for-closed-social
Bo-Yi Wu 6 years ago
committed by GitHub
parent
commit
78b54b49fa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions
  1. +1
    -0
      models/action_test.go
  2. +15
    -0
      models/repo_watch.go

+ 1
- 0
models/action_test.go View File

@ -339,6 +339,7 @@ func TestCommitRepoAction(t *testing.T) {
s.action.ActUserID = user.ID s.action.ActUserID = user.ID
s.action.RepoID = repo.ID s.action.RepoID = repo.ID
s.action.Repo = repo
s.action.IsPrivate = repo.IsPrivate s.action.IsPrivate = repo.IsPrivate
testCorrectRepoAction(t, s.commitRepoActionOptions, &s.action) testCorrectRepoAction(t, s.commitRepoActionOptions, &s.action)

+ 15
- 0
models/repo_watch.go View File

@ -87,6 +87,21 @@ func notifyWatchers(e Engine, act *Action) error {
return fmt.Errorf("insert new actioner: %v", err) 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 { for i := range watches {
if act.ActUserID == watches[i].UserID { if act.ActUserID == watches[i].UserID {
continue continue

Loading…
Cancel
Save