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,6 +244,8 @@ func (c *CreateExecutor) createMediaAttachment(gtsClient *client.Client) error {
|
|||
)
|
||||
}
|
||||
|
||||
description := ""
|
||||
if !c.mediaDescriptions.Empty() {
|
||||
if !c.mediaDescriptions.ExpectedLength(expectedNumValues) {
|
||||
return fmt.Errorf(
|
||||
"received an unexpected number of media descriptions: want %d",
|
||||
|
@ -251,17 +253,31 @@ func (c *CreateExecutor) createMediaAttachment(gtsClient *client.Client) error {
|
|||
)
|
||||
}
|
||||
|
||||
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],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
focus := ""
|
||||
if !c.mediaFocusValues.Empty() {
|
||||
if !c.mediaFocusValues.ExpectedLength(expectedNumValues) {
|
||||
return fmt.Errorf(
|
||||
"received an unexpected number of media focus values: want %d",
|
||||
expectedNumValues,
|
||||
)
|
||||
}
|
||||
focus = c.mediaFocusValues[0]
|
||||
}
|
||||
|
||||
attachment, err := gtsClient.CreateMediaAttachment(
|
||||
c.mediaFiles[0],
|
||||
c.mediaDescriptions[0],
|
||||
c.mediaFocusValues[0],
|
||||
description,
|
||||
focus,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create the media attachment: %w", err)
|
||||
|
|
Loading…
Reference in a new issue