Compare commits

..

8 commits

Author SHA1 Message Date
4fabf72b1f
checkpoint: resolved errors after cleanup 2024-08-14 00:14:02 +01:00
b369583fdb
updated manual 2024-08-13 23:52:40 +01:00
0a98a61231
updated manual 2024-08-13 23:52:40 +01:00
1c98c0bc36
checkpoint: now vote via the status 2024-08-13 23:52:40 +01:00
f8d117333c
checkpoint:
- BREAKING: when creating the status, only print the ID on success.
- fix: Only display the poll results under certain conditions.
2024-08-13 23:52:39 +01:00
caa4341ef2
checkpoint:
- BREAKING: user can no longer view a poll directly from the poll ID.
- Added more poll details in status view.
- Poll now shows the user's vote in status/timeline view.
2024-08-13 23:52:39 +01:00
a0eab3b6ae
refactor: clean up the getAccountID function sig
The getAccountID function no longer needs the path to the credentials
file.
2024-08-13 23:51:16 +01:00
878a898d4c
fix: use VerifyCredentials to get account info
Use the clients VerifyCredentials method to get the user's account
information.
2024-08-13 23:41:12 +01:00
12 changed files with 22 additions and 32 deletions

View file

@ -25,7 +25,7 @@ func (a *AcceptExecutor) Execute() 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 {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}

View file

@ -4,7 +4,6 @@ import (
"fmt"
"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"
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
)
@ -13,9 +12,8 @@ func getAccountID(
gtsClient *client.Client,
myAccount bool,
accountNames internalFlag.StringSliceValue,
credentialsFile string,
) (string, error) {
account, err := getAccount(gtsClient, myAccount, accountNames, credentialsFile)
account, err := getAccount(gtsClient, myAccount, accountNames)
if err != nil {
return "", fmt.Errorf("unable to get the account information: %w", err)
}
@ -27,7 +25,6 @@ func getAccount(
gtsClient *client.Client,
myAccount bool,
accountNames internalFlag.StringSliceValue,
credentialsFile string,
) (model.Account, error) {
var (
account model.Account
@ -36,7 +33,7 @@ func getAccount(
switch {
case myAccount:
account, err = getMyAccount(gtsClient, credentialsFile)
account, err = getMyAccount(gtsClient)
if err != nil {
return account, fmt.Errorf("unable to get your account ID: %w", err)
}
@ -52,15 +49,8 @@ func getAccount(
return account, nil
}
func getMyAccount(gtsClient *client.Client, path string) (model.Account, error) {
authConfig, err := config.NewCredentialsConfigFromFile(path)
if err != nil {
return model.Account{}, fmt.Errorf("unable to retrieve the authentication configuration: %w", err)
}
accountURI := authConfig.CurrentAccount
account, err := gtsClient.GetAccount(accountURI)
func getMyAccount(gtsClient *client.Client) (model.Account, error) {
account, err := gtsClient.VerifyCredentials()
if err != nil {
return model.Account{}, fmt.Errorf("unable to retrieve your account: %w", err)
}

View file

@ -103,7 +103,7 @@ func (a *AddExecutor) addToAccount(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 {
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{}
}
myAccountID, err := getAccountID(gtsClient, true, nil, a.config.CredentialsFile)
myAccountID, err := getAccountID(gtsClient, true, nil)
if err != nil {
return fmt.Errorf("unable to get your account ID: %w", err)
}

View file

@ -25,7 +25,7 @@ func (b *BlockExecutor) Execute() 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 {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}

View file

@ -25,7 +25,7 @@ func (f *FollowExecutor) Execute() 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 {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}

View file

@ -25,7 +25,7 @@ func (m *MuteExecutor) Execute() 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 {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}

View file

@ -25,7 +25,7 @@ func (r *RejectExecutor) Execute() 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 {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}

View file

@ -93,7 +93,7 @@ func (r *RemoveExecutor) removeFromAccount(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 {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}

View file

@ -58,7 +58,7 @@ func (s *ShowExecutor) showInstance(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 {
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
}
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
myAccountID, err := getAccountID(gtsClient, true, nil)
if err != nil {
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
}
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
myAccountID, err := getAccountID(gtsClient, true, nil)
if err != nil {
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 {
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName)
if err != nil {
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 {
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName)
if err != nil {
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 {
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
myAccountID, err := getAccountID(gtsClient, true, nil)
if err != nil {
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 {
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
myAccountID, err := getAccountID(gtsClient, true, nil)
if err != nil {
return fmt.Errorf("unable to get your account ID: %w", err)
}

View file

@ -25,7 +25,7 @@ func (b *UnblockExecutor) Execute() 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 {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}

View file

@ -25,7 +25,7 @@ func (f *UnfollowExecutor) Execute() 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 {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}

View file

@ -25,7 +25,7 @@ func (m *UnmuteExecutor) Execute() 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 {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}