checkpoint: can now create statuses with media attachments
This commit is contained in:
parent
f3a5887cb9
commit
795e344198
2 changed files with 40 additions and 27 deletions
|
@ -50,6 +50,7 @@ type CreateStatusForm struct {
|
|||
Poll *CreateStatusPollForm `json:"poll,omitempty"`
|
||||
ContentType model.StatusContentType `json:"content_type"`
|
||||
Visibility model.StatusVisibility `json:"visibility"`
|
||||
AttachmentIDs []string `json:"media_ids,omitempty"`
|
||||
}
|
||||
|
||||
type CreateStatusPollForm struct {
|
||||
|
|
|
@ -76,11 +76,18 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
|||
return fmt.Errorf("unable to get the status contents from %q: %w", c.fromFile, err)
|
||||
}
|
||||
default:
|
||||
if c.attachmentIDs.Empty() {
|
||||
// TODO: revisit this error type
|
||||
return EmptyContentError{
|
||||
ResourceType: resourceStatus,
|
||||
Hint: "please use --" + flagContent + " or --" + flagFromFile,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if c.addPoll && !c.attachmentIDs.Empty() {
|
||||
return fmt.Errorf("attaching media to a poll is not allowed")
|
||||
}
|
||||
|
||||
preferences, err := gtsClient.GetUserPreferences()
|
||||
if err != nil {
|
||||
|
@ -128,6 +135,11 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
|||
Sensitive: sensitive,
|
||||
Visibility: parsedVisibility,
|
||||
Poll: nil,
|
||||
AttachmentIDs: nil,
|
||||
}
|
||||
|
||||
if !c.attachmentIDs.Empty() {
|
||||
form.AttachmentIDs = c.attachmentIDs
|
||||
}
|
||||
|
||||
if c.addPoll {
|
||||
|
|
Loading…
Reference in a new issue