This commit fixes GIF uploads and improves GIF support: - MediaPicker will now skip location data removal processing, as it is not needed on GIF images and causes them to be converted to JPEG images - The uploader now sets more accurate MIME types on the upload request Issue Repro ----------- Device: iPhone 13 Mini iOS: 17.4.1 Damus: `ada99418f6fcdb1354bc5c1c3f3cc3b4db994ce6` Steps: 1. Download a GIF from GIPHY to the iOS photo gallery 2. Upload that and attach into a post in Damus 3. Check if GIF is animated. Results: GIF is not animated. Issue is reproduced. Testing ------- PASS Device: iPhone 13 Mini iOS: 17.4.1 Damus: this commit Steps: 1. Create a new post 2. Upload the same GIF as the repro and post 3. Make sure GIF is animated. PASS 4. Create a new post 5. Upload a new GIF image (that has never been uploaded by the user on the app) and post 6. Make sure the GIF is animated on the post. PASS 7. Make sure that JPEGs can still be successfully uploaded. PASS 8. Make sure that MP4s can be uploaded. 9. Make a new post that contains 1 JPEG, 1 MP4 file, and 2 GIF files. Make sure they are all uploaded correctly and all GIF files are animated. PASS Closes: https://github.com/damus-io/damus/issues/2157 Changelog-Fixed: Fix broken GIF uploads Signed-off-by: Daniel D’Aquino <daniel@daquino.me> Reviewed-by: William Casarin <jb55@jb55.com>
60 lines
1.9 KiB
Swift
60 lines
1.9 KiB
Swift
//
|
|
// Log.swift
|
|
// damus
|
|
//
|
|
// Created by William Casarin on 2023-08-02.
|
|
//
|
|
|
|
import Foundation
|
|
import os.log
|
|
|
|
|
|
enum LogCategory: String {
|
|
case nav
|
|
case render
|
|
case storage
|
|
case push_notifications
|
|
case damus_purple
|
|
case image_uploading
|
|
}
|
|
|
|
/// Damus structured logger
|
|
class Log {
|
|
static private func logger(for logcat: LogCategory) -> OSLog {
|
|
return OSLog(subsystem: "com.jb55.damus", category: logcat.rawValue)
|
|
}
|
|
|
|
/// dumb workaround, swift can't forward C vararsg
|
|
static private func log(_ message: StaticString, for log: OSLog, type: OSLogType, _ args: [CVarArg]) {
|
|
switch args.count {
|
|
case 0:
|
|
os_log(message, log: log, type: type)
|
|
case 1:
|
|
os_log(message, log: log, type: type, args[0])
|
|
case 2:
|
|
os_log(message, log: log, type: type, args[0], args[1])
|
|
case 3:
|
|
os_log(message, log: log, type: type, args[0], args[1], args[2])
|
|
case 4:
|
|
os_log(message, log: log, type: type, args[0], args[1], args[2], args[3])
|
|
case 5:
|
|
os_log(message, log: log, type: type, args[0], args[1], args[2], args[3], args[4])
|
|
default:
|
|
os_log("Too many variadic params were sent to the logger so we tossed them!", log: log, type: .error)
|
|
os_log(message, log: log, type: type)
|
|
}
|
|
}
|
|
|
|
static func info(_ msg: StaticString, for logcat: LogCategory, _ args: CVarArg...) {
|
|
Log.log(msg, for: logger(for: logcat), type: OSLogType.info, args)
|
|
}
|
|
|
|
static func debug(_ msg: StaticString, for logcat: LogCategory, _ args: CVarArg...) {
|
|
Log.log(msg, for: logger(for: logcat), type: OSLogType.debug, args)
|
|
}
|
|
|
|
static func error(_ msg: StaticString, for logcat: LogCategory, _ args: CVarArg...) {
|
|
Log.log(msg, for: logger(for: logcat), type: OSLogType.error, args)
|
|
}
|
|
}
|