Fix GetTimelineHashtag

This commit is contained in:
178inaba 2017-04-28 02:29:11 +09:00
parent b8fe5a0533
commit a4904109e4
2 changed files with 9 additions and 4 deletions

View File

@ -173,9 +173,14 @@ func (c *Client) GetTimelinePublic(ctx context.Context, isLocal bool) ([]*Status
}
// GetTimelineHashtag return statuses from tagged timeline.
func (c *Client) GetTimelineHashtag(ctx context.Context, tag string) ([]*Status, error) {
func (c *Client) GetTimelineHashtag(ctx context.Context, tag string, isLocal bool) ([]*Status, error) {
params := url.Values{}
if isLocal {
params.Set("local", "t")
}
var statuses []*Status
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/timelines/tag/%s", (&url.URL{Path: tag}).EscapedPath()), nil, &statuses, nil)
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/timelines/tag/%s", url.PathEscape(tag)), params, &statuses, nil)
if err != nil {
return nil, err
}

View File

@ -374,11 +374,11 @@ func TestGetTimelineHashtag(t *testing.T) {
ClientSecret: "bar",
AccessToken: "zoo",
})
_, err := client.GetTimelineHashtag(context.Background(), "notfound")
_, err := client.GetTimelineHashtag(context.Background(), "notfound", false)
if err == nil {
t.Fatalf("should be fail: %v", err)
}
tags, err := client.GetTimelineHashtag(context.Background(), "zzz")
tags, err := client.GetTimelineHashtag(context.Background(), "zzz", true)
if err != nil {
t.Fatalf("should not be fail: %v", err)
}