application

package
v0.22.4 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package application holds the notification use cases — the PR-lifecycle handlers (open/close/draft and the review-reaction handlers) and the event dispatcher — behind the domain's Handler and use-case interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectBot

func DetectBot(login string) domain.BotKind

DetectBot matches login against the two known dependency-bot logins, case-insensitively. The surface is exactly two values, so the match is exact — prefix matching ("dependabot") is intentionally not a hit. Callers pass the PR author so the classification follows who opened the PR, not who fired the webhook.

func IsSecurityAdvisory

func IsSecurityAdvisory(prBody string) bool

IsSecurityAdvisory reports whether prBody carries the advisory section that marks a security update. A miss returns false (routine) — the safe default.

Types

type ApproveHandler

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

ApproveHandler adds a reaction when a review is submitted with state "approved".

func NewApproveHandler

func NewApproveHandler(store domain.MessageStore, behavior domain.RepoBehavior, messenger domain.Messenger, logger *slog.Logger, reviews domain.ReviewSessions) *ApproveHandler

NewApproveHandler builds an ApproveHandler.

func (*ApproveHandler) Applicable

func (h *ApproveHandler) Applicable(event kernel.Event) bool

func (*ApproveHandler) Handle

func (h *ApproveHandler) Handle(ctx context.Context, event kernel.Event) error

type CloseHandler

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

CloseHandler reacts to a PR being closed (merged or not). It updates every stored message with a [Merged]/[Closed] decoration and, if enabled, adds the corresponding reaction to each.

func NewCloseHandler

func NewCloseHandler(store domain.MessageStore, behavior domain.RepoBehavior, messenger domain.Messenger, logger *slog.Logger, reviews domain.ReviewSessions) *CloseHandler

NewCloseHandler builds a CloseHandler.

func (*CloseHandler) Applicable

func (h *CloseHandler) Applicable(event kernel.Event) bool

Applicable returns true when a PR is closed, merged or not. The adapter splits GitHub's single "closed" action into KindMerged/KindClosed; Handle still reads PR.Merged to pick the decoration and emoji.

func (*CloseHandler) Handle

func (h *CloseHandler) Handle(ctx context.Context, event kernel.Event) error

Handle updates every stored message and optionally adds a reaction to each.

type CommentedHandler

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

CommentedHandler adds a reaction when a review is submitted or edited with state "commented".

func NewCommentedHandler

func NewCommentedHandler(store domain.MessageStore, behavior domain.RepoBehavior, messenger domain.Messenger, logger *slog.Logger, reviews domain.ReviewSessions) *CommentedHandler

NewCommentedHandler builds a CommentedHandler.

func (*CommentedHandler) Applicable

func (h *CommentedHandler) Applicable(event kernel.Event) bool

func (*CommentedHandler) Handle

func (h *CommentedHandler) Handle(ctx context.Context, event kernel.Event) error

type Dispatcher

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

Dispatcher routes an event to the first registered handler whose Applicable returns true. Handlers are checked in registration order. If none matches, Dispatch logs a Debug line and returns nil (no error) so the HTTP layer still responds 200 OK.

func NewDispatcher

func NewDispatcher(logger *slog.Logger, handlers []domain.Handler) *Dispatcher

NewDispatcher builds a Dispatcher with the given handlers. Registration order is preserved. The logger receives one Debug record per event with no applicable handler.

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(ctx context.Context, event kernel.Event) error

Dispatch finds the first applicable handler and runs it. Errors from the chosen handler are wrapped and returned.

type DraftHandler

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

DraftHandler reacts to a PR being converted back to draft. It removes every stored message and deletes the PR row — the PR will be re-announced when it is marked ready_for_review again.

func NewDraftHandler

func NewDraftHandler(store domain.MessageStore, messenger domain.Messenger, logger *slog.Logger) *DraftHandler

NewDraftHandler builds a DraftHandler.

func (*DraftHandler) Applicable

func (h *DraftHandler) Applicable(event kernel.Event) bool

Applicable returns true when a PR is converted back to draft.

func (*DraftHandler) Handle

func (h *DraftHandler) Handle(ctx context.Context, event kernel.Event) error

Handle deletes every stored message and the PR row.

type OpenHandler

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

OpenHandler reacts to a PR being opened (non-draft) or marked ready_for_review. It fans out one notification per resolved target channel and records each for later updates.

func NewOpenHandler

func NewOpenHandler(store domain.MessageStore, resolver domain.TargetResolver, messenger domain.Messenger, logger *slog.Logger) *OpenHandler

NewOpenHandler builds an OpenHandler.

func (*OpenHandler) Applicable

func (h *OpenHandler) Applicable(event kernel.Event) bool

Applicable returns true for a freshly opened or ready-for-review PR. The inbound adapter does the draft gating (a draft open never yields KindOpened), so no handler branches on PR.Draft.

func (*OpenHandler) Handle

func (h *OpenHandler) Handle(ctx context.Context, event kernel.Event) error

Handle posts one notification per resolved target channel and records each. It is idempotent per channel: an existing message for a channel is skipped, so a redelivery or a partial-failure retry only posts the missing channels.

type RequestChangeHandler

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

RequestChangeHandler adds a reaction when a review is submitted with state "changes_requested".

func NewRequestChangeHandler

func NewRequestChangeHandler(store domain.MessageStore, behavior domain.RepoBehavior, messenger domain.Messenger, logger *slog.Logger, reviews domain.ReviewSessions) *RequestChangeHandler

NewRequestChangeHandler builds a RequestChangeHandler.

func (*RequestChangeHandler) Applicable

func (h *RequestChangeHandler) Applicable(event kernel.Event) bool

func (*RequestChangeHandler) Handle

func (h *RequestChangeHandler) Handle(ctx context.Context, event kernel.Event) error

Jump to

Keyboard shortcuts

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