Skip to content

Commit

Permalink
media: fix handling of filename and captions
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed Feb 14, 2024
1 parent 4530ff3 commit b1e51db
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,24 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, us
portal.log.Errorfln("Failed to download matrix attachment: %v", err)
return nil, nil, "", errMediaDownloadFailed
}

var filename, caption string
if content.FileName == "" {
filename = content.Body
} else {
filename = content.FileName
caption = content.Body
}
fileUpload = &slack.FileUploadParameters{
Filename: content.Body,
Filename: filename,
Filetype: content.Info.MimeType,
Reader: bytes.NewReader(data),
Channels: []string{portal.Key.ChannelID},
ThreadTimestamp: threadTs,
}
if caption != "" {
fileUpload.InitialComment = caption
}
return nil, fileUpload, threadTs, nil
default:
return nil, nil, "", errUnknownMsgType
Expand Down

0 comments on commit b1e51db

Please sign in to comment.