Documentation
¶
Overview ¶
Package domain defines the notification domain's ports, DTOs, enums, and policies — the contracts for keeping one chat message per (PR, channel) in sync with GitHub PR events. It imports only the standard library, the shared kernel, and the routing domain.
Index ¶
- Constants
- Variables
- func IsBot(senderType string) bool
- type BotFormat
- type BotKind
- type ClosedRequest
- type EventDispatcher
- type Handler
- type Message
- type MessageStore
- type Messenger
- type OpenRequest
- type RepoBehavior
- type ReviewFinishedRequest
- type ReviewSession
- type ReviewSessions
- type TargetResolver
Constants ¶
const ( ReasonNoHandler = "no_handler" ReasonNoMapping = "no_mapping" ReasonNoStoredMessage = "no_stored_message" ReasonAlreadySent = "already_sent" )
Ignored-event reason codes, logged on every silent no-op so a 200-OK delivery that changed nothing can be triaged.
Variables ¶
var ErrNoActiveReview = errors.New("notification: no active review session")
ErrNoActiveReview marks the absence of an in-progress review session for a PR. The reaction handlers treat it as "no session to finish", not a failure.
Functions ¶
func IsBot ¶
IsBot reports whether a webhook sender is a bot (a GitHub App). The reaction handlers use it to suppress reactions to automated reviews when a repo enables IgnoreAIReviews. It intentionally does not distinguish AI reviewers from scripted bots — Copilot, dependabot, and github-actions all present as "Bot" in the payload.
Types ¶
type BotFormat ¶
BotFormat carries the dependency-bot template inputs: the bot's display name and whether the PR body reads as a security advisory.
type BotKind ¶
type BotKind int
BotKind classifies a PR author as a known dependency bot (or none). Moved from the botpr package; drives the compact dependency-bot open template.
Recognised dependency-bot kinds.
type ClosedRequest ¶
type ClosedRequest struct {
Repository string
PR kernel.PR
Merged bool
Emoji string
ReviewerIDs []string
}
ClosedRequest is the intent to update a message for a closed/merged PR. Emoji is the merged/closed reaction; ReviewerIDs, when non-empty, appends a "reviewed by" marker.
type EventDispatcher ¶
EventDispatcher routes an incoming event to the first applicable handler.
type Handler ¶
type Handler interface {
Applicable(event kernel.Event) bool
Handle(ctx context.Context, event kernel.Event) error
}
Handler is implemented by each PR-lifecycle use case. Applicable inspects an event and returns true if Handle should run; the dispatcher runs the first applicable handler and skips the rest (handlers are mutually exclusive).
type Message ¶
Message is one posted chat message for a PR: the channel it lives in and the platform's id for the post. Mapped from the store's persistence model at the repository boundary.
type MessageStore ¶
type MessageStore interface {
AddMessage(ctx context.Context, repository string, prNumber int, channel, messageID string) error
Messages(ctx context.Context, repository string, prNumber int) ([]Message, error)
Touch(ctx context.Context, repository string, prNumber int) error
MarkClosed(ctx context.Context, repository string, prNumber int) error
Delete(ctx context.Context, repository string, prNumber int) error
}
MessageStore persists tracked PRs and their per-channel chat messages.
type Messenger ¶
type Messenger interface {
PostOpen(ctx context.Context, channel string, req OpenRequest) (messageID string, err error)
UpdateClosed(ctx context.Context, channel, messageID string, req ClosedRequest) error
UpdateReviewFinished(ctx context.Context, channel, messageID string, req ReviewFinishedRequest) error
AddReaction(ctx context.Context, channel, messageID, emoji string) error
Delete(ctx context.Context, channel, messageID string) error
}
Messenger delivers notification messages to the chat platform. It receives domain intent — which notification, for which PR, with which data — and its adapter owns the message shaping (which blocks/markers). The infra Slack messenger is the only implementation.
type OpenRequest ¶
type OpenRequest struct {
Repository string
PR kernel.PR
Mentions []string
NewPREmoji string
Bot *BotFormat
}
OpenRequest is the intent to post an opened-PR notification. Bot, when non-nil, selects the compact dependency-bot template; otherwise the standard template is rendered with NewPREmoji.
type RepoBehavior ¶
type RepoBehavior interface {
Get(ctx context.Context, repository string) (routingdomain.RepoMapping, error)
}
RepoBehavior resolves a repository's per-repo behavioral config (reactions, review flags). Close/draft/reaction handlers need it but not the per-channel targets.
type ReviewFinishedRequest ¶
type ReviewFinishedRequest struct {
Repository string
PR kernel.PR
ReviewerIDs []string
NewPREmoji string
}
ReviewFinishedRequest is the intent to refresh a message after its active review session finishes: the standard message is rebuilt and, when reviewers exist, a "reviewed by" marker is appended.
type ReviewSession ¶
ReviewSession is the notification view of one review session: who is (or was) reviewing. Mapped from the review store at the boundary.
type ReviewSessions ¶
type ReviewSessions interface {
GetActive(ctx context.Context, repository string, prNumber int) (ReviewSession, error)
Finish(ctx context.Context, repository string, prNumber int) error
Reviewers(ctx context.Context, repository string, prNumber int) ([]ReviewSession, error)
}
ReviewSessions is the review-session view the reaction and close handlers use. The review domain satisfies it in a later phase; the code-reviews store satisfies it today (via an infra adapter). GetActive returns ErrNoActiveReview when the PR has no in-progress session.
type TargetResolver ¶
type TargetResolver interface {
ResolveTargets(ctx context.Context, repository string, prNumber int) (routingdomain.RepoMapping, []routingdomain.Target, error)
}
TargetResolver resolves the open fan-out: per-repo behavior plus the per-channel targets a newly opened PR is announced to.