Browse Source

提交上传数据集的通知信息

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.2.2^2
zouap 4 years ago
parent
commit
755688bb6f
6 changed files with 33 additions and 1 deletions
  1. +2
    -0
      models/action.go
  2. +15
    -0
      modules/notification/action/action.go
  3. +2
    -0
      modules/notification/base/notifier.go
  4. +4
    -0
      modules/notification/base/null.go
  5. +7
    -0
      modules/notification/notification.go
  6. +3
    -1
      routers/repo/attachment.go

+ 2
- 0
models/action.go View File

@@ -49,6 +49,8 @@ const (
ActionApprovePullRequest // 21
ActionRejectPullRequest // 22
ActionCommentPull // 23

ActionUploadAttachment //24
)

// Action represents user operation type and other information to


+ 15
- 0
modules/notification/action/action.go View File

@@ -314,3 +314,18 @@ func (a *actionNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Rep
log.Error("notifyWatchers: %v", err)
}
}

func NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) {
if err := models.NotifyWatchers(&models.Action{
ActUserID: repo.OwnerID,
ActUser: repo.MustOwner(),
OpType: models.ActionUploadAttachment,
RepoID: repo.ID,
Repo: repo,
IsPrivate: repo.IsPrivate,
RefName: attachment.Name,
Content: attachment.UUID,
}); err != nil {
log.Error("notifyWatchers: %v", err)
}
}

+ 2
- 0
modules/notification/base/notifier.go View File

@@ -53,4 +53,6 @@ type Notifier interface {
NotifySyncPushCommits(pusher *models.User, repo *models.Repository, refName, oldCommitID, newCommitID string, commits *repository.PushCommits)
NotifySyncCreateRef(doer *models.User, repo *models.Repository, refType, refFullName string)
NotifySyncDeleteRef(doer *models.User, repo *models.Repository, refType, refFullName string)

NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment)
}

+ 4
- 0
modules/notification/base/null.go View File

@@ -150,3 +150,7 @@ func (*NullNotifier) NotifySyncCreateRef(doer *models.User, repo *models.Reposit
// NotifySyncDeleteRef places a place holder function
func (*NullNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Repository, refType, refFullName string) {
}

func (*NullNotifier) NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) {

}

+ 7
- 0
modules/notification/notification.go View File

@@ -37,6 +37,13 @@ func NewContext() {
RegisterNotifier(action.NewNotifier())
}

// NotifyUploadAttachment notifies attachment upload message to notifiers
func NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) {
for _, notifier := range notifiers {
notifier.NotifyUploadAttachment(doer, repo, attachment)
}
}

// NotifyCreateIssueComment notifies issue comment related message to notifiers
func NotifyCreateIssueComment(doer *models.User, repo *models.Repository,
issue *models.Issue, comment *models.Comment) {


+ 3
- 1
routers/repo/attachment.go View File

@@ -20,11 +20,11 @@ import (
"code.gitea.io/gitea/modules/labelmsg"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/minio_ext"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/upload"
"code.gitea.io/gitea/modules/worker"

gouuid "github.com/satori/go.uuid"
)

@@ -846,6 +846,8 @@ func CompleteMultipart(ctx *context.Context) {
return
}

notification.NotifyUploadAttachment(ctx.User, ctx.Repo.Repository, attachment)

if attachment.DatasetID != 0 {
if isCanDecompress(attachment.Name) {
if typeCloudBrain == models.TypeCloudBrainOne {


Loading…
Cancel
Save