fix: check following before adding to list
Check if the user is following a specified account before adding it to a list.
This commit is contained in:
parent
eb2d9f44f6
commit
f73f1f5872
2 changed files with 18 additions and 1 deletions
|
@ -105,7 +105,16 @@ func (a *AddExecutor) addAccountsToList(gtsClient *client.Client) error {
|
|||
for ind := range a.accountNames {
|
||||
accountID, err := getTheirAccountID(gtsClient, a.accountNames[ind])
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get the account ID for %s, %w", a.accountNames[ind], err)
|
||||
return fmt.Errorf("unable to get the account ID for %s: %w", a.accountNames[ind], err)
|
||||
}
|
||||
|
||||
relationship, err := gtsClient.GetAccountRelationship(accountID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get your relationship to %s: %w", a.accountNames[ind], err)
|
||||
}
|
||||
|
||||
if !relationship.Following {
|
||||
return NotFollowingError{Account: a.accountNames[ind]}
|
||||
}
|
||||
|
||||
accountIDs[ind] = accountID
|
||||
|
|
|
@ -94,3 +94,11 @@ func (e NoPollOptionError) Error() string {
|
|||
flagPollOption +
|
||||
" flag to add options to the poll"
|
||||
}
|
||||
|
||||
type NotFollowingError struct {
|
||||
Account string
|
||||
}
|
||||
|
||||
func (e NotFollowingError) Error() string {
|
||||
return "you are not following " + e.Account
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue