force jpeg format for avatar download in NSE

CDN may serve WebP by default which INImage doesn't reliably handle.
Append @jpeg to the URL to request JPEG format instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-04-22 11:37:30 +03:00
parent 7477eebe00
commit 610af7a29e
+9 -1
View File
@@ -118,11 +118,19 @@ class NotificationService: UNNotificationServiceExtension {
}
func downloadAvatarImage(from urlString: String) -> INImage? {
let thumbnailUrlString = urlString.replacingOccurrences(
var thumbnailUrlString = urlString.replacingOccurrences(
of: "/img/avatar/",
with: "/img/avatar_thumbnail/"
)
// CDN URLs may end with @webp or no extension (which defaults to webp).
// INImage doesn't reliably handle WebP, so force JPEG.
if let atRange = thumbnailUrlString.range(of: "@", options: .backwards) {
thumbnailUrlString = String(thumbnailUrlString[..<atRange.lowerBound]) + "@jpeg"
} else {
thumbnailUrlString += "@jpeg"
}
guard let url = URL(string: thumbnailUrlString) else { return nil }
var request = URLRequest(url: url)