2019-11-04 02:29:09 +05:30
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package action
import (
"fmt"
2019-11-15 13:36:11 +05:30
"path"
2019-11-14 08:27:36 +05:30
"strings"
2019-11-04 02:29:09 +05:30
2022-08-25 08:01:57 +05:30
activities_model "code.gitea.io/gitea/models/activities"
2022-04-08 14:41:15 +05:30
"code.gitea.io/gitea/models/db"
2022-06-13 15:07:59 +05:30
issues_model "code.gitea.io/gitea/models/issues"
2021-12-10 06:57:50 +05:30
repo_model "code.gitea.io/gitea/models/repo"
2021-11-24 15:19:20 +05:30
user_model "code.gitea.io/gitea/models/user"
2022-01-20 04:56:57 +05:30
"code.gitea.io/gitea/modules/graceful"
2021-07-24 21:33:58 +05:30
"code.gitea.io/gitea/modules/json"
2019-11-04 02:29:09 +05:30
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
2022-01-20 04:56:57 +05:30
"code.gitea.io/gitea/modules/process"
2020-01-10 15:04:21 +05:30
"code.gitea.io/gitea/modules/repository"
2021-12-09 11:11:17 +05:30
"code.gitea.io/gitea/modules/util"
2019-11-04 02:29:09 +05:30
)
type actionNotifier struct {
base . NullNotifier
}
2022-01-20 23:16:10 +05:30
var _ base . Notifier = & actionNotifier { }
2019-11-04 02:29:09 +05:30
2019-11-09 02:24:50 +05:30
// NewNotifier create a new actionNotifier notifier
2019-11-04 02:29:09 +05:30
func NewNotifier ( ) base . Notifier {
return & actionNotifier { }
}
2022-06-13 15:07:59 +05:30
func ( a * actionNotifier ) NotifyNewIssue ( issue * issues_model . Issue , mentions [ ] * user_model . User ) {
2019-11-04 02:29:09 +05:30
if err := issue . LoadPoster ( ) ; err != nil {
log . Error ( "issue.LoadPoster: %v" , err )
return
}
2022-04-08 14:41:15 +05:30
if err := issue . LoadRepo ( db . DefaultContext ) ; err != nil {
2019-11-04 02:29:09 +05:30
log . Error ( "issue.LoadRepo: %v" , err )
return
}
repo := issue . Repo
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2019-11-04 02:29:09 +05:30
ActUserID : issue . Poster . ID ,
ActUser : issue . Poster ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionCreateIssue ,
2019-11-04 02:29:09 +05:30
Content : fmt . Sprintf ( "%d|%s" , issue . Index , issue . Title ) ,
RepoID : repo . ID ,
Repo : repo ,
IsPrivate : repo . IsPrivate ,
} ) ; err != nil {
log . Error ( "NotifyWatchers: %v" , err )
}
}
2019-12-16 03:27:34 +05:30
// NotifyIssueChangeStatus notifies close or reopen issue to notifiers
2022-06-13 15:07:59 +05:30
func ( a * actionNotifier ) NotifyIssueChangeStatus ( doer * user_model . User , issue * issues_model . Issue , actionComment * issues_model . Comment , closeOrReopen bool ) {
2019-12-16 03:27:34 +05:30
// Compose comment action, could be plain comment, close or reopen issue/pull request.
// This object will be used to notify watchers in the end of function.
2022-08-25 08:01:57 +05:30
act := & activities_model . Action {
2019-12-16 03:27:34 +05:30
ActUserID : doer . ID ,
ActUser : doer ,
Content : fmt . Sprintf ( "%d|%s" , issue . Index , "" ) ,
RepoID : issue . Repo . ID ,
Repo : issue . Repo ,
Comment : actionComment ,
CommentID : actionComment . ID ,
IsPrivate : issue . Repo . IsPrivate ,
}
// Check comment type.
if closeOrReopen {
2022-08-25 08:01:57 +05:30
act . OpType = activities_model . ActionCloseIssue
2019-12-16 03:27:34 +05:30
if issue . IsPull {
2022-08-25 08:01:57 +05:30
act . OpType = activities_model . ActionClosePullRequest
2019-12-16 03:27:34 +05:30
}
} else {
2022-08-25 08:01:57 +05:30
act . OpType = activities_model . ActionReopenIssue
2019-12-16 03:27:34 +05:30
if issue . IsPull {
2022-08-25 08:01:57 +05:30
act . OpType = activities_model . ActionReopenPullRequest
2019-12-16 03:27:34 +05:30
}
}
// Notify watchers for whatever action comes in, ignore if no action type.
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( act ) ; err != nil {
2019-12-16 03:27:34 +05:30
log . Error ( "NotifyWatchers: %v" , err )
}
}
// NotifyCreateIssueComment notifies comment on an issue to notifiers
2021-12-10 06:57:50 +05:30
func ( a * actionNotifier ) NotifyCreateIssueComment ( doer * user_model . User , repo * repo_model . Repository ,
2022-06-13 15:07:59 +05:30
issue * issues_model . Issue , comment * issues_model . Comment , mentions [ ] * user_model . User ,
2022-02-24 01:46:07 +05:30
) {
2022-08-25 08:01:57 +05:30
act := & activities_model . Action {
2019-12-16 03:27:34 +05:30
ActUserID : doer . ID ,
ActUser : doer ,
RepoID : issue . Repo . ID ,
Repo : issue . Repo ,
Comment : comment ,
CommentID : comment . ID ,
IsPrivate : issue . Repo . IsPrivate ,
}
2020-09-18 13:08:21 +05:30
2021-12-09 11:11:17 +05:30
truncatedContent , truncatedRight := util . SplitStringAtByteN ( comment . Content , 200 )
if truncatedRight != "" {
// in case the content is in a Latin family language, we remove the last broken word.
lastSpaceIdx := strings . LastIndex ( truncatedContent , " " )
if lastSpaceIdx != - 1 && ( len ( truncatedContent ) - lastSpaceIdx < 15 ) {
truncatedContent = truncatedContent [ : lastSpaceIdx ] + "…"
}
2020-09-18 13:08:21 +05:30
}
2021-12-09 11:11:17 +05:30
act . Content = fmt . Sprintf ( "%d|%s" , issue . Index , truncatedContent )
2020-09-18 13:08:21 +05:30
2019-12-22 13:59:26 +05:30
if issue . IsPull {
2022-08-25 08:01:57 +05:30
act . OpType = activities_model . ActionCommentPull
2019-12-22 13:59:26 +05:30
} else {
2022-08-25 08:01:57 +05:30
act . OpType = activities_model . ActionCommentIssue
2019-12-22 13:59:26 +05:30
}
2019-12-16 03:27:34 +05:30
// Notify watchers for whatever action comes in, ignore if no action type.
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( act ) ; err != nil {
2019-12-16 03:27:34 +05:30
log . Error ( "NotifyWatchers: %v" , err )
}
}
2022-06-13 15:07:59 +05:30
func ( a * actionNotifier ) NotifyNewPullRequest ( pull * issues_model . PullRequest , mentions [ ] * user_model . User ) {
2019-11-04 02:29:09 +05:30
if err := pull . LoadIssue ( ) ; err != nil {
log . Error ( "pull.LoadIssue: %v" , err )
return
}
2022-04-08 14:41:15 +05:30
if err := pull . Issue . LoadRepo ( db . DefaultContext ) ; err != nil {
2019-11-04 02:29:09 +05:30
log . Error ( "pull.Issue.LoadRepo: %v" , err )
return
}
if err := pull . Issue . LoadPoster ( ) ; err != nil {
log . Error ( "pull.Issue.LoadPoster: %v" , err )
return
}
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2019-11-04 02:29:09 +05:30
ActUserID : pull . Issue . Poster . ID ,
ActUser : pull . Issue . Poster ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionCreatePullRequest ,
2019-11-04 02:29:09 +05:30
Content : fmt . Sprintf ( "%d|%s" , pull . Issue . Index , pull . Issue . Title ) ,
RepoID : pull . Issue . Repo . ID ,
Repo : pull . Issue . Repo ,
IsPrivate : pull . Issue . Repo . IsPrivate ,
} ) ; err != nil {
log . Error ( "NotifyWatchers: %v" , err )
}
}
2019-11-09 02:24:50 +05:30
2021-12-10 06:57:50 +05:30
func ( a * actionNotifier ) NotifyRenameRepository ( doer * user_model . User , repo * repo_model . Repository , oldRepoName string ) {
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2019-11-09 02:24:50 +05:30
ActUserID : doer . ID ,
ActUser : doer ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionRenameRepo ,
2019-11-09 02:24:50 +05:30
RepoID : repo . ID ,
Repo : repo ,
IsPrivate : repo . IsPrivate ,
2019-11-15 13:36:11 +05:30
Content : oldRepoName ,
2019-11-09 02:24:50 +05:30
} ) ; err != nil {
2019-11-15 13:36:11 +05:30
log . Error ( "NotifyWatchers: %v" , err )
}
}
2021-12-10 06:57:50 +05:30
func ( a * actionNotifier ) NotifyTransferRepository ( doer * user_model . User , repo * repo_model . Repository , oldOwnerName string ) {
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2019-11-15 13:36:11 +05:30
ActUserID : doer . ID ,
ActUser : doer ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionTransferRepo ,
2019-11-15 13:36:11 +05:30
RepoID : repo . ID ,
Repo : repo ,
IsPrivate : repo . IsPrivate ,
Content : path . Join ( oldOwnerName , repo . Name ) ,
} ) ; err != nil {
log . Error ( "NotifyWatchers: %v" , err )
2019-11-09 02:24:50 +05:30
}
}
2019-11-11 09:09:41 +05:30
2021-12-20 10:11:31 +05:30
func ( a * actionNotifier ) NotifyCreateRepository ( doer , u * user_model . User , repo * repo_model . Repository ) {
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2019-11-11 09:09:41 +05:30
ActUserID : doer . ID ,
ActUser : doer ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionCreateRepo ,
2019-11-11 09:09:41 +05:30
RepoID : repo . ID ,
Repo : repo ,
IsPrivate : repo . IsPrivate ,
} ) ; err != nil {
log . Error ( "notify watchers '%d/%d': %v" , doer . ID , repo . ID , err )
}
}
2021-12-10 06:57:50 +05:30
func ( a * actionNotifier ) NotifyForkRepository ( doer * user_model . User , oldRepo , repo * repo_model . Repository ) {
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2019-11-11 09:09:41 +05:30
ActUserID : doer . ID ,
ActUser : doer ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionCreateRepo ,
2019-11-11 09:09:41 +05:30
RepoID : repo . ID ,
Repo : repo ,
IsPrivate : repo . IsPrivate ,
} ) ; err != nil {
log . Error ( "notify watchers '%d/%d': %v" , doer . ID , repo . ID , err )
}
}
2019-11-14 08:27:36 +05:30
2022-06-13 15:07:59 +05:30
func ( a * actionNotifier ) NotifyPullRequestReview ( pr * issues_model . PullRequest , review * issues_model . Review , comment * issues_model . Comment , mentions [ ] * user_model . User ) {
2022-01-20 04:56:57 +05:30
ctx , _ , finished := process . GetManager ( ) . AddContext ( graceful . GetManager ( ) . HammerContext ( ) , fmt . Sprintf ( "actionNotifier.NotifyPullRequestReview Pull[%d] #%d in [%d]" , pr . ID , pr . Index , pr . BaseRepoID ) )
defer finished ( )
2019-11-14 08:27:36 +05:30
if err := review . LoadReviewer ( ) ; err != nil {
log . Error ( "LoadReviewer '%d/%d': %v" , review . ID , review . ReviewerID , err )
return
}
2022-01-20 04:56:57 +05:30
if err := review . LoadCodeComments ( ctx ) ; err != nil {
2019-11-14 08:27:36 +05:30
log . Error ( "LoadCodeComments '%d/%d': %v" , review . Reviewer . ID , review . ID , err )
return
}
2022-08-25 08:01:57 +05:30
actions := make ( [ ] * activities_model . Action , 0 , 10 )
2019-11-14 08:27:36 +05:30
for _ , lines := range review . CodeComments {
for _ , comments := range lines {
for _ , comm := range comments {
2022-08-25 08:01:57 +05:30
actions = append ( actions , & activities_model . Action {
2019-11-14 08:27:36 +05:30
ActUserID : review . Reviewer . ID ,
ActUser : review . Reviewer ,
Content : fmt . Sprintf ( "%d|%s" , review . Issue . Index , strings . Split ( comm . Content , "\n" ) [ 0 ] ) ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionCommentPull ,
2019-11-14 08:27:36 +05:30
RepoID : review . Issue . RepoID ,
Repo : review . Issue . Repo ,
IsPrivate : review . Issue . Repo . IsPrivate ,
Comment : comm ,
CommentID : comm . ID ,
} )
}
}
}
2022-06-13 15:07:59 +05:30
if review . Type != issues_model . ReviewTypeComment || strings . TrimSpace ( comment . Content ) != "" {
2022-08-25 08:01:57 +05:30
action := & activities_model . Action {
2019-11-14 08:27:36 +05:30
ActUserID : review . Reviewer . ID ,
ActUser : review . Reviewer ,
Content : fmt . Sprintf ( "%d|%s" , review . Issue . Index , strings . Split ( comment . Content , "\n" ) [ 0 ] ) ,
RepoID : review . Issue . RepoID ,
Repo : review . Issue . Repo ,
IsPrivate : review . Issue . Repo . IsPrivate ,
Comment : comment ,
CommentID : comment . ID ,
2019-11-15 05:22:18 +05:30
}
switch review . Type {
2022-06-13 15:07:59 +05:30
case issues_model . ReviewTypeApprove :
2022-08-25 08:01:57 +05:30
action . OpType = activities_model . ActionApprovePullRequest
2022-06-13 15:07:59 +05:30
case issues_model . ReviewTypeReject :
2022-08-25 08:01:57 +05:30
action . OpType = activities_model . ActionRejectPullRequest
2019-11-15 05:22:18 +05:30
default :
2022-08-25 08:01:57 +05:30
action . OpType = activities_model . ActionCommentPull
2019-11-15 05:22:18 +05:30
}
actions = append ( actions , action )
2019-11-14 08:27:36 +05:30
}
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchersActions ( actions ) ; err != nil {
2019-11-14 08:27:36 +05:30
log . Error ( "notify watchers '%d/%d': %v" , review . Reviewer . ID , review . Issue . RepoID , err )
}
}
2019-11-21 22:38:42 +05:30
2022-06-13 15:07:59 +05:30
func ( * actionNotifier ) NotifyMergePullRequest ( pr * issues_model . PullRequest , doer * user_model . User ) {
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2019-11-21 22:38:42 +05:30
ActUserID : doer . ID ,
ActUser : doer ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionMergePullRequest ,
2019-11-21 22:38:42 +05:30
Content : fmt . Sprintf ( "%d|%s" , pr . Issue . Index , pr . Issue . Title ) ,
2022-11-03 21:19:00 +05:30
RepoID : pr . Issue . Repo . ID ,
Repo : pr . Issue . Repo ,
IsPrivate : pr . Issue . Repo . IsPrivate ,
} ) ; err != nil {
log . Error ( "NotifyWatchers [%d]: %v" , pr . ID , err )
}
}
func ( * actionNotifier ) NotifyAutoMergePullRequest ( pr * issues_model . PullRequest , doer * user_model . User ) {
if err := activities_model . NotifyWatchers ( & activities_model . Action {
ActUserID : doer . ID ,
ActUser : doer ,
OpType : activities_model . ActionAutoMergePullRequest ,
Content : fmt . Sprintf ( "%d|%s" , pr . Issue . Index , pr . Issue . Title ) ,
2019-11-21 22:38:42 +05:30
RepoID : pr . Issue . Repo . ID ,
Repo : pr . Issue . Repo ,
IsPrivate : pr . Issue . Repo . IsPrivate ,
} ) ; err != nil {
log . Error ( "NotifyWatchers [%d]: %v" , pr . ID , err )
}
}
2019-11-24 10:46:59 +05:30
2022-06-13 15:07:59 +05:30
func ( * actionNotifier ) NotifyPullRevieweDismiss ( doer * user_model . User , review * issues_model . Review , comment * issues_model . Comment ) {
2021-02-11 23:02:25 +05:30
reviewerName := review . Reviewer . Name
if len ( review . OriginalAuthor ) > 0 {
reviewerName = review . OriginalAuthor
}
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2021-02-11 23:02:25 +05:30
ActUserID : doer . ID ,
ActUser : doer ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionPullReviewDismissed ,
2021-02-11 23:02:25 +05:30
Content : fmt . Sprintf ( "%d|%s|%s" , review . Issue . Index , reviewerName , comment . Content ) ,
RepoID : review . Issue . Repo . ID ,
Repo : review . Issue . Repo ,
IsPrivate : review . Issue . Repo . IsPrivate ,
CommentID : comment . ID ,
Comment : comment ,
} ) ; err != nil {
log . Error ( "NotifyWatchers [%d]: %v" , review . Issue . ID , err )
}
}
2021-12-10 06:57:50 +05:30
func ( a * actionNotifier ) NotifyPushCommits ( pusher * user_model . User , repo * repo_model . Repository , opts * repository . PushUpdateOptions , commits * repository . PushCommits ) {
2020-12-08 07:53:18 +05:30
data , err := json . Marshal ( commits )
if err != nil {
log . Error ( "Marshal: %v" , err )
return
}
2022-08-25 08:01:57 +05:30
opType := activities_model . ActionCommitRepo
2020-12-08 07:53:18 +05:30
// Check it's tag push or branch.
if opts . IsTag ( ) {
2022-08-25 08:01:57 +05:30
opType = activities_model . ActionPushTag
2020-12-08 07:53:18 +05:30
if opts . IsDelRef ( ) {
2022-08-25 08:01:57 +05:30
opType = activities_model . ActionDeleteTag
2020-12-08 07:53:18 +05:30
}
} else if opts . IsDelRef ( ) {
2022-08-25 08:01:57 +05:30
opType = activities_model . ActionDeleteBranch
2020-12-08 07:53:18 +05:30
}
2022-08-25 08:01:57 +05:30
if err = activities_model . NotifyWatchers ( & activities_model . Action {
2020-12-08 07:53:18 +05:30
ActUserID : pusher . ID ,
ActUser : pusher ,
OpType : opType ,
Content : string ( data ) ,
RepoID : repo . ID ,
Repo : repo ,
RefName : opts . RefFullName ,
IsPrivate : repo . IsPrivate ,
} ) ; err != nil {
log . Error ( "notifyWatchers: %v" , err )
}
}
2022-01-20 04:56:57 +05:30
func ( a * actionNotifier ) NotifyCreateRef ( doer * user_model . User , repo * repo_model . Repository , refType , refFullName , refID string ) {
2022-08-25 08:01:57 +05:30
opType := activities_model . ActionCommitRepo
2020-12-08 07:53:18 +05:30
if refType == "tag" {
2021-03-21 15:41:22 +05:30
// has sent same action in `NotifyPushCommits`, so skip it.
return
2020-12-08 07:53:18 +05:30
}
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2020-12-08 07:53:18 +05:30
ActUserID : doer . ID ,
ActUser : doer ,
OpType : opType ,
RepoID : repo . ID ,
Repo : repo ,
IsPrivate : repo . IsPrivate ,
RefName : refFullName ,
} ) ; err != nil {
log . Error ( "notifyWatchers: %v" , err )
}
}
2021-12-10 06:57:50 +05:30
func ( a * actionNotifier ) NotifyDeleteRef ( doer * user_model . User , repo * repo_model . Repository , refType , refFullName string ) {
2022-08-25 08:01:57 +05:30
opType := activities_model . ActionDeleteBranch
2020-12-08 07:53:18 +05:30
if refType == "tag" {
2021-03-21 15:41:22 +05:30
// has sent same action in `NotifyPushCommits`, so skip it.
return
2020-12-08 07:53:18 +05:30
}
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2020-12-08 07:53:18 +05:30
ActUserID : doer . ID ,
ActUser : doer ,
OpType : opType ,
RepoID : repo . ID ,
Repo : repo ,
IsPrivate : repo . IsPrivate ,
RefName : refFullName ,
} ) ; err != nil {
log . Error ( "notifyWatchers: %v" , err )
}
}
2021-12-10 06:57:50 +05:30
func ( a * actionNotifier ) NotifySyncPushCommits ( pusher * user_model . User , repo * repo_model . Repository , opts * repository . PushUpdateOptions , commits * repository . PushCommits ) {
2019-11-24 10:46:59 +05:30
data , err := json . Marshal ( commits )
if err != nil {
log . Error ( "json.Marshal: %v" , err )
return
}
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2019-11-24 10:46:59 +05:30
ActUserID : repo . OwnerID ,
ActUser : repo . MustOwner ( ) ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionMirrorSyncPush ,
2019-11-24 10:46:59 +05:30
RepoID : repo . ID ,
Repo : repo ,
IsPrivate : repo . IsPrivate ,
2020-10-31 03:29:02 +05:30
RefName : opts . RefFullName ,
2019-11-24 10:46:59 +05:30
Content : string ( data ) ,
} ) ; err != nil {
log . Error ( "notifyWatchers: %v" , err )
}
}
2022-01-20 04:56:57 +05:30
func ( a * actionNotifier ) NotifySyncCreateRef ( doer * user_model . User , repo * repo_model . Repository , refType , refFullName , refID string ) {
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2019-11-24 10:46:59 +05:30
ActUserID : repo . OwnerID ,
ActUser : repo . MustOwner ( ) ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionMirrorSyncCreate ,
2019-11-24 10:46:59 +05:30
RepoID : repo . ID ,
Repo : repo ,
IsPrivate : repo . IsPrivate ,
RefName : refFullName ,
} ) ; err != nil {
log . Error ( "notifyWatchers: %v" , err )
}
}
2021-12-10 06:57:50 +05:30
func ( a * actionNotifier ) NotifySyncDeleteRef ( doer * user_model . User , repo * repo_model . Repository , refType , refFullName string ) {
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2019-11-24 10:46:59 +05:30
ActUserID : repo . OwnerID ,
ActUser : repo . MustOwner ( ) ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionMirrorSyncDelete ,
2019-11-24 10:46:59 +05:30
RepoID : repo . ID ,
Repo : repo ,
IsPrivate : repo . IsPrivate ,
RefName : refFullName ,
} ) ; err != nil {
log . Error ( "notifyWatchers: %v" , err )
}
}
2020-07-30 00:50:54 +05:30
2022-08-25 08:01:57 +05:30
func ( a * actionNotifier ) NotifyNewRelease ( rel * repo_model . Release ) {
2020-07-30 00:50:54 +05:30
if err := rel . LoadAttributes ( ) ; err != nil {
log . Error ( "NotifyNewRelease: %v" , err )
return
}
2022-08-25 08:01:57 +05:30
if err := activities_model . NotifyWatchers ( & activities_model . Action {
2020-07-30 00:50:54 +05:30
ActUserID : rel . PublisherID ,
ActUser : rel . Publisher ,
2022-08-25 08:01:57 +05:30
OpType : activities_model . ActionPublishRelease ,
2020-07-30 00:50:54 +05:30
RepoID : rel . RepoID ,
Repo : rel . Repo ,
IsPrivate : rel . Repo . IsPrivate ,
Content : rel . Title ,
RefName : rel . TagName ,
} ) ; err != nil {
log . Error ( "notifyWatchers: %v" , err )
}
}