]> source.dussan.org Git - gitea.git/commitdiff
Fix #150
authorUnknown <joe2010xtmf@163.com>
Thu, 1 May 2014 13:00:30 +0000 (09:00 -0400)
committerUnknown <joe2010xtmf@163.com>
Thu, 1 May 2014 13:00:30 +0000 (09:00 -0400)
models/action.go
models/repo.go
models/user.go

index 77576a995a09720b4a2b08ac794833eaa6d00ccd..2fc8173443420002c8eb5137a800d9a4022ec219 100644 (file)
@@ -40,6 +40,7 @@ type Action struct {
        RepoId      int64
        RepoName    string
        RefName     string
+       IsPrivate   bool      `xorm:"not null"`
        Content     string    `xorm:"TEXT"`
        Created     time.Time `xorm:"created"`
 }
@@ -100,12 +101,11 @@ func CommitRepoAction(userId int64, userName, actEmail string,
                return err
        }
 
-       if !repo.IsPrivate {
-               if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: actEmail,
-                       OpType: opType, Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName}); err != nil {
-                       log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName)
-                       return err
-               }
+       if err = NotifyWatchers(&Action{ActUserId: userId, ActUserName: userName, ActEmail: actEmail,
+               OpType: opType, Content: string(bs), RepoId: repoId, RepoName: repoName, RefName: refName,
+               IsPrivate: repo.IsPrivate}); err != nil {
+               log.Error("action.CommitRepoAction(notify watchers): %d/%s", userId, repoName)
+               return err
        }
 
        log.Trace("action.CommitRepoAction(end): %d/%s", userId, repoName)
@@ -114,12 +114,8 @@ func CommitRepoAction(userId int64, userName, actEmail string,
 
 // NewRepoAction adds new action for creating repository.
 func NewRepoAction(user *User, repo *Repository) (err error) {
-       if repo.IsPrivate {
-               return nil
-       }
-
        if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
-               OpType: OP_CREATE_REPO, RepoId: repo.Id, RepoName: repo.Name}); err != nil {
+               OpType: OP_CREATE_REPO, RepoId: repo.Id, RepoName: repo.Name, IsPrivate: repo.IsPrivate}); err != nil {
                log.Error("action.NewRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
                return err
        }
@@ -130,12 +126,9 @@ func NewRepoAction(user *User, repo *Repository) (err error) {
 
 // TransferRepoAction adds new action for transfering repository.
 func TransferRepoAction(user, newUser *User, repo *Repository) (err error) {
-       if repo.IsPrivate {
-               return nil
-       }
-
        if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
-               OpType: OP_TRANSFER_REPO, RepoId: repo.Id, RepoName: repo.Name, Content: newUser.Name}); err != nil {
+               OpType: OP_TRANSFER_REPO, RepoId: repo.Id, RepoName: repo.Name, Content: newUser.Name,
+               IsPrivate: repo.IsPrivate}); err != nil {
                log.Error("action.TransferRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
                return err
        }
@@ -149,7 +142,7 @@ func GetFeeds(userid, offset int64, isProfile bool) ([]Action, error) {
        actions := make([]Action, 0, 20)
        sess := orm.Limit(20, int(offset)).Desc("id").Where("user_id=?", userid)
        if isProfile {
-               sess.And("act_user_id=?", userid)
+               sess.Where("is_private=?", false).And("act_user_id=?", userid)
        } else {
                sess.And("act_user_id!=?", userid)
        }
index 5f66bca86d0f324bdbe6d183e424d35f1170eae0..5e193787219f37fc22547b8f995a3085c10650d9 100644 (file)
@@ -310,16 +310,14 @@ func CreateRepository(user *User, name, desc, lang, license string, private, mir
                return nil, err
        }
 
-       if !repo.IsPrivate {
-               if err = NewRepoAction(user, repo); err != nil {
-                       log.Error("repo.CreateRepository(NewRepoAction): %v", err)
-               }
-       }
-
        if err = WatchRepo(user.Id, repo.Id, true); err != nil {
                log.Error("repo.CreateRepository(WatchRepo): %v", err)
        }
 
+       if err = NewRepoAction(user, repo); err != nil {
+               log.Error("repo.CreateRepository(NewRepoAction): %v", err)
+       }
+
        // No need for init for mirror.
        if mirror {
                return repo, nil
index 42b3ebe6ae49186053c0cfeedcf5bac6a3804bc0..22334c8436d7ab8fe7dfdcea372b099e21483207 100644 (file)
@@ -248,6 +248,7 @@ func ChangeUserName(user *User, newUserName string) (err error) {
                }
 
                for j := range accesses {
+                       accesses[j].UserName = newUserName
                        accesses[j].RepoName = newUserName + "/" + repos[i].LowerName
                        if err = UpdateAccessWithSession(sess, &accesses[j]); err != nil {
                                return err