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
|
@ -38,18 +38,19 @@ func (g *Client) GetStatus(statusID string) (model.Status, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateStatusForm struct {
|
type CreateStatusForm struct {
|
||||||
Content string `json:"status"`
|
Content string `json:"status"`
|
||||||
InReplyTo string `json:"in_reply_to_id"`
|
InReplyTo string `json:"in_reply_to_id"`
|
||||||
Language string `json:"language"`
|
Language string `json:"language"`
|
||||||
SpoilerText string `json:"spoiler_text"`
|
SpoilerText string `json:"spoiler_text"`
|
||||||
Boostable bool `json:"boostable"`
|
Boostable bool `json:"boostable"`
|
||||||
Federated bool `json:"federated"`
|
Federated bool `json:"federated"`
|
||||||
Likeable bool `json:"likeable"`
|
Likeable bool `json:"likeable"`
|
||||||
Replyable bool `json:"replyable"`
|
Replyable bool `json:"replyable"`
|
||||||
Sensitive bool `json:"sensitive"`
|
Sensitive bool `json:"sensitive"`
|
||||||
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,12 +76,19 @@ 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:
|
||||||
return EmptyContentError{
|
if c.attachmentIDs.Empty() {
|
||||||
ResourceType: resourceStatus,
|
// TODO: revisit this error type
|
||||||
Hint: "please use --" + flagContent + " or --" + flagFromFile,
|
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()
|
preferences, err := gtsClient.GetUserPreferences()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("WARNING: Unable to get your posting preferences: %w", err)
|
fmt.Println("WARNING: Unable to get your posting preferences: %w", err)
|
||||||
|
@ -116,18 +123,23 @@ func (c *CreateExecutor) createStatus(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
form := client.CreateStatusForm{
|
form := client.CreateStatusForm{
|
||||||
Content: content,
|
Content: content,
|
||||||
ContentType: parsedContentType,
|
ContentType: parsedContentType,
|
||||||
Language: language,
|
Language: language,
|
||||||
SpoilerText: c.spoilerText,
|
SpoilerText: c.spoilerText,
|
||||||
Boostable: c.boostable,
|
Boostable: c.boostable,
|
||||||
Federated: c.federated,
|
Federated: c.federated,
|
||||||
InReplyTo: c.inReplyTo,
|
InReplyTo: c.inReplyTo,
|
||||||
Likeable: c.likeable,
|
Likeable: c.likeable,
|
||||||
Replyable: c.replyable,
|
Replyable: c.replyable,
|
||||||
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