All parameters are now of pointer type and thus can be nil
This commit is contained in:
parent
636b33ad1c
commit
e71411ef96
14
accounts.go
14
accounts.go
|
@ -41,10 +41,10 @@ type Field struct {
|
|||
|
||||
// AccountSource is a Mastodon account profile field.
|
||||
type AccountSource struct {
|
||||
Privacy string `json:"privacy"`
|
||||
Privacy *string `json:"privacy"`
|
||||
Sensitive *bool `json:"sensitive"`
|
||||
Language string `json:"language"`
|
||||
Note string `json:"note"`
|
||||
Language *string `json:"language"`
|
||||
Note *string `json:"note"`
|
||||
Fields *[]Field `json:"fields"`
|
||||
}
|
||||
|
||||
|
@ -102,14 +102,14 @@ func (c *Client) AccountUpdate(ctx context.Context, profile *Profile) (*Account,
|
|||
}
|
||||
}
|
||||
if profile.Source != nil {
|
||||
if len(profile.Source.Privacy) > 0 {
|
||||
params.Set("source[privacy]", profile.Source.Privacy)
|
||||
if profile.Source.Privacy != nil {
|
||||
params.Set("source[privacy]", *profile.Source.Privacy)
|
||||
}
|
||||
if profile.Source.Sensitive != nil {
|
||||
params.Set("source[sensitive]", strconv.FormatBool(*profile.Source.Sensitive))
|
||||
}
|
||||
if len(profile.Source.Language) > 0 {
|
||||
params.Set("source[language]", profile.Source.Language)
|
||||
if profile.Source.Language != nil {
|
||||
params.Set("source[language]", *profile.Source.Language)
|
||||
}
|
||||
}
|
||||
if profile.Avatar != "" {
|
||||
|
|
|
@ -96,7 +96,7 @@ func TestAccountUpdate(t *testing.T) {
|
|||
}
|
||||
tbool := true
|
||||
fields := []Field{{"foo", "bar", time.Time{}}, {"dum", "baz", time.Time{}}}
|
||||
source := AccountSource{Language: "de", Privacy: "public", Sensitive: &tbool}
|
||||
source := AccountSource{Language: String("de"), Privacy: String("public"), Sensitive: &tbool}
|
||||
a, err := client.AccountUpdate(context.Background(), &Profile{
|
||||
DisplayName: String("display_name"),
|
||||
Note: String("note"),
|
||||
|
|
Loading…
Reference in New Issue
Block a user