mirror of
https://github.com/harness/drone.git
synced 2025-05-10 21:00:04 +08:00
feat: [CODE-2425]: Add webhook and trigger for all comment types (#2815)
* feat: [CODE-2425]: Arg format * Merge branch 'main' into akp/CODE-2425 * feat: [CODE-2425]: return immediately in notification service if its a code-comment * feat: [CODE-2425]: send gitness comment type * Merge branch 'main' into akp/CODE-2425 * feat: [CODE-2425]: Add webhook and trigger for all comment types
This commit is contained in:
parent
d79a1a290c
commit
b848c642fc
@ -220,9 +220,14 @@ func (c *Controller) CommentCreate(
|
||||
log.Ctx(ctx).Warn().Err(err).Msg("failed to publish PR changed event")
|
||||
}
|
||||
|
||||
// if it's a regular comment publish a comment create event
|
||||
if act.Type == enum.PullReqActivityTypeComment && act.Kind == enum.PullReqActivityKindComment {
|
||||
c.reportCommentCreated(ctx, pr, session.Principal.ID, act.ID, act.IsReply())
|
||||
// publish event for all comments
|
||||
if act.Type == enum.PullReqActivityTypeComment || act.Type == enum.PullReqActivityTypeCodeComment {
|
||||
c.reportCommentCreated(
|
||||
ctx,
|
||||
pr,
|
||||
session.Principal.ID,
|
||||
act.ID, act.IsReply(),
|
||||
)
|
||||
}
|
||||
|
||||
err = c.instrumentation.Track(ctx, instrument.Event{
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
pullreqevents "github.com/harness/gitness/app/events/pullreq"
|
||||
"github.com/harness/gitness/events"
|
||||
"github.com/harness/gitness/types"
|
||||
gitnessenum "github.com/harness/gitness/types/enum"
|
||||
)
|
||||
|
||||
type CommentPayload struct {
|
||||
@ -106,6 +107,10 @@ func (s *Service) processCommentCreatedEvent(
|
||||
return nil, nil, nil, nil, fmt.Errorf("failed to fetch activity from pullReqActivityStore: %w", err)
|
||||
}
|
||||
|
||||
if activity.Type != gitnessenum.PullReqActivityTypeComment {
|
||||
return nil, nil, nil, nil, fmt.Errorf("code-comments are not supported currently")
|
||||
}
|
||||
|
||||
commenter, err := s.principalInfoView.Find(ctx, activity.CreatedBy)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, fmt.Errorf("failed to fetch commenter from principalInfoView: %w", err)
|
||||
|
@ -359,6 +359,7 @@ func (s *Service) handleEventPullReqComment(
|
||||
Text: activity.Text,
|
||||
ID: activity.ID,
|
||||
ParentID: activity.ParentID,
|
||||
Kind: activity.Kind,
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
|
@ -302,6 +302,7 @@ type CommentInfo struct {
|
||||
ID int64 `json:"id"`
|
||||
ParentID *int64 `json:"parent_id,omitempty"`
|
||||
Text string `json:"text"`
|
||||
Kind enum.PullReqActivityKind `json:"kind"`
|
||||
}
|
||||
|
||||
type LabelInfo struct {
|
||||
|
Loading…
Reference in New Issue
Block a user