--- a/cmd/accounts.go Wed Sep 05 13:51:32 2018 +0200
+++ b/cmd/accounts.go Wed Sep 05 23:19:11 2018 +0200
@@ -179,9 +179,12 @@
accountFollowSubcommand,
accountBlockSubcommand,
accountMuteSubcommand,
+ accountPinSubcommand,
+ accountUnpinSubcommand,
accountRelationshipsSubcommand,
accountReportsSubcommand,
accountUpdateSubcommand,
+ accountListEndorsementsSubcommand,
}
var accountSearchSubcommand = &cobra.Command{
@@ -255,6 +258,33 @@
},
}
+var accountPinSubcommand = &cobra.Command{
+ Use: "pin",
+ Short: "Endorse (pin) the account",
+ Aliases: []string{"endorse"},
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return accountSubcommandsRunE(cmd.Name(), args)
+ },
+}
+
+var accountUnpinSubcommand = &cobra.Command{
+ Use: "unpin",
+ Short: "Cancel endorsement of an account",
+ Aliases: []string{"disavow"},
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return accountSubcommandsRunE(cmd.Name(), args)
+ },
+}
+
+var accountListEndorsementsSubcommand = &cobra.Command{
+ Use: "pinned",
+ Short: `Display the list of pinned (endorsed) accounts`,
+ Aliases: []string{"list-endorsements", "get-endorsements"},
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return accountSubcommandsRunE(cmd.Name(), args)
+ },
+}
+
var accountRelationshipsSubcommand = &cobra.Command{
Use: "relationships --account-ids ACC1,ACC2...",
Short: "List relationships with the accounts",
@@ -373,7 +403,7 @@
switch subcmd {
case "show", "search", "update":
// These subcommands do not require an account ID
- case "favourites", "blocks", "mutes":
+ case "favourites", "blocks", "mutes", "pinned":
// Those subcommands can not use an account ID
if opt.accountID > 0 {
return errors.New("useless account ID")
@@ -573,6 +603,14 @@
relationship, err = gClient.MuteAccount(opt.accountID, muteNotif)
}
obj = relationship
+ case "pin", "unpin":
+ var relationship *madon.Relationship
+ if subcmd == "unpin" {
+ relationship, err = gClient.UnpinAccount(opt.accountID)
+ } else {
+ relationship, err = gClient.PinAccount(opt.accountID)
+ }
+ obj = relationship
case "favourites":
var statusList []madon.Status
statusList, err = gClient.GetFavourites(limOpts)
@@ -594,6 +632,13 @@
accountList = accountList[:opt.keep]
}
obj = accountList
+ case "pinned":
+ var accountList []madon.Account
+ accountList, err = gClient.GetEndorsements(limOpts)
+ if opt.keep > 0 && len(accountList) > int(opt.keep) {
+ accountList = accountList[:opt.keep]
+ }
+ obj = accountList
case "relationships":
var ids []int64
ids, err = splitIDs(opt.accountIDs)