Fix image extension. fix #635

This commit is contained in:
Karlatemp 2020-12-01 22:40:19 +08:00
parent 6cfd602570
commit d1bd88c001
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8
2 changed files with 5 additions and 2 deletions

View File

@ -87,7 +87,7 @@ public class ExternalImage internal constructor(
return "ExternalImage(${generateUUID(md5)})"
}
internal fun calculateImageResourceId(): String = generateImageId(md5)
internal fun calculateImageResourceId(): String = """{${generateUUID(md5)}}.$formatName"""
private fun String.detectFormatName(): String = when {
startsWith("FFD8") -> "jpg"

View File

@ -26,7 +26,10 @@ internal class OnlineGroupImageImpl(
internal val delegate: ImMsgBody.CustomFace
) : @Suppress("DEPRECATION")
OnlineGroupImage() {
override val imageId: String = ExternalImage.generateImageId(delegate.md5)
override val imageId: String = delegate.filePath.takeIf {
GROUP_IMAGE_ID_REGEX.matches(it)
} ?: ExternalImage.generateImageId(delegate.md5)
override val originUrl: String
get() = if (delegate.origUrl.isBlank()) {
"http://gchat.qpic.cn/gchatpic_new/0/0-0-${