summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-04-25 10:21:49 -0600
committermo khan <mo@mokhan.ca>2025-04-25 10:21:49 -0600
commit470d99d532a6a9c48f051a2c49db6bc5f4cc3834 (patch)
treefa02c0cdab727a333342e0990447384ae305a66e /pkg
parent2cd89b747c7c255df9197132fcdf04d0c8cd2ff3 (diff)
feat: record the author
Diffstat (limited to 'pkg')
-rw-r--r--pkg/domain/sparkle.go9
-rw-r--r--pkg/domain/user.go8
-rw-r--r--pkg/domain/user_test.go6
3 files changed, 11 insertions, 12 deletions
diff --git a/pkg/domain/sparkle.go b/pkg/domain/sparkle.go
index 5c07fbc..68aed67 100644
--- a/pkg/domain/sparkle.go
+++ b/pkg/domain/sparkle.go
@@ -8,11 +8,10 @@ import (
)
type Sparkle struct {
- ID ID `json:"id" jsonapi:"primary,sparkles"`
- Sparklee string `json:"sparklee" jsonapi:"attr,sparklee"`
- Recipient *User `json:"recipient" jsonapi:"attr,recipient"`
- Author *User `json:"author" jsonapi:"attr,author"`
- Reason string `json:"reason" jsonapi:"attr,reason"`
+ 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"`
}
var SparkleRegex = regexp.MustCompile(`\A\s*(?P<sparklee>@\w+)\s+(?P<reason>.+)\z`)
diff --git a/pkg/domain/user.go b/pkg/domain/user.go
index 5a0420b..aae17f6 100644
--- a/pkg/domain/user.go
+++ b/pkg/domain/user.go
@@ -25,10 +25,10 @@ func (u *User) Validate() error {
return nil
}
-func (self *User) Sparkle(recipient *User, reason string) *Sparkle {
+func (self *User) Sparkle(sparklee string, reason string) *Sparkle {
return &Sparkle{
- Recipient: recipient,
- Author: self,
- Reason: reason,
+ Sparklee: sparklee,
+ Author: self,
+ Reason: reason,
}
}
diff --git a/pkg/domain/user_test.go b/pkg/domain/user_test.go
index dbdba6d..7bcd9d3 100644
--- a/pkg/domain/user_test.go
+++ b/pkg/domain/user_test.go
@@ -10,13 +10,13 @@ import (
func TestUser(t *testing.T) {
t.Run("Sparkle", func(t *testing.T) {
t.Run("returns a new Sparkle", func(t *testing.T) {
- tanuki := &User{}
+ tanuki := &User{Username: "@tanuki"}
user := &User{}
- sparkle := user.Sparkle(tanuki, "for helping me with my homework")
+ sparkle := user.Sparkle(tanuki.Username, "for helping me with my homework")
require.NotNil(t, sparkle)
- assert.Equal(t, tanuki, sparkle.Recipient)
+ assert.Equal(t, tanuki.Username, sparkle.Sparklee)
assert.Equal(t, "for helping me with my homework", sparkle.Reason)
assert.Equal(t, user, sparkle.Author)
})