notification

package
v0.0.0-...-4c964c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TemplateReviewerAdded        = "reviewer_added.html"
	TemplateCommentPRAuthor      = "comment_pr_author.html"
	TemplateCommentMentions      = "comment_mentions.html"
	TemplateCommentParticipants  = "comment_participants.html"
	TemplatePullReqBranchUpdated = "pullreq_branch_updated.html"
	TemplateNameReviewSubmitted  = "review_submitted.html"
	TemplatePullReqStateChanged  = "pullreq_state_changed.html"
)

Variables

Functions

func GenerateEmailFromPayload

func GenerateEmailFromPayload(
	templateName string,
	recipients []*types.PrincipalInfo,
	base *BasePullReqPayload,
	payload interface{},
) (*mailer.Payload, error)

func GetHTMLBody

func GetHTMLBody(templateName string, data interface{}) ([]byte, error)

func GetSubjectPullRequest

func GetSubjectPullRequest(
	repoIdentifier string,
	prNum int64,
	prTitle string,
) string

func LoadTemplates

func LoadTemplates() error

func RetrieveEmailsFromPrincipals

func RetrieveEmailsFromPrincipals(principals []*types.PrincipalInfo) []string

Types

type BasePullReqPayload

type BasePullReqPayload struct {
	Repo       *types.Repository
	PullReq    *types.PullReq
	Author     *types.PrincipalInfo
	PullReqURL string
}

type Client

type Client interface {
	SendCommentPRAuthor(
		ctx context.Context,
		recipients []*types.PrincipalInfo,
		payload *CommentPayload,
	) error
	SendCommentMentions(
		ctx context.Context,
		recipients []*types.PrincipalInfo,
		payload *CommentPayload,
	) error
	SendCommentParticipants(
		ctx context.Context,
		recipients []*types.PrincipalInfo,
		payload *CommentPayload,
	) error
	SendReviewerAdded(
		ctx context.Context,
		recipients []*types.PrincipalInfo,
		payload *ReviewerAddedPayload,
	) error
	SendPullReqBranchUpdated(
		ctx context.Context,
		recipients []*types.PrincipalInfo,
		payload *PullReqBranchUpdatedPayload,
	) error
	SendReviewSubmitted(
		ctx context.Context,
		recipients []*types.PrincipalInfo,
		payload *ReviewSubmittedPayload,
	) error
	SendPullReqStateChanged(
		ctx context.Context,
		recipients []*types.PrincipalInfo,
		payload *PullReqStateChangedPayload,
	) error
}

Client is an interface for sending notifications, such as emails, Slack messages etc. It is implemented by MailClient and in future we can have other implementations for other channels like Slack etc.

func ProvideMailClient

func ProvideMailClient(mailer mailer.Mailer) Client

type CommentPayload

type CommentPayload struct {
	Base      *BasePullReqPayload
	Commenter *types.PrincipalInfo
	Text      string
}

type Config

type Config struct {
	EventReaderName string
	Concurrency     int
	MaxRetries      int
}

type MailClient

type MailClient struct {
	mailer.Mailer
}

func NewMailClient

func NewMailClient(mailer mailer.Mailer) MailClient

func (MailClient) SendCommentMentions

func (m MailClient) SendCommentMentions(
	ctx context.Context,
	recipients []*types.PrincipalInfo,
	payload *CommentPayload,
) error

func (MailClient) SendCommentPRAuthor

func (m MailClient) SendCommentPRAuthor(
	ctx context.Context,
	recipients []*types.PrincipalInfo,
	payload *CommentPayload,
) error

func (MailClient) SendCommentParticipants

func (m MailClient) SendCommentParticipants(
	ctx context.Context,
	recipients []*types.PrincipalInfo,
	payload *CommentPayload,
) error

func (MailClient) SendPullReqBranchUpdated

func (m MailClient) SendPullReqBranchUpdated(
	ctx context.Context,
	recipients []*types.PrincipalInfo,
	payload *PullReqBranchUpdatedPayload,
) error

func (MailClient) SendPullReqStateChanged

func (m MailClient) SendPullReqStateChanged(
	ctx context.Context,
	recipients []*types.PrincipalInfo,
	payload *PullReqStateChangedPayload,
) error

func (MailClient) SendReviewSubmitted

func (m MailClient) SendReviewSubmitted(
	ctx context.Context,
	recipients []*types.PrincipalInfo,
	payload *ReviewSubmittedPayload,
) error

func (MailClient) SendReviewerAdded

func (m MailClient) SendReviewerAdded(
	ctx context.Context,
	recipients []*types.PrincipalInfo,
	payload *ReviewerAddedPayload,
) error

type PullReqBranchUpdatedPayload

type PullReqBranchUpdatedPayload struct {
	Base      *BasePullReqPayload
	Committer *types.PrincipalInfo
	NewSHA    string
}

type PullReqState

type PullReqState string
const (
	PullReqStateMerged   PullReqState = "merged"
	PullReqStateClosed   PullReqState = "closed"
	PullReqStateReopened PullReqState = "reopened"
)

type PullReqStateChangedPayload

type PullReqStateChangedPayload struct {
	Base      *BasePullReqPayload
	ChangedBy *types.PrincipalInfo
	State     PullReqState
}

type ReviewSubmittedPayload

type ReviewSubmittedPayload struct {
	Base     *BasePullReqPayload
	Author   *types.PrincipalInfo
	Reviewer *types.PrincipalInfo
	Decision enum.PullReqReviewDecision
}

type ReviewerAddedPayload

type ReviewerAddedPayload struct {
	Base     *BasePullReqPayload
	Reviewer *types.PrincipalInfo
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(
	ctx context.Context,
	config Config,
	notificationClient Client,
	prReaderFactory *events.ReaderFactory[*pullreqevents.Reader],
	pullReqStore store.PullReqStore,
	repoStore store.RepoStore,
	principalInfoView store.PrincipalInfoView,
	principalInfoCache store.PrincipalInfoCache,
	pullReqReviewersStore store.PullReqReviewerStore,
	pullReqActivityStore store.PullReqActivityStore,
	spacePathStore store.SpacePathStore,
	urlProvider url.Provider,
) (*Service, error)

func ProvideNotificationService

func ProvideNotificationService(
	ctx context.Context,
	notificationClient Client,
	pullReqConfig Config,
	prReaderFactory *events.ReaderFactory[*pullreqevents.Reader],
	pullReqStore store.PullReqStore,
	repoStore store.RepoStore,
	principalInfoView store.PrincipalInfoView,
	principalInfoCache store.PrincipalInfoCache,
	pullReqReviewersStore store.PullReqReviewerStore,
	pullReqActivityStore store.PullReqActivityStore,
	spacePathStore store.SpacePathStore,
	urlProvider url.Provider,
) (*Service, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL