setting media-description and media-focus is now optional when creating attachments
This commit is contained in:
parent
4472808f20
commit
5c50507bfc
1 changed files with 28 additions and 12 deletions
|
@ -244,24 +244,40 @@ func (c *CreateExecutor) createMediaAttachment(gtsClient *client.Client) error {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.mediaDescriptions.ExpectedLength(expectedNumValues) {
|
description := ""
|
||||||
return fmt.Errorf(
|
if !c.mediaDescriptions.Empty() {
|
||||||
"received an unexpected number of media descriptions: want %d",
|
if !c.mediaDescriptions.ExpectedLength(expectedNumValues) {
|
||||||
expectedNumValues,
|
return fmt.Errorf(
|
||||||
)
|
"received an unexpected number of media descriptions: want %d",
|
||||||
|
expectedNumValues,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
description, err = utilities.ReadContents(c.mediaDescriptions[0])
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"unable to read the contents from %s: %w",
|
||||||
|
c.mediaDescriptions[0],
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.mediaFocusValues.ExpectedLength(expectedNumValues) {
|
focus := ""
|
||||||
return fmt.Errorf(
|
if !c.mediaFocusValues.Empty() {
|
||||||
"received an unexpected number of media focus values: want %d",
|
if !c.mediaFocusValues.ExpectedLength(expectedNumValues) {
|
||||||
expectedNumValues,
|
return fmt.Errorf(
|
||||||
)
|
"received an unexpected number of media focus values: want %d",
|
||||||
|
expectedNumValues,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
focus = c.mediaFocusValues[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
attachment, err := gtsClient.CreateMediaAttachment(
|
attachment, err := gtsClient.CreateMediaAttachment(
|
||||||
c.mediaFiles[0],
|
c.mediaFiles[0],
|
||||||
c.mediaDescriptions[0],
|
description,
|
||||||
c.mediaFocusValues[0],
|
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