diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-11-15 16:06:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-15 16:06:11 +0800 |
commit | 21ae9838e04233bbf9930d368d935fd1f9b68c34 (patch) | |
tree | 610abb6f1ec2df235d469276b36f6d26e00e4653 /modules/notification/action | |
parent | b30d744e0986dcf716d4f57dac8c72a494bb226b (diff) | |
download | gitea-21ae9838e04233bbf9930d368d935fd1f9b68c34.tar.gz gitea-21ae9838e04233bbf9930d368d935fd1f9b68c34.zip |
Move transfer repository and rename repository on a service package and start action notification (#8573)
* move transfer repository and rename repository on a service package and start action notification
* remove unused codes
* fix lint
* fix bugs
* fix test
* fix test
* fix test
* fix lint
* update go mod and sum
Diffstat (limited to 'modules/notification/action')
-rw-r--r-- | modules/notification/action/action.go | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index d4be1e4304..dd4dc0ae32 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -6,6 +6,7 @@ package action import ( "fmt" + "path" "strings" "code.gitea.io/gitea/models" @@ -77,7 +78,9 @@ func (a *actionNotifier) NotifyNewPullRequest(pull *models.PullRequest) { } } -func (a *actionNotifier) NotifyRenameRepository(doer *models.User, repo *models.Repository, oldName string) { +func (a *actionNotifier) NotifyRenameRepository(doer *models.User, repo *models.Repository, oldRepoName string) { + log.Trace("action.ChangeRepositoryName: %s/%s", doer.Name, repo.Name) + if err := models.NotifyWatchers(&models.Action{ ActUserID: doer.ID, ActUser: doer, @@ -85,11 +88,23 @@ func (a *actionNotifier) NotifyRenameRepository(doer *models.User, repo *models. RepoID: repo.ID, Repo: repo, IsPrivate: repo.IsPrivate, - Content: oldName, + Content: oldRepoName, }); err != nil { - log.Error("notify watchers: %v", err) - } else { - log.Trace("action.renameRepoAction: %s/%s", doer.Name, repo.Name) + log.Error("NotifyWatchers: %v", err) + } +} + +func (a *actionNotifier) NotifyTransferRepository(doer *models.User, repo *models.Repository, oldOwnerName string) { + if err := models.NotifyWatchers(&models.Action{ + ActUserID: doer.ID, + ActUser: doer, + OpType: models.ActionTransferRepo, + RepoID: repo.ID, + Repo: repo, + IsPrivate: repo.IsPrivate, + Content: path.Join(oldOwnerName, repo.Name), + }); err != nil { + log.Error("NotifyWatchers: %v", err) } } |