initial commits

master
Charles Iliya Krempeaux 2023-09-26 13:48:44 +09:00
parent 431d019447
commit 9af222354c
1 changed files with 17 additions and 3 deletions

View File

@ -21,6 +21,12 @@ const (
// See: // See:
// https://docs.joinmastodon.org/entities/Field/ // https://docs.joinmastodon.org/entities/Field/
type Field struct { type Field struct {
Name opt.Optional[string]
Value opt.Optional[string]
VerifiedAt nul.Nullable[string]
}
type field struct {
Name opt.Optional[string] `json:"name"` Name opt.Optional[string] `json:"name"`
Value opt.Optional[string] `json:"value"` Value opt.Optional[string] `json:"value"`
VerifiedAt nul.Nullable[string] `json:"verified_at"` VerifiedAt nul.Nullable[string] `json:"verified_at"`
@ -78,13 +84,21 @@ func (receiver *Field) UnmarshalJSON(data []byte) error {
return errNilReceiver return errNilReceiver
} }
err := json.Unmarshal(data, receiver) var f field
err := json.Unmarshal(data, &f)
if nil != err { if nil != err {
return err return err
} }
if nul.Null[string]() == receiver.VerifiedAt { if nul.Null[string]() == f.VerifiedAt {
receiver.VerifiedAt = nul.Nothing[string]() f.VerifiedAt = nul.Nothing[string]()
}
*receiver = Field{
Name: f.Name,
Value: f.Value,
VerifiedAt: f.VerifiedAt,
} }
return nil return nil