From be6120570837cb461e6c52349d7917154af8af87 Mon Sep 17 00:00:00 2001 From: Darren O'Connor Date: Wed, 16 Nov 2022 01:57:22 +0000 Subject: [PATCH 1/2] Remove unused variables --- accounts_test.go | 8 ++++---- lists_test.go | 12 ++++++------ report_test.go | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/accounts_test.go b/accounts_test.go index 473e9b6..47e0310 100644 --- a/accounts_test.go +++ b/accounts_test.go @@ -303,11 +303,11 @@ func TestAccountFollow(t *testing.T) { ClientSecret: "bar", AccessToken: "zoo", }) - rel, err := client.AccountFollow(context.Background(), "123") + _, err := client.AccountFollow(context.Background(), "123") if err == nil { t.Fatalf("should be fail: %v", err) } - rel, err = client.AccountFollow(context.Background(), "1234567") + rel, err := client.AccountFollow(context.Background(), "1234567") if err != nil { t.Fatalf("should not be fail: %v", err) } @@ -335,11 +335,11 @@ func TestAccountUnfollow(t *testing.T) { ClientSecret: "bar", AccessToken: "zoo", }) - rel, err := client.AccountUnfollow(context.Background(), "123") + _, err := client.AccountUnfollow(context.Background(), "123") if err == nil { t.Fatalf("should be fail: %v", err) } - rel, err = client.AccountUnfollow(context.Background(), "1234567") + rel, err := client.AccountUnfollow(context.Background(), "1234567") if err != nil { t.Fatalf("should not be fail: %v", err) } diff --git a/lists_test.go b/lists_test.go index 5cca304..b1c9e3b 100644 --- a/lists_test.go +++ b/lists_test.go @@ -125,11 +125,11 @@ func TestGetList(t *testing.T) { ClientSecret: "bar", AccessToken: "zoo", }) - list, err := client.GetList(context.Background(), "2") + _, err := client.GetList(context.Background(), "2") if err == nil { t.Fatalf("should be fail: %v", err) } - list, err = client.GetList(context.Background(), "1") + list, err := client.GetList(context.Background(), "1") if err != nil { t.Fatalf("should not be fail: %v", err) } @@ -154,11 +154,11 @@ func TestCreateList(t *testing.T) { ClientSecret: "bar", AccessToken: "zoo", }) - list, err := client.CreateList(context.Background(), "") + _, err := client.CreateList(context.Background(), "") if err == nil { t.Fatalf("should be fail: %v", err) } - list, err = client.CreateList(context.Background(), "foo") + list, err := client.CreateList(context.Background(), "foo") if err != nil { t.Fatalf("should not be fail: %v", err) } @@ -187,11 +187,11 @@ func TestRenameList(t *testing.T) { ClientSecret: "bar", AccessToken: "zoo", }) - list, err := client.RenameList(context.Background(), "2", "bar") + _, err := client.RenameList(context.Background(), "2", "bar") if err == nil { t.Fatalf("should be fail: %v", err) } - list, err = client.RenameList(context.Background(), "1", "bar") + list, err := client.RenameList(context.Background(), "1", "bar") if err != nil { t.Fatalf("should not be fail: %v", err) } diff --git a/report_test.go b/report_test.go index 374f490..f25f0b5 100644 --- a/report_test.go +++ b/report_test.go @@ -63,11 +63,11 @@ func TestReport(t *testing.T) { ClientSecret: "bar", AccessToken: "zoo", }) - rp, err := client.Report(context.Background(), "121", nil, "") + _, err := client.Report(context.Background(), "121", nil, "") if err == nil { t.Fatalf("should be fail: %v", err) } - rp, err = client.Report(context.Background(), "122", nil, "") + rp, err := client.Report(context.Background(), "122", nil, "") if err != nil { t.Fatalf("should not be fail: %v", err) } From 5f0c9a21c2b068961ba897a628adb5897eec01d1 Mon Sep 17 00:00:00 2001 From: Rasmus Lindroth Date: Wed, 16 Nov 2022 20:20:18 +0100 Subject: [PATCH 2/2] add support for language --- mastodon.go | 1 + mastodon_test.go | 7 +++++++ status.go | 3 +++ 3 files changed, 11 insertions(+) diff --git a/mastodon.go b/mastodon.go index 0706981..c704e10 100644 --- a/mastodon.go +++ b/mastodon.go @@ -230,6 +230,7 @@ type Toot struct { Sensitive bool `json:"sensitive"` SpoilerText string `json:"spoiler_text"` Visibility string `json:"visibility"` + Language string `json:"language"` ScheduledAt *time.Time `json:"scheduled_at,omitempty"` Poll *TootPoll `json:"poll"` } diff --git a/mastodon_test.go b/mastodon_test.go index ff3fc5c..0ef9d07 100644 --- a/mastodon_test.go +++ b/mastodon_test.go @@ -252,6 +252,9 @@ func TestPostStatusParams(t *testing.T) { if r.FormValue("visibility") != "" { s.Visibility = (r.FormValue("visibility")) } + if r.FormValue("language") != "" { + s.Language = (r.FormValue("language")) + } if r.FormValue("sensitive") == "true" { s.Sensitive = true s.SpoilerText = fmt.Sprintf("

%s

", r.FormValue("spoiler_text")) @@ -288,6 +291,7 @@ func TestPostStatusParams(t *testing.T) { Status: "foobar", InReplyToID: ID("2"), Visibility: "unlisted", + Language: "sv", Sensitive: true, SpoilerText: "bar", MediaIDs: []ID{"1", "2"}, @@ -310,6 +314,9 @@ func TestPostStatusParams(t *testing.T) { if s.Visibility != "unlisted" { t.Fatalf("want %q but %q", "unlisted", s.Visibility) } + if s.Language != "sv" { + t.Fatalf("want %q but %q", "sv", s.Language) + } if s.Sensitive != true { t.Fatalf("want %t but %t", true, s.Sensitive) } diff --git a/status.go b/status.go index e616366..f5cc451 100644 --- a/status.go +++ b/status.go @@ -365,6 +365,9 @@ func (c *Client) PostStatus(ctx context.Context, toot *Toot) (*Status, error) { if toot.Visibility != "" { params.Set("visibility", fmt.Sprint(toot.Visibility)) } + if toot.Language != "" { + params.Set("language", fmt.Sprint(toot.Language)) + } if toot.Sensitive { params.Set("sensitive", "true") }