summaryrefslogtreecommitdiffstats
path: root/models/action.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-02-28 21:50:29 -0500
committerUnknwon <u@gogs.io>2015-02-28 21:50:29 -0500
commitb0b11fd7b1bd5e556c27ccae73668b7df74cd73e (patch)
tree134a3b875952990ffe83f5b583d461b6b2e942df /models/action.go
parent3a6ba39a61c68d967c6c08aa087d2de2d0bf7ec0 (diff)
parentf44204e9449c09e0fef37a4974dc2f2043593d6f (diff)
downloadgitea-b0b11fd7b1bd5e556c27ccae73668b7df74cd73e.tar.gz
gitea-b0b11fd7b1bd5e556c27ccae73668b7df74cd73e.zip
Merge branch 'access' of github.com:gogits/gogs into dev
Diffstat (limited to 'models/action.go')
-rw-r--r--models/action.go54
1 files changed, 33 insertions, 21 deletions
diff --git a/models/action.go b/models/action.go
index a1a33f83a0..f872104eb2 100644
--- a/models/action.go
+++ b/models/action.go
@@ -434,46 +434,58 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
return nil
}
-// NewRepoAction adds new action for creating repository.
-func NewRepoAction(u *User, repo *Repository) (err error) {
- if err = NotifyWatchers(&Action{ActUserId: u.Id, ActUserName: u.Name, ActEmail: u.Email,
- OpType: CREATE_REPO, RepoId: repo.Id, RepoUserName: repo.Owner.Name, RepoName: repo.Name,
- IsPrivate: repo.IsPrivate}); err != nil {
- log.Error(4, "NotifyWatchers: %d/%s", u.Id, repo.Name)
- return err
+func newRepoAction(e Engine, u *User, repo *Repository) (err error) {
+ if err = notifyWatchers(e, &Action{
+ ActUserId: u.Id,
+ ActUserName: u.Name,
+ ActEmail: u.Email,
+ OpType: CREATE_REPO,
+ RepoId: repo.Id,
+ RepoUserName: repo.Owner.Name,
+ RepoName: repo.Name,
+ IsPrivate: repo.IsPrivate}); err != nil {
+ return fmt.Errorf("notify watchers '%d/%s'", u.Id, repo.Id)
}
log.Trace("action.NewRepoAction: %s/%s", u.Name, repo.Name)
return err
}
-// TransferRepoAction adds new action for transferring repository.
-func TransferRepoAction(u, newUser *User, repo *Repository) (err error) {
+// NewRepoAction adds new action for creating repository.
+func NewRepoAction(u *User, repo *Repository) (err error) {
+ return newRepoAction(x, u, repo)
+}
+
+func transferRepoAction(e Engine, actUser, oldOwner, newOwner *User, repo *Repository) (err error) {
action := &Action{
- ActUserId: u.Id,
- ActUserName: u.Name,
- ActEmail: u.Email,
+ ActUserId: actUser.Id,
+ ActUserName: actUser.Name,
+ ActEmail: actUser.Email,
OpType: TRANSFER_REPO,
RepoId: repo.Id,
- RepoUserName: newUser.Name,
+ RepoUserName: newOwner.Name,
RepoName: repo.Name,
IsPrivate: repo.IsPrivate,
- Content: path.Join(repo.Owner.LowerName, repo.LowerName),
+ Content: path.Join(oldOwner.LowerName, repo.LowerName),
}
- if err = NotifyWatchers(action); err != nil {
- log.Error(4, "NotifyWatchers: %d/%s", u.Id, repo.Name)
- return err
+ if err = notifyWatchers(e, action); err != nil {
+ return fmt.Errorf("notify watchers '%d/%s'", actUser.Id, repo.Id)
}
// Remove watch for organization.
if repo.Owner.IsOrganization() {
- if err = WatchRepo(repo.Owner.Id, repo.Id, false); err != nil {
- log.Error(4, "WatchRepo", err)
+ if err = watchRepo(e, repo.Owner.Id, repo.Id, false); err != nil {
+ return fmt.Errorf("watch repository: %v", err)
}
}
- log.Trace("action.TransferRepoAction: %s/%s", u.Name, repo.Name)
- return err
+ log.Trace("action.TransferRepoAction: %s/%s", actUser.Name, repo.Name)
+ return nil
+}
+
+// TransferRepoAction adds new action for transferring repository.
+func TransferRepoAction(actUser, oldOwner, newOwner *User, repo *Repository) (err error) {
+ return transferRepoAction(x, actUser, oldOwner, newOwner, repo)
}
// GetFeeds returns action list of given user in given context.