Store mime type for reuploaded files

This commit is contained in:
Tulir Asokan
2023-01-28 13:11:35 +02:00
parent 448a48af11
commit 75fafae82f
4 changed files with 20 additions and 13 deletions

View File

@@ -76,8 +76,9 @@ func (br *DiscordBridge) uploadMatrixAttachment(intent *appservice.IntentAPI, da
dbFile.URL = url
dbFile.ID = attachmentID
dbFile.Size = len(data)
dbFile.MimeType = mimetype.Detect(data).String()
if mime == "" {
mime = mimetype.Detect(data).String()
mime = dbFile.MimeType
}
if strings.HasPrefix(mime, "image/") {
cfg, _, _ := image.DecodeConfig(bytes.NewReader(data))