fix IDs
parent
e0cf1e0650
commit
aef736e991
|
@ -2,7 +2,6 @@ package mastodon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
)
|
)
|
||||||
|
@ -24,11 +23,11 @@ func (c *Client) GetReports(ctx context.Context) ([]*Report, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report reports the report
|
// Report reports the report
|
||||||
func (c *Client) Report(ctx context.Context, accountID int64, ids []int64, comment string) (*Report, error) {
|
func (c *Client) Report(ctx context.Context, accountID ID, ids []ID, comment string) (*Report, error) {
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
params.Set("account_id", fmt.Sprint(accountID))
|
params.Set("account_id", string(accountID))
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
params.Add("status_ids[]", fmt.Sprint(id))
|
params.Add("status_ids[]", string(id))
|
||||||
}
|
}
|
||||||
params.Set("comment", comment)
|
params.Set("comment", comment)
|
||||||
var report Report
|
var report Report
|
||||||
|
|
|
@ -65,26 +65,26 @@ func TestReport(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
rp, err := client.Report(context.Background(), 121, nil, "")
|
rp, err := client.Report(context.Background(), "121", nil, "")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
if rp.ID != 1234 {
|
if rp.ID != 1234 {
|
||||||
t.Fatalf("want %v but %v", 1234, rp.ID)
|
t.Fatalf("want %q but %q", "1234", rp.ID)
|
||||||
}
|
}
|
||||||
if rp.ActionTaken {
|
if rp.ActionTaken {
|
||||||
t.Fatalf("want %v but %v", true, rp.ActionTaken)
|
t.Fatalf("want %v but %v", true, rp.ActionTaken)
|
||||||
}
|
}
|
||||||
rp, err = client.Report(context.Background(), 123, []int64{567}, "")
|
rp, err = client.Report(context.Background(), "123", []ID{"567"}, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
if rp.ID != 1234 {
|
if rp.ID != 1234 {
|
||||||
t.Fatalf("want %v but %v", 1234, rp.ID)
|
t.Fatalf("want %q but %q", "1234", rp.ID)
|
||||||
}
|
}
|
||||||
if !rp.ActionTaken {
|
if !rp.ActionTaken {
|
||||||
t.Fatalf("want %v but %v", false, rp.ActionTaken)
|
t.Fatalf("want %v but %v", false, rp.ActionTaken)
|
||||||
|
|
40
status.go
40
status.go
|
@ -57,9 +57,9 @@ func (c *Client) GetFavourites(ctx context.Context, pg *Pagination) ([]*Status,
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStatus return status specified by id.
|
// GetStatus return status specified by id.
|
||||||
func (c *Client) GetStatus(ctx context.Context, id int64) (*Status, error) {
|
func (c *Client) GetStatus(ctx context.Context, id ID) (*Status, error) {
|
||||||
var status Status
|
var status Status
|
||||||
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%d", id), nil, &status, nil)
|
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%s", id), nil, &status, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -67,9 +67,9 @@ func (c *Client) GetStatus(ctx context.Context, id int64) (*Status, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStatusContext return status specified by id.
|
// GetStatusContext return status specified by id.
|
||||||
func (c *Client) GetStatusContext(ctx context.Context, id int64) (*Context, error) {
|
func (c *Client) GetStatusContext(ctx context.Context, id ID) (*Context, error) {
|
||||||
var context Context
|
var context Context
|
||||||
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%d/context", id), nil, &context, nil)
|
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%s/context", id), nil, &context, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -77,9 +77,9 @@ func (c *Client) GetStatusContext(ctx context.Context, id int64) (*Context, erro
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStatusCard return status specified by id.
|
// GetStatusCard return status specified by id.
|
||||||
func (c *Client) GetStatusCard(ctx context.Context, id int64) (*Card, error) {
|
func (c *Client) GetStatusCard(ctx context.Context, id ID) (*Card, error) {
|
||||||
var card Card
|
var card Card
|
||||||
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%d/card", id), nil, &card, nil)
|
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%s/card", id), nil, &card, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -87,9 +87,9 @@ func (c *Client) GetStatusCard(ctx context.Context, id int64) (*Card, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRebloggedBy returns the account list of the user who reblogged the toot of id.
|
// GetRebloggedBy returns the account list of the user who reblogged the toot of id.
|
||||||
func (c *Client) GetRebloggedBy(ctx context.Context, id int64, pg *Pagination) ([]*Account, error) {
|
func (c *Client) GetRebloggedBy(ctx context.Context, id ID, pg *Pagination) ([]*Account, error) {
|
||||||
var accounts []*Account
|
var accounts []*Account
|
||||||
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%d/reblogged_by", id), nil, &accounts, pg)
|
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%s/reblogged_by", id), nil, &accounts, pg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -97,9 +97,9 @@ func (c *Client) GetRebloggedBy(ctx context.Context, id int64, pg *Pagination) (
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFavouritedBy returns the account list of the user who liked the toot of id.
|
// GetFavouritedBy returns the account list of the user who liked the toot of id.
|
||||||
func (c *Client) GetFavouritedBy(ctx context.Context, id int64, pg *Pagination) ([]*Account, error) {
|
func (c *Client) GetFavouritedBy(ctx context.Context, id ID, pg *Pagination) ([]*Account, error) {
|
||||||
var accounts []*Account
|
var accounts []*Account
|
||||||
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%d/favourited_by", id), nil, &accounts, pg)
|
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/statuses/%s/favourited_by", id), nil, &accounts, pg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -107,9 +107,9 @@ func (c *Client) GetFavouritedBy(ctx context.Context, id int64, pg *Pagination)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reblog is reblog the toot of id and return status of reblog.
|
// Reblog is reblog the toot of id and return status of reblog.
|
||||||
func (c *Client) Reblog(ctx context.Context, id int64) (*Status, error) {
|
func (c *Client) Reblog(ctx context.Context, id ID) (*Status, error) {
|
||||||
var status Status
|
var status Status
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%d/reblog", id), nil, &status, nil)
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/reblog", id), nil, &status, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -117,9 +117,9 @@ func (c *Client) Reblog(ctx context.Context, id int64) (*Status, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unreblog is unreblog the toot of id and return status of the original toot.
|
// Unreblog is unreblog the toot of id and return status of the original toot.
|
||||||
func (c *Client) Unreblog(ctx context.Context, id int64) (*Status, error) {
|
func (c *Client) Unreblog(ctx context.Context, id ID) (*Status, error) {
|
||||||
var status Status
|
var status Status
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%d/unreblog", id), nil, &status, nil)
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/unreblog", id), nil, &status, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -127,9 +127,9 @@ func (c *Client) Unreblog(ctx context.Context, id int64) (*Status, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Favourite is favourite the toot of id and return status of the favourite toot.
|
// Favourite is favourite the toot of id and return status of the favourite toot.
|
||||||
func (c *Client) Favourite(ctx context.Context, id int64) (*Status, error) {
|
func (c *Client) Favourite(ctx context.Context, id ID) (*Status, error) {
|
||||||
var status Status
|
var status Status
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%d/favourite", id), nil, &status, nil)
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/favourite", id), nil, &status, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -137,9 +137,9 @@ func (c *Client) Favourite(ctx context.Context, id int64) (*Status, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unfavourite is unfavourite the toot of id and return status of the unfavourite toot.
|
// Unfavourite is unfavourite the toot of id and return status of the unfavourite toot.
|
||||||
func (c *Client) Unfavourite(ctx context.Context, id int64) (*Status, error) {
|
func (c *Client) Unfavourite(ctx context.Context, id ID) (*Status, error) {
|
||||||
var status Status
|
var status Status
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%d/unfavourite", id), nil, &status, nil)
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/statuses/%s/unfavourite", id), nil, &status, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -234,8 +234,8 @@ func (c *Client) PostStatus(ctx context.Context, toot *Toot) (*Status, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteStatus delete the toot.
|
// DeleteStatus delete the toot.
|
||||||
func (c *Client) DeleteStatus(ctx context.Context, id int64) error {
|
func (c *Client) DeleteStatus(ctx context.Context, id ID) error {
|
||||||
return c.doAPI(ctx, http.MethodDelete, fmt.Sprintf("/api/v1/statuses/%d", id), nil, nil, nil)
|
return c.doAPI(ctx, http.MethodDelete, fmt.Sprintf("/api/v1/statuses/%s", id), nil, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search search content with query.
|
// Search search content with query.
|
||||||
|
|
|
@ -53,11 +53,11 @@ func TestGetStatus(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.GetStatus(context.Background(), 123)
|
_, err := client.GetStatus(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
status, err := client.GetStatus(context.Background(), 1234567)
|
status, err := client.GetStatus(context.Background(), "1234567")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -83,11 +83,11 @@ func TestGetStatusCard(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.GetStatusCard(context.Background(), 123)
|
_, err := client.GetStatusCard(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
card, err := client.GetStatusCard(context.Background(), 1234567)
|
card, err := client.GetStatusCard(context.Background(), "1234567")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -113,11 +113,11 @@ func TestGetStatusContext(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.GetStatusContext(context.Background(), 123)
|
_, err := client.GetStatusContext(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
context, err := client.GetStatusContext(context.Background(), 1234567)
|
context, err := client.GetStatusContext(context.Background(), "1234567")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -152,11 +152,11 @@ func TestGetRebloggedBy(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.GetRebloggedBy(context.Background(), 123, nil)
|
_, err := client.GetRebloggedBy(context.Background(), "123", nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
rbs, err := client.GetRebloggedBy(context.Background(), 1234567, nil)
|
rbs, err := client.GetRebloggedBy(context.Background(), "1234567", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -188,11 +188,11 @@ func TestGetFavouritedBy(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.GetFavouritedBy(context.Background(), 123, nil)
|
_, err := client.GetFavouritedBy(context.Background(), "123", nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
fbs, err := client.GetFavouritedBy(context.Background(), 1234567, nil)
|
fbs, err := client.GetFavouritedBy(context.Background(), "1234567", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -224,11 +224,11 @@ func TestReblog(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.Reblog(context.Background(), 123)
|
_, err := client.Reblog(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
status, err := client.Reblog(context.Background(), 1234567)
|
status, err := client.Reblog(context.Background(), "1234567")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -254,11 +254,11 @@ func TestUnreblog(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.Unreblog(context.Background(), 123)
|
_, err := client.Unreblog(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
status, err := client.Unreblog(context.Background(), 1234567)
|
status, err := client.Unreblog(context.Background(), "1234567")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -284,11 +284,11 @@ func TestFavourite(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.Favourite(context.Background(), 123)
|
_, err := client.Favourite(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
status, err := client.Favourite(context.Background(), 1234567)
|
status, err := client.Favourite(context.Background(), "1234567")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -314,11 +314,11 @@ func TestUnfavourite(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.Unfavourite(context.Background(), 123)
|
_, err := client.Unfavourite(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
status, err := client.Unfavourite(context.Background(), 1234567)
|
status, err := client.Unfavourite(context.Background(), "1234567")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -449,11 +449,11 @@ func TestDeleteStatus(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
err := client.DeleteStatus(context.Background(), 123)
|
err := client.DeleteStatus(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
err = client.DeleteStatus(context.Background(), 1234567)
|
err = client.DeleteStatus(context.Background(), "1234567")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -27,7 +28,7 @@ type NotificationEvent struct {
|
||||||
func (e *NotificationEvent) event() {}
|
func (e *NotificationEvent) event() {}
|
||||||
|
|
||||||
// DeleteEvent is struct for passing deletion event to app.
|
// DeleteEvent is struct for passing deletion event to app.
|
||||||
type DeleteEvent struct{ ID int64 }
|
type DeleteEvent struct{ ID ID }
|
||||||
|
|
||||||
func (e *DeleteEvent) event() {}
|
func (e *DeleteEvent) event() {}
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ func handleReader(q chan Event, r io.Reader) error {
|
||||||
var id int64
|
var id int64
|
||||||
id, err = strconv.ParseInt(strings.TrimSpace(token[1]), 10, 64)
|
id, err = strconv.ParseInt(strings.TrimSpace(token[1]), 10, 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
q <- &DeleteEvent{id}
|
q <- &DeleteEvent{ID(fmt.Sprintf("%20d", id))}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -45,8 +45,8 @@ data: 1234567
|
||||||
}
|
}
|
||||||
case *DeleteEvent:
|
case *DeleteEvent:
|
||||||
passDelete = true
|
passDelete = true
|
||||||
if event.ID != 1234567 {
|
if event.ID != "1234567" {
|
||||||
t.Fatalf("want %d but %d", 1234567, event.ID)
|
t.Fatalf("want %q but %q", "1234567", event.ID)
|
||||||
}
|
}
|
||||||
case *ErrorEvent:
|
case *ErrorEvent:
|
||||||
passError = true
|
passError = true
|
||||||
|
|
|
@ -3,6 +3,7 @@ package mastodon
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ func (c *WSClient) handleWS(ctx context.Context, rawurl string, q chan Event) er
|
||||||
q <- &NotificationEvent{Notification: ¬ification}
|
q <- &NotificationEvent{Notification: ¬ification}
|
||||||
}
|
}
|
||||||
case "delete":
|
case "delete":
|
||||||
q <- &DeleteEvent{ID: int64(s.Payload.(float64))}
|
q <- &DeleteEvent{ID: ID(fmt.Sprint(int64(s.Payload.(float64))))}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
q <- &ErrorEvent{err}
|
q <- &ErrorEvent{err}
|
||||||
|
|
|
@ -118,10 +118,10 @@ func wsTest(t *testing.T, q chan Event, cancel func()) {
|
||||||
t.Fatalf("want %q but %q", "foo", events[0].(*UpdateEvent).Status.Content)
|
t.Fatalf("want %q but %q", "foo", events[0].(*UpdateEvent).Status.Content)
|
||||||
}
|
}
|
||||||
if events[1].(*NotificationEvent).Notification.ID != "123" {
|
if events[1].(*NotificationEvent).Notification.ID != "123" {
|
||||||
t.Fatalf("want %d but %d", 123, events[1].(*NotificationEvent).Notification.ID)
|
t.Fatalf("want %q but %q", "123", events[1].(*NotificationEvent).Notification.ID)
|
||||||
}
|
}
|
||||||
if events[2].(*DeleteEvent).ID != 1234567 {
|
if events[2].(*DeleteEvent).ID != "1234567" {
|
||||||
t.Fatalf("want %d but %d", 1234567, events[2].(*DeleteEvent).ID)
|
t.Fatalf("want %q but %q", "1234567", events[2].(*DeleteEvent).ID)
|
||||||
}
|
}
|
||||||
if errorEvent, ok := events[3].(*ErrorEvent); !ok {
|
if errorEvent, ok := events[3].(*ErrorEvent); !ok {
|
||||||
t.Fatalf("should be fail: %v", errorEvent.err)
|
t.Fatalf("should be fail: %v", errorEvent.err)
|
||||||
|
|
Loading…
Reference in New Issue