Compare commits
1 commit
57973f63d1
...
786d62fc69
Author | SHA1 | Date | |
---|---|---|---|
786d62fc69 |
6 changed files with 81 additions and 2 deletions
|
@ -240,7 +240,7 @@ func (g *Client) ReblogStatus(statusID string) error {
|
||||||
|
|
||||||
if err := g.sendRequest(params); err != nil {
|
if err := g.sendRequest(params); err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"received an error after sending the request to reblog the status; %w",
|
"received an error after sending the request to reblog the status: %w",
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,49 @@ func (g *Client) UnreblogStatus(statusID string) error {
|
||||||
|
|
||||||
if err := g.sendRequest(params); err != nil {
|
if err := g.sendRequest(params); err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"received an error after sending the request to un-reblog the status; %w",
|
"received an error after sending the request to un-reblog the status: %w",
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) MuteStatus(statusID string) error {
|
||||||
|
url := g.Authentication.Instance + baseStatusesPath + "/" + statusID + "/mute"
|
||||||
|
|
||||||
|
params := requestParameters{
|
||||||
|
httpMethod: http.MethodPost,
|
||||||
|
url: url,
|
||||||
|
requestBody: nil,
|
||||||
|
contentType: "",
|
||||||
|
output: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := g.sendRequest(params); err != nil {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"received an error after sending the request to mute the status: %w",
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) UnmuteStatus(statusID string) error {
|
||||||
|
url := g.Authentication.Instance + baseStatusesPath + "/" + statusID + "/unmute"
|
||||||
|
|
||||||
|
params := requestParameters{
|
||||||
|
httpMethod: http.MethodPost,
|
||||||
|
url: url,
|
||||||
|
requestBody: nil,
|
||||||
|
contentType: "",
|
||||||
|
output: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := g.sendRequest(params); err != nil {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"received an error after sending the request to unmute the status: %w",
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,6 +326,7 @@ type MuteExecutor struct {
|
||||||
accountName internalFlag.StringSliceValue
|
accountName internalFlag.StringSliceValue
|
||||||
muteDuration internalFlag.TimeDurationValue
|
muteDuration internalFlag.TimeDurationValue
|
||||||
muteNotifications bool
|
muteNotifications bool
|
||||||
|
statusID string
|
||||||
resourceType string
|
resourceType string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,6 +347,7 @@ func NewMuteExecutor(
|
||||||
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
||||||
exe.Var(&exe.muteDuration, "mute-duration", "Specify how long the mute should last for. To mute indefinitely, set this to 0s")
|
exe.Var(&exe.muteDuration, "mute-duration", "Specify how long the mute should last for. To mute indefinitely, set this to 0s")
|
||||||
exe.BoolVar(&exe.muteNotifications, "mute-notifications", false, "Set to true to mute notifications as well as posts")
|
exe.BoolVar(&exe.muteNotifications, "mute-notifications", false, "Set to true to mute notifications as well as posts")
|
||||||
|
exe.StringVar(&exe.statusID, "status-id", "", "The ID of the status")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
return &exe
|
return &exe
|
||||||
|
@ -570,6 +572,7 @@ type UnmuteExecutor struct {
|
||||||
printer *printer.Printer
|
printer *printer.Printer
|
||||||
config *config.Config
|
config *config.Config
|
||||||
accountName internalFlag.StringSliceValue
|
accountName internalFlag.StringSliceValue
|
||||||
|
statusID string
|
||||||
resourceType string
|
resourceType string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,6 +590,7 @@ func NewUnmuteExecutor(
|
||||||
exe.Usage = usage.ExecutorUsageFunc("unmute", "Umutes a specific resource (e.g. an account)", exe.FlagSet)
|
exe.Usage = usage.ExecutorUsageFunc("unmute", "Umutes a specific resource (e.g. an account)", exe.FlagSet)
|
||||||
|
|
||||||
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
exe.Var(&exe.accountName, "account-name", "The name of the account")
|
||||||
|
exe.StringVar(&exe.statusID, "status-id", "", "The ID of the status")
|
||||||
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
exe.StringVar(&exe.resourceType, "type", "", "The type of resource you want to action on (e.g. account, status)")
|
||||||
|
|
||||||
return &exe
|
return &exe
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
func (m *MuteExecutor) Execute() error {
|
func (m *MuteExecutor) Execute() error {
|
||||||
funcMap := map[string]func(*client.Client) error{
|
funcMap := map[string]func(*client.Client) error{
|
||||||
resourceAccount: m.muteAccount,
|
resourceAccount: m.muteAccount,
|
||||||
|
resourceStatus: m.muteStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
doFunc, ok := funcMap[m.resourceType]
|
doFunc, ok := funcMap[m.resourceType]
|
||||||
|
@ -43,3 +44,17 @@ func (m *MuteExecutor) muteAccount(gtsClient *client.Client) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MuteExecutor) muteStatus(gtsClient *client.Client) error {
|
||||||
|
if m.statusID == "" {
|
||||||
|
return FlagNotSetError{flagText: flagStatusID}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := gtsClient.MuteStatus(m.statusID); err != nil {
|
||||||
|
return fmt.Errorf("unable to mute the status: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
m.printer.PrintSuccess("Successfully muted the status.")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
func (m *UnmuteExecutor) Execute() error {
|
func (m *UnmuteExecutor) Execute() error {
|
||||||
funcMap := map[string]func(*client.Client) error{
|
funcMap := map[string]func(*client.Client) error{
|
||||||
resourceAccount: m.unmuteAccount,
|
resourceAccount: m.unmuteAccount,
|
||||||
|
resourceStatus: m.unmuteStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
doFunc, ok := funcMap[m.resourceType]
|
doFunc, ok := funcMap[m.resourceType]
|
||||||
|
@ -38,3 +39,17 @@ func (m *UnmuteExecutor) unmuteAccount(gtsClient *client.Client) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *UnmuteExecutor) unmuteStatus(gtsClient *client.Client) error {
|
||||||
|
if m.statusID == "" {
|
||||||
|
return FlagNotSetError{flagText: flagStatusID}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := gtsClient.UnmuteStatus(m.statusID); err != nil {
|
||||||
|
return fmt.Errorf("unable to unmute the status: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
m.printer.PrintSuccess("Successfully unmuted the status.")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ func (p Printer) PrintStatus(status model.Status, userAccountID string) {
|
||||||
builder.WriteString("\n" + p.fieldFormat("Boosted: ") + strconv.FormatBool(status.Reblogged))
|
builder.WriteString("\n" + p.fieldFormat("Boosted: ") + strconv.FormatBool(status.Reblogged))
|
||||||
builder.WriteString("\n" + p.fieldFormat("Liked: ") + strconv.FormatBool(status.Favourited))
|
builder.WriteString("\n" + p.fieldFormat("Liked: ") + strconv.FormatBool(status.Favourited))
|
||||||
builder.WriteString("\n" + p.fieldFormat("Bookmarked: ") + strconv.FormatBool(status.Bookmarked))
|
builder.WriteString("\n" + p.fieldFormat("Bookmarked: ") + strconv.FormatBool(status.Bookmarked))
|
||||||
|
builder.WriteString("\n" + p.fieldFormat("Muted: ") + strconv.FormatBool(status.Muted))
|
||||||
|
|
||||||
// Status visibility
|
// Status visibility
|
||||||
builder.WriteString("\n\n" + p.headerFormat("VISIBILITY:"))
|
builder.WriteString("\n\n" + p.headerFormat("VISIBILITY:"))
|
||||||
|
|
|
@ -316,6 +316,7 @@
|
||||||
{ "flag": "account-name" },
|
{ "flag": "account-name" },
|
||||||
{ "flag": "mute-duration" },
|
{ "flag": "mute-duration" },
|
||||||
{ "flag": "mute-notifications", "default": "false" },
|
{ "flag": "mute-notifications", "default": "false" },
|
||||||
|
{ "flag": "status-id", "fieldName": "statusID", "default": "" },
|
||||||
{ "flag": "type", "fieldName": "resourceType", "default": "" }
|
{ "flag": "type", "fieldName": "resourceType", "default": "" }
|
||||||
],
|
],
|
||||||
"summary": "Mutes a specific resource (e.g. an account)",
|
"summary": "Mutes a specific resource (e.g. an account)",
|
||||||
|
@ -408,6 +409,7 @@
|
||||||
"additionalFields": [],
|
"additionalFields": [],
|
||||||
"flags": [
|
"flags": [
|
||||||
{ "flag": "account-name" },
|
{ "flag": "account-name" },
|
||||||
|
{ "flag": "status-id", "fieldName": "statusID", "default": "" },
|
||||||
{ "flag": "type", "fieldName": "resourceType", "default": "" }
|
{ "flag": "type", "fieldName": "resourceType", "default": "" }
|
||||||
],
|
],
|
||||||
"summary": "Umutes a specific resource (e.g. an account)",
|
"summary": "Umutes a specific resource (e.g. an account)",
|
||||||
|
|
Loading…
Reference in a new issue