diff --git a/SignalServiceKit/src/Loki/API/LokiFileServerProxy.swift b/SignalServiceKit/src/Loki/API/LokiFileServerProxy.swift index 02114eed8..0b1e3cc0a 100644 --- a/SignalServiceKit/src/Loki/API/LokiFileServerProxy.swift +++ b/SignalServiceKit/src/Loki/API/LokiFileServerProxy.swift @@ -23,7 +23,7 @@ internal class LokiFileServerProxy : LokiHTTPClient { switch self { case .symmetricKeyGenerationFailed: return "Couldn't generate symmetric key." case .endpointParsingFailed: return "Couldn't parse endpoint." - case .proxyResponseParsingFailed: return "Couldn't parse proxy response." + case .proxyResponseParsingFailed: return "Couldn't parse file server proxy response." case .fileServerHTTPError(let httpStatusCode, let message): return "File server returned \(httpStatusCode) with description: \(message ?? "no description provided.")." } } @@ -109,6 +109,7 @@ internal class LokiFileServerProxy : LokiHTTPClient { let isSuccess = (200..<300).contains(statusCode) guard isSuccess else { throw HTTPError.networkError(code: statusCode, response: nil, underlyingError: Error.fileServerHTTPError(code: statusCode, message: nil)) } let uncheckedJSONAsData = try DiffieHellman.decrypt(cipherText, using: symmetricKey) + if uncheckedJSONAsData.isEmpty { return () } let uncheckedJSON = try? JSONSerialization.jsonObject(with: uncheckedJSONAsData, options: .allowFragments) as? JSON guard let json = uncheckedJSON else { throw HTTPError.networkError(code: -1, response: nil, underlyingError: Error.proxyResponseParsingFailed) } return json diff --git a/SignalServiceKit/src/Loki/API/LokiRSSFeedProxy.swift b/SignalServiceKit/src/Loki/API/LokiRSSFeedProxy.swift index 12a9732b0..78df64c27 100644 --- a/SignalServiceKit/src/Loki/API/LokiRSSFeedProxy.swift +++ b/SignalServiceKit/src/Loki/API/LokiRSSFeedProxy.swift @@ -7,7 +7,7 @@ public enum LokiRSSFeedProxy { public var errorDescription: String? { switch self { - case .proxyResponseParsingFailed: return "Couldn't parse proxy response." + case .proxyResponseParsingFailed: return "Couldn't parse RSS feed proxy response." } } } diff --git a/SignalServiceKit/src/Loki/API/LokiSnodeProxy.swift b/SignalServiceKit/src/Loki/API/LokiSnodeProxy.swift index d23328ced..3898e36ed 100644 --- a/SignalServiceKit/src/Loki/API/LokiSnodeProxy.swift +++ b/SignalServiceKit/src/Loki/API/LokiSnodeProxy.swift @@ -15,7 +15,7 @@ internal class LokiSnodeProxy : LokiHTTPClient { switch self { case .targetPublicKeySetMissing: return "Missing target public key set." case .symmetricKeyGenerationFailed: return "Couldn't generate symmetric key." - case .proxyResponseParsingFailed: return "Couldn't parse proxy response." + case .proxyResponseParsingFailed: return "Couldn't parse snode proxy response." case .targetSnodeHTTPError(let httpStatusCode, let message): return "Target snode returned error \(httpStatusCode) with description: \(message ?? "no description provided.")." } }