blob: c9dcfb4aac62fa8e2245b84ec75aa18d30461cd8 (
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
44
45
46
47
48
49
50
51
|
package domain
import (
v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
)
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 (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()
}
func (self *User) ToSubjectReference() *v1.SubjectReference {
return &v1.SubjectReference{
Object: self.ToObjectReference(),
}
}
func (self *User) ToObjectReference() *v1.ObjectReference {
return &v1.ObjectReference{
ObjectType: "user",
// ObjectId: self.ID.String(),
ObjectId: self.Username,
}
}
|