initial commits
parent
1e327c0bc4
commit
dc72440189
18
ent/role.go
18
ent/role.go
|
@ -7,6 +7,7 @@ import (
|
|||
"sourcecode.social/reiver/go-jsonint"
|
||||
)
|
||||
|
||||
var _ json.Marshaler = Role{}
|
||||
var _ json.Unmarshaler = new(Role)
|
||||
|
||||
// Role represents a Mastodon API "Role".
|
||||
|
@ -29,6 +30,23 @@ type role struct {
|
|||
Highlighted opt.Optional[bool] `json:"Highlighted"`
|
||||
}
|
||||
|
||||
func (receiver Role) MarshalJSON() ([]byte, error) {
|
||||
|
||||
var src role
|
||||
|
||||
src.ID = receiver.ID
|
||||
src.Name = receiver.Name
|
||||
src.Permissions = receiver.Permissions
|
||||
src.Highlighted = src.Highlighted
|
||||
|
||||
src.Color = receiver.Color
|
||||
receiver.Color.WhenNothing(func(){
|
||||
src.Color = opt.Something("")
|
||||
})
|
||||
|
||||
return json.Marshal(src)
|
||||
}
|
||||
|
||||
func (receiver *Role) UnmarshalJSON(data []byte) error {
|
||||
if nil == receiver {
|
||||
return errNilReceiver
|
||||
|
|
Loading…
Reference in New Issue