Compare commits

..

5 commits

Author SHA1 Message Date
b2b2b3422f
updated manual 2024-08-13 23:19:40 +01:00
326d3e2576
updated manual 2024-08-13 23:17:59 +01:00
2f530bca5a
checkpoint: now vote via the status 2024-08-13 22:15:29 +01:00
64e8d6f0ba
checkpoint:
- BREAKING: when creating the status, only print the ID on success.
- fix: Only display the poll results under certain conditions.
2024-08-13 19:27:27 +01:00
ef2b02b799
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 18:30:46 +01:00
12 changed files with 32 additions and 22 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)
accountID, err := getAccountID(gtsClient, false, a.accountName, a.config.CredentialsFile)
if err != nil {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}

View file

@ -4,6 +4,7 @@ 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"
)
@ -12,8 +13,9 @@ func getAccountID(
gtsClient *client.Client,
myAccount bool,
accountNames internalFlag.StringSliceValue,
credentialsFile string,
) (string, error) {
account, err := getAccount(gtsClient, myAccount, accountNames)
account, err := getAccount(gtsClient, myAccount, accountNames, credentialsFile)
if err != nil {
return "", fmt.Errorf("unable to get the account information: %w", err)
}
@ -25,6 +27,7 @@ func getAccount(
gtsClient *client.Client,
myAccount bool,
accountNames internalFlag.StringSliceValue,
credentialsFile string,
) (model.Account, error) {
var (
account model.Account
@ -33,7 +36,7 @@ func getAccount(
switch {
case myAccount:
account, err = getMyAccount(gtsClient)
account, err = getMyAccount(gtsClient, credentialsFile)
if err != nil {
return account, fmt.Errorf("unable to get your account ID: %w", err)
}
@ -49,8 +52,15 @@ func getAccount(
return account, nil
}
func getMyAccount(gtsClient *client.Client) (model.Account, error) {
account, err := gtsClient.VerifyCredentials()
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)
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)
accountID, err := getAccountID(gtsClient, false, a.accountNames, a.config.CredentialsFile)
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)
myAccountID, err := getAccountID(gtsClient, true, nil, a.config.CredentialsFile)
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)
accountID, err := getAccountID(gtsClient, false, b.accountName, b.config.CredentialsFile)
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)
accountID, err := getAccountID(gtsClient, false, f.accountName, f.config.CredentialsFile)
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)
accountID, err := getAccountID(gtsClient, false, m.accountName, m.config.CredentialsFile)
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)
accountID, err := getAccountID(gtsClient, false, r.accountName, r.config.CredentialsFile)
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)
accountID, err := getAccountID(gtsClient, false, r.accountNames, r.config.CredentialsFile)
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)
account, err := getAccount(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
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)
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
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)
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
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)
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
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)
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.config.CredentialsFile)
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)
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
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)
myAccountID, err := getAccountID(gtsClient, true, nil, s.config.CredentialsFile)
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)
accountID, err := getAccountID(gtsClient, false, b.accountName, b.config.CredentialsFile)
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)
accountID, err := getAccountID(gtsClient, false, f.accountName, f.config.CredentialsFile)
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)
accountID, err := getAccountID(gtsClient, false, m.accountName, m.config.CredentialsFile)
if err != nil {
return fmt.Errorf("received an error while getting the account ID: %w", err)
}