checkpoint
This commit is contained in:
parent
1debd1bbf7
commit
2e455fc9f8
2 changed files with 43 additions and 28 deletions
|
@ -50,6 +50,7 @@ type CreateStatusForm struct {
|
||||||
Poll *CreateStatusPollForm `json:"poll,omitempty"`
|
Poll *CreateStatusPollForm `json:"poll,omitempty"`
|
||||||
ContentType model.StatusContentType `json:"content_type"`
|
ContentType model.StatusContentType `json:"content_type"`
|
||||||
Visibility model.StatusVisibility `json:"visibility"`
|
Visibility model.StatusVisibility `json:"visibility"`
|
||||||
|
AttachmentIDs []string `json:"media_ids,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateStatusPollForm struct {
|
type CreateStatusPollForm struct {
|
||||||
|
|
|
@ -39,6 +39,7 @@ type CreateExecutor struct {
|
||||||
visibility string
|
visibility string
|
||||||
pollExpiresIn TimeDurationFlagValue
|
pollExpiresIn TimeDurationFlagValue
|
||||||
pollOptions MultiStringFlagValue
|
pollOptions MultiStringFlagValue
|
||||||
|
attachmentIDs MultiStringFlagValue
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCreateExecutor(printer *printer.Printer, config *config.Config, name, summary string) *CreateExecutor {
|
func NewCreateExecutor(printer *printer.Printer, config *config.Config, name, summary string) *CreateExecutor {
|
||||||
|
@ -74,6 +75,7 @@ func NewCreateExecutor(printer *printer.Printer, config *config.Config, name, su
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
createExe.Var(&createExe.attachmentIDs, flagAttachmentID, "Specify the ID of the media attachment to add to the status")
|
||||||
|
|
||||||
// Flags specifically for polls
|
// Flags specifically for polls
|
||||||
createExe.BoolVar(&createExe.addPoll, flagAddPoll, false, "Add a poll to the status")
|
createExe.BoolVar(&createExe.addPoll, flagAddPoll, false, "Add a poll to the status")
|
||||||
|
@ -161,11 +163,18 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
||||||
return fmt.Errorf("unable to get the status contents from %q: %w", c.fromFile, err)
|
return fmt.Errorf("unable to get the status contents from %q: %w", c.fromFile, err)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
if len(c.attachmentIDs) == 0 {
|
||||||
|
// TODO: revisit this error type
|
||||||
return EmptyContentError{
|
return EmptyContentError{
|
||||||
ResourceType: resourceStatus,
|
ResourceType: resourceStatus,
|
||||||
Hint: "please use --" + flagContent + " or --" + flagFromFile,
|
Hint: "please use --" + flagContent + " or --" + flagFromFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(c.attachmentIDs) > 0 && c.addPoll {
|
||||||
|
return fmt.Errorf("attaching media to a poll is not allowed")
|
||||||
|
}
|
||||||
|
|
||||||
preferences, err := gtsClient.GetUserPreferences()
|
preferences, err := gtsClient.GetUserPreferences()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -213,6 +222,11 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
||||||
Sensitive: sensitive,
|
Sensitive: sensitive,
|
||||||
Visibility: parsedVisibility,
|
Visibility: parsedVisibility,
|
||||||
Poll: nil,
|
Poll: nil,
|
||||||
|
AttachmentIDs: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(c.attachmentIDs) > 0 {
|
||||||
|
form.AttachmentIDs = c.attachmentIDs
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.addPoll {
|
if c.addPoll {
|
||||||
|
@ -246,7 +260,7 @@ func (c *CreateExecutor) createMediaAttachment(gtsClient *client.Client) error {
|
||||||
return FlagNotSetError{flagText: flagFromFile}
|
return FlagNotSetError{flagText: flagFromFile}
|
||||||
}
|
}
|
||||||
|
|
||||||
attachment, err := gtsClient.CreateMediaAttachment(c.fromFile, c.description, c.focus);
|
attachment, err := gtsClient.CreateMediaAttachment(c.fromFile, c.description, c.focus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to create the media attachment: %w", err)
|
return fmt.Errorf("unable to create the media attachment: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue