domain

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 4 Imported by: 0

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

View Source
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

View Source
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

This section is empty.

Types

type BotFormat

type BotFormat struct {
	Name     string
	Security bool
}

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.

const (
	BotKindNone BotKind = iota
	BotKindDependabot
	BotKindRenovate
)

Recognised dependency-bot kinds.

func (BotKind) Name

func (k BotKind) Name() string

Name returns the bot's display name ("dependabot"/"renovate"), or "" for none.

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

type EventDispatcher interface {
	Dispatch(ctx context.Context, event kernel.Event) error
}

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

type Message struct {
	Channel   string
	MessageID string
}

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

type ReviewSession struct {
	SlackUserID   string
	SlackUserName string
}

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.

Jump to

Keyboard shortcuts

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