Skip to content

Commit

Permalink
[bugfix] Fix Toot CLI media attachments not working properly (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmethurst authored Jul 22, 2022
1 parent 7b72ba4 commit 7ca5bac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 11 additions & 0 deletions docs/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ definitions:
description: |-
Array of Attachment ids to be attached as media.
If provided, status becomes optional, and poll cannot be used.
If the status is being submitted as a form, the key is 'media_ids[]',
but if it's json or xml, the key is 'media_ids'.
in: formData
items:
type: string
Expand Down Expand Up @@ -422,6 +426,10 @@ definitions:
description: |-
Array of Attachment ids to be attached as media.
If provided, status becomes optional, and poll cannot be used.
If the status is being submitted as a form, the key is 'media_ids[]',
but if it's json or xml, the key is 'media_ids'.
in: formData
items:
type: string
Expand Down Expand Up @@ -3531,6 +3539,9 @@ paths:
- description: |-
Array of Attachment ids to be attached as media.
If provided, status becomes optional, and poll cannot be used.
If the status is being submitted as a form, the key is 'media_ids[]',
but if it's json or xml, the key is 'media_ids'.
in: formData
items:
type: string
Expand Down
2 changes: 1 addition & 1 deletion internal/api/client/status/statuscreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (suite *StatusCreateTestSuite) TestAttachNewMediaSuccess() {
ctx.Request.Header.Set("accept", "application/json")
ctx.Request.Form = url.Values{
"status": {"here's an image attachment"},
"media_ids": {attachment.ID},
"media_ids[]": {attachment.ID},
}
suite.statusModule.StatusCreatePOSTHandler(ctx)

Expand Down
6 changes: 5 additions & 1 deletion internal/api/model/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ type StatusCreateRequest struct {
Status string `form:"status" json:"status" xml:"status"`
// Array of Attachment ids to be attached as media.
// If provided, status becomes optional, and poll cannot be used.
//
// If the status is being submitted as a form, the key is 'media_ids[]',
// but if it's json or xml, the key is 'media_ids'.
//
// in: formData
MediaIDs []string `form:"media_ids" json:"media_ids" xml:"media_ids"`
MediaIDs []string `form:"media_ids[]" json:"media_ids" xml:"media_ids"`
// Poll to include with this status.
// swagger:ignore
Poll *PollRequest `form:"poll" json:"poll" xml:"poll"`
Expand Down

0 comments on commit 7ca5bac

Please sign in to comment.