package domain import ( v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" "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 (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() GlobalID { if x.IsZero(self.Username) { return GlobalID("gid://sparkle/User/*") } return GlobalID("gid://sparkle/User/" + self.Username) } func (self *User) ToSubjectReference() *v1.SubjectReference { return &v1.SubjectReference{ Object: self.ToGID().ToObjectReference(), } }