checkpoint: add ability to unfollow accounts
This commit is contained in:
parent
4d0522eb49
commit
0e8f83f4e0
4 changed files with 21 additions and 1 deletions
|
@ -71,5 +71,11 @@ func (c *followCommand) followAccount(gts *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *followCommand) unfollowAccount(gts *client.Client) error {
|
func (c *followCommand) unfollowAccount(gts *client.Client) error {
|
||||||
|
if err := gts.UnfollowAccount(c.accountID); err != nil {
|
||||||
|
return fmt.Errorf("unable to unfollow the account; %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Successfully unfollowed the account.")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ func run() error {
|
||||||
add string = "add"
|
add string = "add"
|
||||||
remove string = "remove"
|
remove string = "remove"
|
||||||
follow string = "follow"
|
follow string = "follow"
|
||||||
|
unfollow string = "unfollow"
|
||||||
)
|
)
|
||||||
|
|
||||||
summaries := map[string]string{
|
summaries := map[string]string{
|
||||||
|
@ -72,6 +73,7 @@ func run() error {
|
||||||
add: "add a resource to another resource",
|
add: "add a resource to another resource",
|
||||||
remove: "remove a resource from another resource",
|
remove: "remove a resource from another resource",
|
||||||
follow: "follow a resource (e.g. an account)",
|
follow: "follow a resource (e.g. an account)",
|
||||||
|
unfollow: "unfollow a resource (e.g. an account)",
|
||||||
}
|
}
|
||||||
|
|
||||||
flag.Usage = enbasUsageFunc(summaries)
|
flag.Usage = enbasUsageFunc(summaries)
|
||||||
|
@ -112,6 +114,8 @@ func run() error {
|
||||||
executor = newRemoveCommand(remove, summaries[remove])
|
executor = newRemoveCommand(remove, summaries[remove])
|
||||||
case follow:
|
case follow:
|
||||||
executor = newFollowCommand(follow, summaries[follow], false)
|
executor = newFollowCommand(follow, summaries[follow], false)
|
||||||
|
case unfollow:
|
||||||
|
executor = newFollowCommand(unfollow, summaries[unfollow], true)
|
||||||
default:
|
default:
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
|
|
||||||
|
|
|
@ -32,3 +32,13 @@ func (g *Client) FollowAccount(accountID string, reblogs, notify bool) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Client) UnfollowAccount(accountID string) error {
|
||||||
|
url := g.Authentication.Instance + fmt.Sprintf("/api/v1/accounts/%s/unfollow", accountID)
|
||||||
|
|
||||||
|
if err := g.sendRequest(http.MethodPost, url, nil, nil); err != nil {
|
||||||
|
return fmt.Errorf("received an error after sending the request to unfollow the account; %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (a AccountRelationship) String() string {
|
||||||
|
|
||||||
output := fmt.Sprintf(
|
output := fmt.Sprintf(
|
||||||
format,
|
format,
|
||||||
utilities.HeaderFormat("YOUR RELATIONSHIP TO THIS ACCOUNT:"),
|
utilities.HeaderFormat("YOUR RELATIONSHIP WITH THIS ACCOUNT:"),
|
||||||
utilities.FieldFormat("Following"), a.Following,
|
utilities.FieldFormat("Following"), a.Following,
|
||||||
utilities.FieldFormat("Is following you"), a.FollowedBy,
|
utilities.FieldFormat("Is following you"), a.FollowedBy,
|
||||||
utilities.FieldFormat("A follow request was sent and is pending"), a.FollowRequested,
|
utilities.FieldFormat("A follow request was sent and is pending"), a.FollowRequested,
|
||||||
|
|
Loading…
Reference in a new issue