Skip to content

Commit 78b54b4

Browse files
authored
fix: Add feed for organization (#3594)
* feat: Add feed for organization * fix: testing * fix: testing * fix: testing * fix: testing
1 parent 990709d commit 78b54b4

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

models/action_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ func TestCommitRepoAction(t *testing.T) {
339339

340340
s.action.ActUserID = user.ID
341341
s.action.RepoID = repo.ID
342+
s.action.Repo = repo
342343
s.action.IsPrivate = repo.IsPrivate
343344

344345
testCorrectRepoAction(t, s.commitRepoActionOptions, &s.action)

models/repo_watch.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ func notifyWatchers(e Engine, act *Action) error {
8787
return fmt.Errorf("insert new actioner: %v", err)
8888
}
8989

90+
act.loadRepo()
91+
// check repo owner exist.
92+
if err := act.Repo.getOwner(e); err != nil {
93+
return fmt.Errorf("can't get repo owner: %v", err)
94+
}
95+
96+
// Add feed for organization
97+
if act.Repo.Owner.IsOrganization() && act.ActUserID != act.Repo.Owner.ID {
98+
act.ID = 0
99+
act.UserID = act.Repo.Owner.ID
100+
if _, err = e.InsertOne(act); err != nil {
101+
return fmt.Errorf("insert new actioner: %v", err)
102+
}
103+
}
104+
90105
for i := range watches {
91106
if act.ActUserID == watches[i].UserID {
92107
continue

0 commit comments

Comments
 (0)