Fix type of IDs.
In Mastodon 2.0 API specification, IDs are typed as string.
This commit is contained in:
parent
98d1ab17f1
commit
3274f13917
66
accounts.go
66
accounts.go
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
// Account hold information for mastodon account.
|
// Account hold information for mastodon account.
|
||||||
type Account struct {
|
type Account struct {
|
||||||
ID int64 `json:"id"`
|
ID ID `json:"id"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Acct string `json:"acct"`
|
Acct string `json:"acct"`
|
||||||
DisplayName string `json:"display_name"`
|
DisplayName string `json:"display_name"`
|
||||||
|
@ -28,9 +28,9 @@ type Account struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAccount return Account.
|
// GetAccount return Account.
|
||||||
func (c *Client) GetAccount(ctx context.Context, id int) (*Account, error) {
|
func (c *Client) GetAccount(ctx context.Context, id ID) (*Account, error) {
|
||||||
var account Account
|
var account Account
|
||||||
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/accounts/%d", id), nil, &account, nil)
|
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/accounts/%s", url.PathEscape(string(id))), nil, &account, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,9 @@ func (c *Client) AccountUpdate(ctx context.Context, profile *Profile) (*Account,
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAccountStatuses return statuses by specified accuont.
|
// GetAccountStatuses return statuses by specified accuont.
|
||||||
func (c *Client) GetAccountStatuses(ctx context.Context, id int64, pg *Pagination) ([]*Status, error) {
|
func (c *Client) GetAccountStatuses(ctx context.Context, id ID, pg *Pagination) ([]*Status, error) {
|
||||||
var statuses []*Status
|
var statuses []*Status
|
||||||
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/accounts/%d/statuses", id), nil, &statuses, pg)
|
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/accounts/%s/statuses", url.PathEscape(string(id))), nil, &statuses, pg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -94,9 +94,9 @@ func (c *Client) GetAccountStatuses(ctx context.Context, id int64, pg *Paginatio
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAccountFollowers return followers list.
|
// GetAccountFollowers return followers list.
|
||||||
func (c *Client) GetAccountFollowers(ctx context.Context, id int64, pg *Pagination) ([]*Account, error) {
|
func (c *Client) GetAccountFollowers(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/accounts/%d/followers", id), nil, &accounts, pg)
|
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/accounts/%s/followers", url.PathEscape(string(id))), nil, &accounts, pg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -104,9 +104,9 @@ func (c *Client) GetAccountFollowers(ctx context.Context, id int64, pg *Paginati
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAccountFollowing return following list.
|
// GetAccountFollowing return following list.
|
||||||
func (c *Client) GetAccountFollowing(ctx context.Context, id int64, pg *Pagination) ([]*Account, error) {
|
func (c *Client) GetAccountFollowing(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/accounts/%d/following", id), nil, &accounts, pg)
|
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/accounts/%s/following", url.PathEscape(string(id))), nil, &accounts, pg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -125,18 +125,18 @@ func (c *Client) GetBlocks(ctx context.Context, pg *Pagination) ([]*Account, err
|
||||||
|
|
||||||
// Relationship hold information for relation-ship to the account.
|
// Relationship hold information for relation-ship to the account.
|
||||||
type Relationship struct {
|
type Relationship struct {
|
||||||
ID int64 `json:"id"`
|
ID ID `json:"id"`
|
||||||
Following bool `json:"following"`
|
Following bool `json:"following"`
|
||||||
FollowedBy bool `json:"followed_by"`
|
FollowedBy bool `json:"followed_by"`
|
||||||
Blocking bool `json:"blocking"`
|
Blocking bool `json:"blocking"`
|
||||||
Muting bool `json:"muting"`
|
Muting bool `json:"muting"`
|
||||||
Requested bool `json:"requested"`
|
Requested bool `json:"requested"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountFollow follow the account.
|
// AccountFollow follow the account.
|
||||||
func (c *Client) AccountFollow(ctx context.Context, id int64) (*Relationship, error) {
|
func (c *Client) AccountFollow(ctx context.Context, id ID) (*Relationship, error) {
|
||||||
var relationship Relationship
|
var relationship Relationship
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/follow", id), nil, &relationship, nil)
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%s/follow", url.PathEscape(string(id))), nil, &relationship, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -144,9 +144,9 @@ func (c *Client) AccountFollow(ctx context.Context, id int64) (*Relationship, er
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountUnfollow unfollow the account.
|
// AccountUnfollow unfollow the account.
|
||||||
func (c *Client) AccountUnfollow(ctx context.Context, id int64) (*Relationship, error) {
|
func (c *Client) AccountUnfollow(ctx context.Context, id ID) (*Relationship, error) {
|
||||||
var relationship Relationship
|
var relationship Relationship
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/unfollow", id), nil, &relationship, nil)
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%s/unfollow", url.PathEscape(string(id))), nil, &relationship, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -154,9 +154,9 @@ func (c *Client) AccountUnfollow(ctx context.Context, id int64) (*Relationship,
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountBlock block the account.
|
// AccountBlock block the account.
|
||||||
func (c *Client) AccountBlock(ctx context.Context, id int64) (*Relationship, error) {
|
func (c *Client) AccountBlock(ctx context.Context, id ID) (*Relationship, error) {
|
||||||
var relationship Relationship
|
var relationship Relationship
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/block", id), nil, &relationship, nil)
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%s/block", url.PathEscape(string(id))), nil, &relationship, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -164,9 +164,9 @@ func (c *Client) AccountBlock(ctx context.Context, id int64) (*Relationship, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountUnblock unblock the account.
|
// AccountUnblock unblock the account.
|
||||||
func (c *Client) AccountUnblock(ctx context.Context, id int64) (*Relationship, error) {
|
func (c *Client) AccountUnblock(ctx context.Context, id ID) (*Relationship, error) {
|
||||||
var relationship Relationship
|
var relationship Relationship
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/unblock", id), nil, &relationship, nil)
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%s/unblock", url.PathEscape(string(id))), nil, &relationship, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -174,9 +174,9 @@ func (c *Client) AccountUnblock(ctx context.Context, id int64) (*Relationship, e
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountMute mute the account.
|
// AccountMute mute the account.
|
||||||
func (c *Client) AccountMute(ctx context.Context, id int64) (*Relationship, error) {
|
func (c *Client) AccountMute(ctx context.Context, id ID) (*Relationship, error) {
|
||||||
var relationship Relationship
|
var relationship Relationship
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/mute", id), nil, &relationship, nil)
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%s/mute", url.PathEscape(string(id))), nil, &relationship, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -184,9 +184,9 @@ func (c *Client) AccountMute(ctx context.Context, id int64) (*Relationship, erro
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountUnmute unmute the account.
|
// AccountUnmute unmute the account.
|
||||||
func (c *Client) AccountUnmute(ctx context.Context, id int64) (*Relationship, error) {
|
func (c *Client) AccountUnmute(ctx context.Context, id ID) (*Relationship, error) {
|
||||||
var relationship Relationship
|
var relationship Relationship
|
||||||
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/unmute", id), nil, &relationship, nil)
|
err := c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/accounts/%s/unmute", url.PathEscape(string(id))), nil, &relationship, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -194,10 +194,10 @@ func (c *Client) AccountUnmute(ctx context.Context, id int64) (*Relationship, er
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAccountRelationships return relationship for the account.
|
// GetAccountRelationships return relationship for the account.
|
||||||
func (c *Client) GetAccountRelationships(ctx context.Context, ids []int64) ([]*Relationship, error) {
|
func (c *Client) GetAccountRelationships(ctx context.Context, ids []string) ([]*Relationship, error) {
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
params.Add("id[]", fmt.Sprint(id))
|
params.Add("id[]", id)
|
||||||
}
|
}
|
||||||
|
|
||||||
var relationships []*Relationship
|
var relationships []*Relationship
|
||||||
|
@ -246,13 +246,13 @@ func (c *Client) GetFollowRequests(ctx context.Context, pg *Pagination) ([]*Acco
|
||||||
}
|
}
|
||||||
|
|
||||||
// FollowRequestAuthorize is authorize the follow request of user with id.
|
// FollowRequestAuthorize is authorize the follow request of user with id.
|
||||||
func (c *Client) FollowRequestAuthorize(ctx context.Context, id int64) error {
|
func (c *Client) FollowRequestAuthorize(ctx context.Context, id ID) error {
|
||||||
return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/follow_requests/%d/authorize", id), nil, nil, nil)
|
return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/follow_requests/%s/authorize", url.PathEscape(string(id))), nil, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FollowRequestReject is rejects the follow request of user with id.
|
// FollowRequestReject is rejects the follow request of user with id.
|
||||||
func (c *Client) FollowRequestReject(ctx context.Context, id int64) error {
|
func (c *Client) FollowRequestReject(ctx context.Context, id ID) error {
|
||||||
return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/follow_requests/%d/reject", id), nil, nil, nil)
|
return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/follow_requests/%s/reject", url.PathEscape(string(id))), nil, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMutes returns the list of users muted by the current user.
|
// GetMutes returns the list of users muted by the current user.
|
||||||
|
|
|
@ -25,11 +25,11 @@ func TestGetAccount(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.GetAccount(context.Background(), 1)
|
_, err := client.GetAccount(context.Background(), "1")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
a, err := client.GetAccount(context.Background(), 1234567)
|
a, err := client.GetAccount(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)
|
||||||
}
|
}
|
||||||
|
@ -124,11 +124,11 @@ func TestGetAccountStatuses(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.GetAccountStatuses(context.Background(), 123, nil)
|
_, err := client.GetAccountStatuses(context.Background(), "123", nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
ss, err := client.GetAccountStatuses(context.Background(), 1234567, nil)
|
ss, err := client.GetAccountStatuses(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)
|
||||||
}
|
}
|
||||||
|
@ -157,11 +157,11 @@ func TestGetAccountFollowers(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.GetAccountFollowers(context.Background(), 123, nil)
|
_, err := client.GetAccountFollowers(context.Background(), "123", nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
fl, err := client.GetAccountFollowers(context.Background(), 1234567, nil)
|
fl, err := client.GetAccountFollowers(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)
|
||||||
}
|
}
|
||||||
|
@ -193,11 +193,11 @@ func TestGetAccountFollowing(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.GetAccountFollowing(context.Background(), 123, nil)
|
_, err := client.GetAccountFollowing(context.Background(), "123", nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
fl, err := client.GetAccountFollowing(context.Background(), 1234567, nil)
|
fl, err := client.GetAccountFollowing(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)
|
||||||
}
|
}
|
||||||
|
@ -267,16 +267,16 @@ func TestAccountFollow(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
rel, err := client.AccountFollow(context.Background(), 123)
|
rel, err := client.AccountFollow(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
rel, err = client.AccountFollow(context.Background(), 1234567)
|
rel, err = client.AccountFollow(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)
|
||||||
}
|
}
|
||||||
if rel.ID != 1234567 {
|
if rel.ID != "1234567" {
|
||||||
t.Fatalf("want %d but %d", 1234567, rel.ID)
|
t.Fatalf("want %q but %q", "1234567", rel.ID)
|
||||||
}
|
}
|
||||||
if !rel.Following {
|
if !rel.Following {
|
||||||
t.Fatalf("want %t but %t", true, rel.Following)
|
t.Fatalf("want %t but %t", true, rel.Following)
|
||||||
|
@ -300,16 +300,16 @@ func TestAccountUnfollow(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
rel, err := client.AccountUnfollow(context.Background(), 123)
|
rel, err := client.AccountUnfollow(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
rel, err = client.AccountUnfollow(context.Background(), 1234567)
|
rel, err = client.AccountUnfollow(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)
|
||||||
}
|
}
|
||||||
if rel.ID != 1234567 {
|
if rel.ID != "1234567" {
|
||||||
t.Fatalf("want %d but %d", 1234567, rel.ID)
|
t.Fatalf("want %q but %q", "1234567", rel.ID)
|
||||||
}
|
}
|
||||||
if rel.Following {
|
if rel.Following {
|
||||||
t.Fatalf("want %t but %t", false, rel.Following)
|
t.Fatalf("want %t but %t", false, rel.Following)
|
||||||
|
@ -333,16 +333,16 @@ func TestAccountBlock(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.AccountBlock(context.Background(), 123)
|
_, err := client.AccountBlock(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
rel, err := client.AccountBlock(context.Background(), 1234567)
|
rel, err := client.AccountBlock(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)
|
||||||
}
|
}
|
||||||
if rel.ID != 1234567 {
|
if rel.ID != "1234567" {
|
||||||
t.Fatalf("want %d but %d", 1234567, rel.ID)
|
t.Fatalf("want %q but %q", "1234567", rel.ID)
|
||||||
}
|
}
|
||||||
if !rel.Blocking {
|
if !rel.Blocking {
|
||||||
t.Fatalf("want %t but %t", true, rel.Blocking)
|
t.Fatalf("want %t but %t", true, rel.Blocking)
|
||||||
|
@ -366,16 +366,16 @@ func TestAccountUnblock(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.AccountUnblock(context.Background(), 123)
|
_, err := client.AccountUnblock(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
rel, err := client.AccountUnblock(context.Background(), 1234567)
|
rel, err := client.AccountUnblock(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)
|
||||||
}
|
}
|
||||||
if rel.ID != 1234567 {
|
if rel.ID != "1234567" {
|
||||||
t.Fatalf("want %d but %d", 1234567, rel.ID)
|
t.Fatalf("want %q but %q", "1234567", rel.ID)
|
||||||
}
|
}
|
||||||
if rel.Blocking {
|
if rel.Blocking {
|
||||||
t.Fatalf("want %t but %t", false, rel.Blocking)
|
t.Fatalf("want %t but %t", false, rel.Blocking)
|
||||||
|
@ -399,16 +399,16 @@ func TestAccountMute(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.AccountMute(context.Background(), 123)
|
_, err := client.AccountMute(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
rel, err := client.AccountMute(context.Background(), 1234567)
|
rel, err := client.AccountMute(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)
|
||||||
}
|
}
|
||||||
if rel.ID != 1234567 {
|
if rel.ID != "1234567" {
|
||||||
t.Fatalf("want %d but %d", 1234567, rel.ID)
|
t.Fatalf("want %q but %q", "1234567", rel.ID)
|
||||||
}
|
}
|
||||||
if !rel.Muting {
|
if !rel.Muting {
|
||||||
t.Fatalf("want %t but %t", true, rel.Muting)
|
t.Fatalf("want %t but %t", true, rel.Muting)
|
||||||
|
@ -432,16 +432,16 @@ func TestAccountUnmute(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.AccountUnmute(context.Background(), 123)
|
_, err := client.AccountUnmute(context.Background(), "123")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
rel, err := client.AccountUnmute(context.Background(), 1234567)
|
rel, err := client.AccountUnmute(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)
|
||||||
}
|
}
|
||||||
if rel.ID != 1234567 {
|
if rel.ID != "1234567" {
|
||||||
t.Fatalf("want %d but %d", 1234567, rel.ID)
|
t.Fatalf("want %q but %q", "1234567", rel.ID)
|
||||||
}
|
}
|
||||||
if rel.Muting {
|
if rel.Muting {
|
||||||
t.Fatalf("want %t but %t", false, rel.Muting)
|
t.Fatalf("want %t but %t", false, rel.Muting)
|
||||||
|
@ -465,19 +465,19 @@ func TestGetAccountRelationship(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
_, err := client.GetAccountRelationships(context.Background(), []int64{123, 456})
|
_, err := client.GetAccountRelationships(context.Background(), []string{"123", "456"})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("should be fail: %v", err)
|
t.Fatalf("should be fail: %v", err)
|
||||||
}
|
}
|
||||||
rels, err := client.GetAccountRelationships(context.Background(), []int64{1234567, 8901234})
|
rels, err := client.GetAccountRelationships(context.Background(), []string{"1234567", "8901234"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("should not be fail: %v", err)
|
t.Fatalf("should not be fail: %v", err)
|
||||||
}
|
}
|
||||||
if rels[0].ID != 1234567 {
|
if rels[0].ID != "1234567" {
|
||||||
t.Fatalf("want %d but %d", 1234567, rels[0].ID)
|
t.Fatalf("want %q but %q", "1234567", rels[0].ID)
|
||||||
}
|
}
|
||||||
if rels[1].ID != 8901234 {
|
if rels[1].ID != "8901234" {
|
||||||
t.Fatalf("want %d but %d", 8901234, rels[1].ID)
|
t.Fatalf("want %q but %q", "8901234", rels[1].ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,11 +599,11 @@ func TestFollowRequestAuthorize(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
err := client.FollowRequestAuthorize(context.Background(), 123)
|
err := client.FollowRequestAuthorize(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.FollowRequestAuthorize(context.Background(), 1234567)
|
err = client.FollowRequestAuthorize(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)
|
||||||
}
|
}
|
||||||
|
@ -623,11 +623,11 @@ func TestFollowRequestReject(t *testing.T) {
|
||||||
ClientSecret: "bar",
|
ClientSecret: "bar",
|
||||||
AccessToken: "zoo",
|
AccessToken: "zoo",
|
||||||
})
|
})
|
||||||
err := client.FollowRequestReject(context.Background(), 123)
|
err := client.FollowRequestReject(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.FollowRequestReject(context.Background(), 1234567)
|
err = client.FollowRequestReject(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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,11 @@ import (
|
||||||
|
|
||||||
// SimpleJSON is a struct for output JSON for data to be simple used
|
// SimpleJSON is a struct for output JSON for data to be simple used
|
||||||
type SimpleJSON struct {
|
type SimpleJSON struct {
|
||||||
ID int64 `json:"id"`
|
ID mastodon.ID `json:"id"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Acct string `json:"acct"`
|
Acct string `json:"acct"`
|
||||||
Avatar string `json:"avatar"`
|
Avatar string `json:"avatar"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkFlag(f ...bool) bool {
|
func checkFlag(f ...bool) bool {
|
||||||
|
|
|
@ -51,7 +51,7 @@ func ExamplePagination() {
|
||||||
var followers []*mastodon.Account
|
var followers []*mastodon.Account
|
||||||
var pg mastodon.Pagination
|
var pg mastodon.Pagination
|
||||||
for {
|
for {
|
||||||
fs, err := c.GetAccountFollowers(context.Background(), 1, &pg)
|
fs, err := c.GetAccountFollowers(context.Background(), "1", &pg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
// Status is struct to hold status.
|
// Status is struct to hold status.
|
||||||
type Status struct {
|
type Status struct {
|
||||||
ID int64 `json:"id"`
|
ID ID `json:"id"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
InReplyToID interface{} `json:"in_reply_to_id"`
|
InReplyToID interface{} `json:"in_reply_to_id"`
|
||||||
InReplyToAccountID interface{} `json:"in_reply_to_account_id"`
|
InReplyToAccountID interface{} `json:"in_reply_to_account_id"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user