diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-24 15:55:09 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-24 15:55:09 -0600 |
| commit | f6ad289b8d27219c47aefec24113ccb02a62dd99 (patch) | |
| tree | 8febaf35f6686c3f46ed4b8a1990138b6f622300 /app/domain/sparkle.go | |
| parent | 7fb5255aafc435f5b47725716963f3aebfb9feb2 (diff) | |
refactor: extract defaultEntity type
Diffstat (limited to 'app/domain/sparkle.go')
| -rw-r--r-- | app/domain/sparkle.go | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/app/domain/sparkle.go b/app/domain/sparkle.go index 2ea5a53..10e24de 100644 --- a/app/domain/sparkle.go +++ b/app/domain/sparkle.go @@ -9,10 +9,10 @@ import ( ) type Sparkle struct { - ID ID `json:"id" jsonapi:"primary,sparkles"` Sparklee string `json:"sparklee" jsonapi:"attr,sparklee"` Author *User `json:"author" jsonapi:"attr,author"` Reason string `json:"reason" jsonapi:"attr,reason"` + defaultEntity } var SparkleRegex = regexp.MustCompile(`\A\s*(?P<sparklee>@\w+)\s+(?P<reason>.+)\z`) @@ -35,21 +35,12 @@ func NewSparkle(text string) (*Sparkle, error) { } return &Sparkle{ - ID: ID(pls.GenerateULID()), - Sparklee: matches[SparkleeIndex], - Reason: matches[ReasonIndex], + defaultEntity: defaultEntity{ID: ID(pls.GenerateULID())}, + Sparklee: matches[SparkleeIndex], + Reason: matches[ReasonIndex], }, nil } -func (s *Sparkle) GetID() ID { - return s.ID -} - -func (s *Sparkle) SetID(id ID) error { - s.ID = id - return nil -} - func (s *Sparkle) ToGID() string { return "gid://sparkle/Sparkle/" + s.ID.String() } |
