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"`
|
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 {
|
||||||
|
|
|
@ -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)
|
return fmt.Errorf("unable to get the status contents from %q: %w", c.fromFile, err)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
if c.attachmentIDs.Empty() {
|
||||||
|
// 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 c.addPoll && !c.attachmentIDs.Empty() {
|
||||||
|
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 {
|
||||||
|
@ -128,6 +135,11 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
||||||
Sensitive: sensitive,
|
Sensitive: sensitive,
|
||||||
Visibility: parsedVisibility,
|
Visibility: parsedVisibility,
|
||||||
Poll: nil,
|
Poll: nil,
|
||||||
|
AttachmentIDs: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
if !c.attachmentIDs.Empty() {
|
||||||
|
form.AttachmentIDs = c.attachmentIDs
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.addPoll {
|
if c.addPoll {
|
||||||
|
|
Loading…
Reference in a new issue