comment

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID               uuid.UUID
	Resource         resource.Ref
	ParentID         *uuid.UUID
	AuthorCapacityID uuid.UUID
	Body             string
	Status           string
	Version          int
	CreatedAt        time.Time
	CreatedBy        uuid.UUID
	UpdatedAt        *time.Time
	UpdatedBy        *uuid.UUID
}

Comment is a persisted comment row.

type CreateIn

type CreateIn struct {
	Resource         resource.Ref
	ParentID         *uuid.UUID
	AuthorCapacityID uuid.UUID
	Body             string
}

CreateIn is the input to Create.

type Service

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

Service manages comments inside a tenant transaction.

func New

func New(idgen model.IDGen, ob outbox.Writer) *Service

New wires the service. ob may be nil.

func (*Service) Create

func (s *Service) Create(ctx context.Context, db database.TenantDB, in CreateIn) (uuid.UUID, error)

Create inserts a new comment. Validates inputs; checks parent thread consistency.

func (*Service) Edit

func (s *Service) Edit(ctx context.Context, db database.TenantDB, id uuid.UUID, expectedVersion int, newBody string) error

Edit updates a comment body with optimistic locking. Voided comments cannot be edited. When ob is wired, emits "comment.edited" with previous and new body for audit history.

func (*Service) List

func (s *Service) List(ctx context.Context, db database.TenantDB, ref resource.Ref) ([]Comment, error)

List returns all comments for the given resource, ordered by created_at ASC. Includes all statuses (active, edited, voided).

func (*Service) Void

func (s *Service) Void(ctx context.Context, db database.TenantDB, id uuid.UUID, expectedVersion int) error

Void sets a comment's status to 'voided' with optimistic locking. Only the comment's author may void it (SEC-45).

Jump to

Keyboard shortcuts

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