summaryrefslogtreecommitdiff
path: root/app/domain/user.go
blob: a6adfa8819b1c4e2ea11ba8324c32d00bc8ca910 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package domain

import "github.com/xlgmokha/x/pkg/x"

type User struct {
	ID         ID     `json:"id" jsonapi:"primary,users"`
	Username   string `json:"username" jsonapi:"attr,username"`
	ProfileURL string `json:"profile" jsonapi:"attr,profile"`
	Picture    string `json:"picture" jsonapi:"attr,picture"`
}

func NewUser(options ...x.Configure[*User]) *User {
	user := &User{}
	for _, option := range options {
		option(user)
	}
	return user
}

func (u *User) GetID() ID {
	return u.ID
}

func (u *User) SetID(id ID) error {
	u.ID = id
	return nil
}

func (u *User) Validate() error {
	return nil
}

func (self *User) Sparkle(sparklee string, reason string) *Sparkle {
	return &Sparkle{
		Sparklee: sparklee,
		Author:   self,
		Reason:   reason,
	}
}

func (self *User) ToGID() string {
	return "gid://sparkle/User/" + self.ID.String()
}