Compare commits
8 commits
b2b2b3422f
...
4fabf72b1f
Author | SHA1 | Date | |
---|---|---|---|
4fabf72b1f | |||
b369583fdb | |||
0a98a61231 | |||
1c98c0bc36 | |||
f8d117333c | |||
caa4341ef2 | |||
a0eab3b6ae | |||
878a898d4c |
12 changed files with 22 additions and 32 deletions
|
@ -25,7 +25,7 @@ func (a *AcceptExecutor) Execute() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AcceptExecutor) acceptFollowRequest(gtsClient *client.Client) error {
|
func (a *AcceptExecutor) acceptFollowRequest(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, false, a.accountName, a.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, false, a.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/config"
|
|
||||||
internalFlag "codeflow.dananglin.me.uk/apollo/enbas/internal/flag"
|
internalFlag "codeflow.dananglin.me.uk/apollo/enbas/internal/flag"
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
|
||||||
)
|
)
|
||||||
|
@ -13,9 +12,8 @@ func getAccountID(
|
||||||
gtsClient *client.Client,
|
gtsClient *client.Client,
|
||||||
myAccount bool,
|
myAccount bool,
|
||||||
accountNames internalFlag.StringSliceValue,
|
accountNames internalFlag.StringSliceValue,
|
||||||
credentialsFile string,
|
|
||||||
) (string, error) {
|
) (string, error) {
|
||||||
account, err := getAccount(gtsClient, myAccount, accountNames, credentialsFile)
|
account, err := getAccount(gtsClient, myAccount, accountNames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("unable to get the account information: %w", err)
|
return "", fmt.Errorf("unable to get the account information: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -27,7 +25,6 @@ func getAccount(
|
||||||
gtsClient *client.Client,
|
gtsClient *client.Client,
|
||||||
myAccount bool,
|
myAccount bool,
|
||||||
accountNames internalFlag.StringSliceValue,
|
accountNames internalFlag.StringSliceValue,
|
||||||
credentialsFile string,
|
|
||||||
) (model.Account, error) {
|
) (model.Account, error) {
|
||||||
var (
|
var (
|
||||||
account model.Account
|
account model.Account
|
||||||
|
@ -36,7 +33,7 @@ func getAccount(
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case myAccount:
|
case myAccount:
|
||||||
account, err = getMyAccount(gtsClient, credentialsFile)
|
account, err = getMyAccount(gtsClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return account, fmt.Errorf("unable to get your account ID: %w", err)
|
return account, fmt.Errorf("unable to get your account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -52,15 +49,8 @@ func getAccount(
|
||||||
return account, nil
|
return account, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMyAccount(gtsClient *client.Client, path string) (model.Account, error) {
|
func getMyAccount(gtsClient *client.Client) (model.Account, error) {
|
||||||
authConfig, err := config.NewCredentialsConfigFromFile(path)
|
account, err := gtsClient.VerifyCredentials()
|
||||||
if err != nil {
|
|
||||||
return model.Account{}, fmt.Errorf("unable to retrieve the authentication configuration: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
accountURI := authConfig.CurrentAccount
|
|
||||||
|
|
||||||
account, err := gtsClient.GetAccount(accountURI)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return model.Account{}, fmt.Errorf("unable to retrieve your account: %w", err)
|
return model.Account{}, fmt.Errorf("unable to retrieve your account: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ func (a *AddExecutor) addToAccount(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AddExecutor) addNoteToAccount(gtsClient *client.Client) error {
|
func (a *AddExecutor) addNoteToAccount(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, false, a.accountNames, a.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, false, a.accountNames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ func (a *AddExecutor) addVoteToStatus(gtsClient *client.Client) error {
|
||||||
return MultipleChoiceError{}
|
return MultipleChoiceError{}
|
||||||
}
|
}
|
||||||
|
|
||||||
myAccountID, err := getAccountID(gtsClient, true, nil, a.config.CredentialsFile)
|
myAccountID, err := getAccountID(gtsClient, true, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to get your account ID: %w", err)
|
return fmt.Errorf("unable to get your account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ func (b *BlockExecutor) Execute() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlockExecutor) blockAccount(gtsClient *client.Client) error {
|
func (b *BlockExecutor) blockAccount(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, false, b.accountName, b.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, false, b.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ func (f *FollowExecutor) Execute() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FollowExecutor) followAccount(gtsClient *client.Client) error {
|
func (f *FollowExecutor) followAccount(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, false, f.accountName, f.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, false, f.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ func (m *MuteExecutor) Execute() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MuteExecutor) muteAccount(gtsClient *client.Client) error {
|
func (m *MuteExecutor) muteAccount(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, false, m.accountName, m.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, false, m.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ func (r *RejectExecutor) Execute() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RejectExecutor) rejectFollowRequest(gtsClient *client.Client) error {
|
func (r *RejectExecutor) rejectFollowRequest(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, false, r.accountName, r.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, false, r.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ func (r *RemoveExecutor) removeFromAccount(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RemoveExecutor) removeNoteFromAccount(gtsClient *client.Client) error {
|
func (r *RemoveExecutor) removeNoteFromAccount(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, false, r.accountNames, r.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, false, r.accountNames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ func (s *ShowExecutor) showInstance(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShowExecutor) showAccount(gtsClient *client.Client) error {
|
func (s *ShowExecutor) showAccount(gtsClient *client.Client) error {
|
||||||
account, err := getAccount(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
|
account, err := getAccount(gtsClient, s.myAccount, s.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to get the account information: %w", err)
|
return fmt.Errorf("unable to get the account information: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ func (s *ShowExecutor) showStatus(gtsClient *client.Client) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
|
myAccountID, err := getAccountID(gtsClient, true, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to get your account ID: %w", err)
|
return fmt.Errorf("unable to get your account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ func (s *ShowExecutor) showTimeline(gtsClient *client.Client) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
|
myAccountID, err := getAccountID(gtsClient, true, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to get your account ID: %w", err)
|
return fmt.Errorf("unable to get your account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ func (s *ShowExecutor) showFollowers(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShowExecutor) showFollowersFromAccount(gtsClient *client.Client) error {
|
func (s *ShowExecutor) showFollowersFromAccount(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ func (s *ShowExecutor) showFollowing(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShowExecutor) showFollowingFromAccount(gtsClient *client.Client) error {
|
func (s *ShowExecutor) showFollowingFromAccount(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ func (s *ShowExecutor) showBookmarks(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(bookmarks.Statuses) > 0 {
|
if len(bookmarks.Statuses) > 0 {
|
||||||
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
|
myAccountID, err := getAccountID(gtsClient, true, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to get your account ID: %w", err)
|
return fmt.Errorf("unable to get your account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ func (s *ShowExecutor) showLiked(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(liked.Statuses) > 0 {
|
if len(liked.Statuses) > 0 {
|
||||||
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
|
myAccountID, err := getAccountID(gtsClient, true, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to get your account ID: %w", err)
|
return fmt.Errorf("unable to get your account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ func (b *UnblockExecutor) Execute() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *UnblockExecutor) unblockAccount(gtsClient *client.Client) error {
|
func (b *UnblockExecutor) unblockAccount(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, false, b.accountName, b.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, false, b.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ func (f *UnfollowExecutor) Execute() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *UnfollowExecutor) unfollowAccount(gtsClient *client.Client) error {
|
func (f *UnfollowExecutor) unfollowAccount(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, false, f.accountName, f.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, false, f.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ func (m *UnmuteExecutor) Execute() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *UnmuteExecutor) unmuteAccount(gtsClient *client.Client) error {
|
func (m *UnmuteExecutor) unmuteAccount(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gtsClient, false, m.accountName, m.config.CredentialsFile)
|
accountID, err := getAccountID(gtsClient, false, m.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue