add support for language

This commit is contained in:
Rasmus Lindroth 2022-11-16 20:20:18 +01:00 committed by mattn
parent be61205708
commit 5f0c9a21c2
3 changed files with 11 additions and 0 deletions

View File

@ -230,6 +230,7 @@ type Toot struct {
Sensitive bool `json:"sensitive"` Sensitive bool `json:"sensitive"`
SpoilerText string `json:"spoiler_text"` SpoilerText string `json:"spoiler_text"`
Visibility string `json:"visibility"` Visibility string `json:"visibility"`
Language string `json:"language"`
ScheduledAt *time.Time `json:"scheduled_at,omitempty"` ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
Poll *TootPoll `json:"poll"` Poll *TootPoll `json:"poll"`
} }

View File

@ -252,6 +252,9 @@ func TestPostStatusParams(t *testing.T) {
if r.FormValue("visibility") != "" { if r.FormValue("visibility") != "" {
s.Visibility = (r.FormValue("visibility")) s.Visibility = (r.FormValue("visibility"))
} }
if r.FormValue("language") != "" {
s.Language = (r.FormValue("language"))
}
if r.FormValue("sensitive") == "true" { if r.FormValue("sensitive") == "true" {
s.Sensitive = true s.Sensitive = true
s.SpoilerText = fmt.Sprintf("<p>%s</p>", r.FormValue("spoiler_text")) s.SpoilerText = fmt.Sprintf("<p>%s</p>", r.FormValue("spoiler_text"))
@ -288,6 +291,7 @@ func TestPostStatusParams(t *testing.T) {
Status: "foobar", Status: "foobar",
InReplyToID: ID("2"), InReplyToID: ID("2"),
Visibility: "unlisted", Visibility: "unlisted",
Language: "sv",
Sensitive: true, Sensitive: true,
SpoilerText: "bar", SpoilerText: "bar",
MediaIDs: []ID{"1", "2"}, MediaIDs: []ID{"1", "2"},
@ -310,6 +314,9 @@ func TestPostStatusParams(t *testing.T) {
if s.Visibility != "unlisted" { if s.Visibility != "unlisted" {
t.Fatalf("want %q but %q", "unlisted", s.Visibility) 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 { if s.Sensitive != true {
t.Fatalf("want %t but %t", true, s.Sensitive) t.Fatalf("want %t but %t", true, s.Sensitive)
} }

View File

@ -365,6 +365,9 @@ func (c *Client) PostStatus(ctx context.Context, toot *Toot) (*Status, error) {
if toot.Visibility != "" { if toot.Visibility != "" {
params.Set("visibility", fmt.Sprint(toot.Visibility)) params.Set("visibility", fmt.Sprint(toot.Visibility))
} }
if toot.Language != "" {
params.Set("language", fmt.Sprint(toot.Language))
}
if toot.Sensitive { if toot.Sensitive {
params.Set("sensitive", "true") params.Set("sensitive", "true")
} }