bug fix for AddToList and RemoveFromList

pull/171/head
Rasmus Lindroth 2022-12-30 11:44:05 +01:00
parent f54995fdf9
commit 2aa0406a44
2 changed files with 3 additions and 3 deletions

View File

@ -90,7 +90,7 @@ func (c *Client) DeleteList(ctx context.Context, id ID) error {
func (c *Client) AddToList(ctx context.Context, list ID, accounts ...ID) error { func (c *Client) AddToList(ctx context.Context, list ID, accounts ...ID) error {
params := url.Values{} params := url.Values{}
for _, acct := range accounts { for _, acct := range accounts {
params.Add("account_ids", string(acct)) params.Add("account_ids[]", string(acct))
} }
return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/lists/%s/accounts", url.PathEscape(string(list))), params, nil, nil) return c.doAPI(ctx, http.MethodPost, fmt.Sprintf("/api/v1/lists/%s/accounts", url.PathEscape(string(list))), params, nil, nil)
@ -100,7 +100,7 @@ func (c *Client) AddToList(ctx context.Context, list ID, accounts ...ID) error {
func (c *Client) RemoveFromList(ctx context.Context, list ID, accounts ...ID) error { func (c *Client) RemoveFromList(ctx context.Context, list ID, accounts ...ID) error {
params := url.Values{} params := url.Values{}
for _, acct := range accounts { for _, acct := range accounts {
params.Add("account_ids", string(acct)) params.Add("account_ids[]", string(acct))
} }
return c.doAPI(ctx, http.MethodDelete, fmt.Sprintf("/api/v1/lists/%s/accounts", url.PathEscape(string(list))), params, nil, nil) return c.doAPI(ctx, http.MethodDelete, fmt.Sprintf("/api/v1/lists/%s/accounts", url.PathEscape(string(list))), params, nil, nil)

View File

@ -235,7 +235,7 @@ func TestAddToList(t *testing.T) {
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return return
} }
if r.PostFormValue("account_ids") != "1" { if r.PostFormValue("account_ids[]") != "1" {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return return
} }