2024-06-02 07:53:13 +01:00
|
|
|
// SPDX-FileCopyrightText: 2024 Dan Anglin <d.n.i.anglin@gmail.com>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2024-05-23 18:06:49 +01:00
|
|
|
package executor
|
2024-02-23 09:44:57 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
|
2024-02-24 15:53:29 +00:00
|
|
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
|
2024-02-27 19:52:59 +00:00
|
|
|
"codeflow.dananglin.me.uk/apollo/enbas/internal/utilities"
|
2024-02-23 09:44:57 +00:00
|
|
|
)
|
|
|
|
|
2024-05-23 18:06:49 +01:00
|
|
|
type ShowExecutor struct {
|
2024-02-23 09:44:57 +00:00
|
|
|
*flag.FlagSet
|
2024-05-23 18:06:49 +01:00
|
|
|
topLevelFlags TopLevelFlags
|
2024-05-20 17:26:06 +01:00
|
|
|
myAccount bool
|
2024-05-23 18:22:13 +01:00
|
|
|
skipAccountRelationship bool
|
2024-05-20 19:46:05 +01:00
|
|
|
showUserPreferences bool
|
2024-05-29 20:26:10 +01:00
|
|
|
showInBrowser bool
|
2024-05-20 17:26:06 +01:00
|
|
|
resourceType string
|
2024-05-21 21:06:18 +01:00
|
|
|
accountName string
|
2024-05-20 17:26:06 +01:00
|
|
|
statusID string
|
|
|
|
timelineCategory string
|
|
|
|
listID string
|
|
|
|
tag string
|
2024-06-15 18:40:13 +01:00
|
|
|
pollID string
|
2024-05-20 17:26:06 +01:00
|
|
|
limit int
|
2024-02-23 09:44:57 +00:00
|
|
|
}
|
|
|
|
|
2024-05-23 18:06:49 +01:00
|
|
|
func NewShowExecutor(tlf TopLevelFlags, name, summary string) *ShowExecutor {
|
2024-06-03 07:00:39 +01:00
|
|
|
showExe := ShowExecutor{
|
2024-05-22 23:30:09 +01:00
|
|
|
FlagSet: flag.NewFlagSet(name, flag.ExitOnError),
|
|
|
|
topLevelFlags: tlf,
|
2024-02-23 09:44:57 +00:00
|
|
|
}
|
|
|
|
|
2024-06-09 15:58:10 +01:00
|
|
|
showExe.BoolVar(&showExe.myAccount, flagMyAccount, false, "Set to true to lookup your account")
|
|
|
|
showExe.BoolVar(&showExe.skipAccountRelationship, flagSkipRelationship, false, "Set to true to skip showing your relationship to the specified account")
|
|
|
|
showExe.BoolVar(&showExe.showUserPreferences, flagShowPreferences, false, "Show your preferences")
|
|
|
|
showExe.BoolVar(&showExe.showInBrowser, flagBrowser, false, "Set to true to view in the browser")
|
|
|
|
showExe.StringVar(&showExe.resourceType, flagType, "", "Specify the type of resource to display")
|
|
|
|
showExe.StringVar(&showExe.accountName, flagAccountName, "", "Specify the account name in full (username@domain)")
|
|
|
|
showExe.StringVar(&showExe.statusID, flagStatusID, "", "Specify the ID of the status to display")
|
|
|
|
showExe.StringVar(&showExe.timelineCategory, flagTimelineCategory, model.TimelineCategoryHome, "Specify the timeline category to view")
|
|
|
|
showExe.StringVar(&showExe.listID, flagListID, "", "Specify the ID of the list to display")
|
|
|
|
showExe.StringVar(&showExe.tag, flagTag, "", "Specify the name of the tag to use")
|
2024-06-15 18:40:13 +01:00
|
|
|
showExe.StringVar(&showExe.pollID, flagPollID, "", "Specify the ID of the poll to display")
|
2024-06-09 15:58:10 +01:00
|
|
|
showExe.IntVar(&showExe.limit, flagLimit, 20, "Specify the limit of items to display")
|
2024-02-28 19:35:18 +00:00
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
showExe.Usage = commandUsageFunc(name, summary, showExe.FlagSet)
|
2024-02-23 09:44:57 +00:00
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
return &showExe
|
2024-02-23 09:44:57 +00:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) Execute() error {
|
|
|
|
if s.resourceType == "" {
|
2024-05-23 18:06:49 +01:00
|
|
|
return FlagNotSetError{flagText: flagType}
|
2024-02-23 09:44:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
funcMap := map[string]func(*client.Client) error{
|
2024-06-10 10:58:43 +01:00
|
|
|
resourceInstance: s.showInstance,
|
|
|
|
resourceAccount: s.showAccount,
|
|
|
|
resourceStatus: s.showStatus,
|
|
|
|
resourceTimeline: s.showTimeline,
|
|
|
|
resourceList: s.showList,
|
|
|
|
resourceFollowers: s.showFollowers,
|
|
|
|
resourceFollowing: s.showFollowing,
|
|
|
|
resourceBlocked: s.showBlocked,
|
|
|
|
resourceBookmarks: s.showBookmarks,
|
|
|
|
resourceLiked: s.showLiked,
|
|
|
|
resourceStarred: s.showLiked,
|
|
|
|
resourceFollowRequest: s.showFollowRequests,
|
2024-06-15 18:40:13 +01:00
|
|
|
resourcePoll: s.showPoll,
|
2024-06-03 07:00:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
doFunc, ok := funcMap[s.resourceType]
|
2024-02-23 09:44:57 +00:00
|
|
|
if !ok {
|
2024-06-03 07:00:39 +01:00
|
|
|
return UnsupportedTypeError{resourceType: s.resourceType}
|
2024-02-28 19:35:18 +00:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
gtsClient, err := client.NewClientFromConfig(s.topLevelFlags.ConfigDir)
|
2024-02-28 19:35:18 +00:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to create the GoToSocial client: %w", err)
|
2024-02-23 09:44:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return doFunc(gtsClient)
|
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) showInstance(gtsClient *client.Client) error {
|
2024-05-21 21:06:18 +01:00
|
|
|
instance, err := gtsClient.GetInstance()
|
2024-02-23 09:44:57 +00:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the instance details: %w", err)
|
2024-02-23 09:44:57 +00:00
|
|
|
}
|
|
|
|
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(instance, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-02-23 09:44:57 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) showAccount(gtsClient *client.Client) error {
|
2024-05-20 18:37:29 +01:00
|
|
|
var (
|
|
|
|
account model.Account
|
|
|
|
err error
|
|
|
|
)
|
2024-02-23 09:44:57 +00:00
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
if s.myAccount {
|
|
|
|
account, err = getMyAccount(gtsClient, s.topLevelFlags.ConfigDir)
|
2024-02-23 09:44:57 +00:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("received an error while getting the account details: %w", err)
|
2024-02-23 09:44:57 +00:00
|
|
|
}
|
|
|
|
} else {
|
2024-06-03 07:00:39 +01:00
|
|
|
if s.accountName == "" {
|
2024-05-23 18:06:49 +01:00
|
|
|
return FlagNotSetError{flagText: flagAccountName}
|
2024-02-23 09:44:57 +00:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
account, err = getAccount(gtsClient, s.accountName)
|
2024-05-20 18:37:29 +01:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("received an error while getting the account details: %w", err)
|
2024-05-20 18:37:29 +01:00
|
|
|
}
|
2024-02-23 09:44:57 +00:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
if s.showInBrowser {
|
2024-05-29 20:26:10 +01:00
|
|
|
utilities.OpenLink(account.URL)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(account, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-02-23 09:44:57 +00:00
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
if !s.myAccount && !s.skipAccountRelationship {
|
2024-05-21 21:06:18 +01:00
|
|
|
relationship, err := gtsClient.GetAccountRelationship(account.ID)
|
2024-05-20 17:26:06 +01:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the relationship to this account: %w", err)
|
2024-05-20 17:26:06 +01:00
|
|
|
}
|
|
|
|
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(relationship, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-05-20 17:26:06 +01:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
if s.myAccount && s.showUserPreferences {
|
2024-05-21 21:06:18 +01:00
|
|
|
preferences, err := gtsClient.GetUserPreferences()
|
2024-05-20 19:46:05 +01:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the user preferences: %w", err)
|
2024-05-20 19:46:05 +01:00
|
|
|
}
|
|
|
|
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(preferences, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-05-20 19:46:05 +01:00
|
|
|
}
|
|
|
|
|
2024-02-23 09:44:57 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) showStatus(gtsClient *client.Client) error {
|
|
|
|
if s.statusID == "" {
|
2024-05-23 18:06:49 +01:00
|
|
|
return FlagNotSetError{flagText: flagStatusID}
|
2024-02-23 13:14:50 +00:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
status, err := gtsClient.GetStatus(s.statusID)
|
2024-02-23 13:14:50 +00:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the status: %w", err)
|
2024-02-23 13:14:50 +00:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
if s.showInBrowser {
|
2024-05-29 20:26:10 +01:00
|
|
|
utilities.OpenLink(status.URL)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(status, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-02-23 13:14:50 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2024-02-24 15:53:29 +00:00
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) showTimeline(gtsClient *client.Client) error {
|
2024-02-24 15:53:29 +00:00
|
|
|
var (
|
2024-06-03 03:54:27 +01:00
|
|
|
timeline model.StatusList
|
2024-02-24 15:53:29 +00:00
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
switch s.timelineCategory {
|
2024-06-02 11:35:43 +01:00
|
|
|
case model.TimelineCategoryHome:
|
2024-06-03 07:00:39 +01:00
|
|
|
timeline, err = gtsClient.GetHomeTimeline(s.limit)
|
2024-06-02 11:35:43 +01:00
|
|
|
case model.TimelineCategoryPublic:
|
2024-06-03 07:00:39 +01:00
|
|
|
timeline, err = gtsClient.GetPublicTimeline(s.limit)
|
2024-06-02 11:35:43 +01:00
|
|
|
case model.TimelineCategoryList:
|
2024-06-03 07:00:39 +01:00
|
|
|
if s.listID == "" {
|
2024-05-23 18:06:49 +01:00
|
|
|
return FlagNotSetError{flagText: flagListID}
|
2024-02-24 15:53:29 +00:00
|
|
|
}
|
|
|
|
|
2024-06-03 03:54:27 +01:00
|
|
|
var list model.List
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
list, err = gtsClient.GetList(s.listID)
|
2024-06-03 03:54:27 +01:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("unable to retrieve the list: %w", err)
|
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
timeline, err = gtsClient.GetListTimeline(list.ID, list.Title, s.limit)
|
2024-06-02 11:35:43 +01:00
|
|
|
case model.TimelineCategoryTag:
|
2024-06-03 07:00:39 +01:00
|
|
|
if s.tag == "" {
|
2024-05-23 18:06:49 +01:00
|
|
|
return FlagNotSetError{flagText: flagTag}
|
2024-02-24 15:53:29 +00:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
timeline, err = gtsClient.GetTagTimeline(s.tag, s.limit)
|
2024-02-24 15:53:29 +00:00
|
|
|
default:
|
2024-06-03 07:00:39 +01:00
|
|
|
return model.InvalidTimelineCategoryError{Value: s.timelineCategory}
|
2024-02-24 15:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
2024-06-03 07:00:39 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the %s timeline: %w", s.timelineCategory, err)
|
2024-02-24 15:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(timeline.Statuses) == 0 {
|
|
|
|
fmt.Println("There are no statuses in this timeline.")
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(timeline, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-02-24 15:53:29 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2024-02-27 19:52:59 +00:00
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) showList(gtsClient *client.Client) error {
|
|
|
|
if s.listID == "" {
|
|
|
|
return s.showLists(gtsClient)
|
2024-05-19 11:48:36 +01:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
list, err := gtsClient.GetList(s.listID)
|
2024-05-19 11:48:36 +01:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the list: %w", err)
|
2024-05-19 11:48:36 +01:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
accounts, err := gtsClient.GetAccountsFromList(s.listID, 0)
|
2024-05-19 11:48:36 +01:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the accounts from the list: %w", err)
|
2024-05-19 11:48:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(accounts) > 0 {
|
|
|
|
accountMap := make(map[string]string)
|
|
|
|
for i := range accounts {
|
2024-05-31 21:41:10 +01:00
|
|
|
accountMap[accounts[i].Acct] = accounts[i].Username
|
2024-05-19 11:48:36 +01:00
|
|
|
}
|
2024-05-20 17:26:06 +01:00
|
|
|
|
2024-05-19 11:48:36 +01:00
|
|
|
list.Accounts = accountMap
|
|
|
|
}
|
|
|
|
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(list, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-05-19 11:48:36 +01:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) showLists(gtsClient *client.Client) error {
|
2024-05-21 21:06:18 +01:00
|
|
|
lists, err := gtsClient.GetAllLists()
|
2024-02-27 19:52:59 +00:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the lists: %w", err)
|
2024-02-27 19:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(lists) == 0 {
|
|
|
|
fmt.Println("You have no lists.")
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(lists, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-02-27 19:52:59 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2024-05-20 17:26:06 +01:00
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) showFollowers(gtsClient *client.Client) error {
|
|
|
|
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.topLevelFlags.ConfigDir)
|
2024-05-21 21:06:18 +01:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
2024-05-20 17:26:06 +01:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
followers, err := gtsClient.GetFollowers(accountID, s.limit)
|
2024-05-20 17:26:06 +01:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the list of followers: %w", err)
|
2024-05-20 17:26:06 +01:00
|
|
|
}
|
|
|
|
|
2024-05-21 14:30:50 +01:00
|
|
|
if len(followers.Accounts) > 0 {
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(followers, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-05-20 17:26:06 +01:00
|
|
|
} else {
|
|
|
|
fmt.Println("There are no followers for this account or the list is hidden.")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) showFollowing(gtsClient *client.Client) error {
|
|
|
|
accountID, err := getAccountID(gtsClient, s.myAccount, s.accountName, s.topLevelFlags.ConfigDir)
|
2024-05-21 21:06:18 +01:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("received an error while getting the account ID: %w", err)
|
2024-05-20 17:26:06 +01:00
|
|
|
}
|
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
following, err := gtsClient.GetFollowing(accountID, s.limit)
|
2024-05-20 17:26:06 +01:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the list of followed accounts: %w", err)
|
2024-05-20 17:26:06 +01:00
|
|
|
}
|
|
|
|
|
2024-05-21 14:30:50 +01:00
|
|
|
if len(following.Accounts) > 0 {
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(following, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-05-20 17:26:06 +01:00
|
|
|
} else {
|
|
|
|
fmt.Println("This account is not following anyone or the list is hidden.")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2024-05-21 13:19:53 +01:00
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) showBlocked(gtsClient *client.Client) error {
|
|
|
|
blocked, err := gtsClient.GetBlockedAccounts(s.limit)
|
2024-05-21 13:19:53 +01:00
|
|
|
if err != nil {
|
2024-06-02 11:35:43 +01:00
|
|
|
return fmt.Errorf("unable to retrieve the list of blocked accounts: %w", err)
|
2024-05-21 13:19:53 +01:00
|
|
|
}
|
|
|
|
|
2024-05-21 14:30:50 +01:00
|
|
|
if len(blocked.Accounts) > 0 {
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(blocked, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-05-21 13:19:53 +01:00
|
|
|
} else {
|
|
|
|
fmt.Println("You have no blocked accounts.")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2024-06-03 06:53:31 +01:00
|
|
|
|
2024-06-03 07:00:39 +01:00
|
|
|
func (s *ShowExecutor) showBookmarks(gtsClient *client.Client) error {
|
|
|
|
bookmarks, err := gtsClient.GetBookmarks(s.limit)
|
2024-06-03 06:53:31 +01:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("unable to retrieve the list of bookmarks: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(bookmarks.Statuses) > 0 {
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(bookmarks, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-06-03 06:53:31 +01:00
|
|
|
} else {
|
|
|
|
fmt.Println("You have no bookmarks.")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2024-06-04 17:01:33 +01:00
|
|
|
|
|
|
|
func (s *ShowExecutor) showLiked(gtsClient *client.Client) error {
|
|
|
|
liked, err := gtsClient.GetLikedStatuses(s.limit, s.resourceType)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("unable to retrieve the list of your %s statuses: %w", s.resourceType, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(liked.Statuses) > 0 {
|
2024-06-09 15:58:10 +01:00
|
|
|
utilities.Display(liked, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
2024-06-04 17:01:33 +01:00
|
|
|
} else {
|
|
|
|
fmt.Printf("You have no %s statuses.\n", s.resourceType)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2024-06-10 10:58:43 +01:00
|
|
|
|
|
|
|
func (s *ShowExecutor) showFollowRequests(gtsClient *client.Client) error {
|
|
|
|
accounts, err := gtsClient.GetFollowRequests(s.limit)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("unable to retrieve the list of follow requests: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(accounts.Accounts) > 0 {
|
|
|
|
utilities.Display(accounts, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
|
|
|
} else {
|
|
|
|
fmt.Println("You have no follow requests.")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2024-06-15 18:40:13 +01:00
|
|
|
|
|
|
|
func (s *ShowExecutor) showPoll(gtsClient *client.Client) error {
|
|
|
|
if s.pollID == "" {
|
|
|
|
return FlagNotSetError{flagText: flagPollID}
|
|
|
|
}
|
|
|
|
|
|
|
|
poll, err := gtsClient.GetPoll(s.pollID)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("unable to retrieve the poll: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
utilities.Display(poll, *s.topLevelFlags.NoColor, s.topLevelFlags.Pager)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|