From 8b8eb804febee14e0f254273b7610f19f5f99051 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 4 Jun 2024 16:00:33 +0200 Subject: [PATCH] Remove user from FailedAPICall + fix service --- LeStorage/Codables/FailedAPICall.swift | 6 +----- LeStorage/Services.swift | 2 +- LeStorage/Store.swift | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/LeStorage/Codables/FailedAPICall.swift b/LeStorage/Codables/FailedAPICall.swift index 98708b2..9674e17 100644 --- a/LeStorage/Codables/FailedAPICall.swift +++ b/LeStorage/Codables/FailedAPICall.swift @@ -17,9 +17,6 @@ class FailedAPICall: ModelObject, Storable { /// The creation date of the call var date: Date = Date() - /// The user having the issue - var user: String - /// The id of the API call var callId: String @@ -32,8 +29,7 @@ class FailedAPICall: ModelObject, Storable { /// The server error var error: String - init(user: String, callId: String, type: String, apiCall: String, error: String) { - self.user = user + init(callId: String, type: String, apiCall: String, error: String) { self.callId = callId self.type = type self.apiCall = apiCall diff --git a/LeStorage/Services.swift b/LeStorage/Services.swift index 216a8b9..ffa70d9 100644 --- a/LeStorage/Services.swift +++ b/LeStorage/Services.swift @@ -349,7 +349,7 @@ public class Services { /// - Parameters: /// - email: the email of the user public func forgotPassword(email: String) async throws { - var postRequest = try self._baseRequest(servicePath: "dj-rest-auth/password/reset/", method: .post) + var postRequest = try self._baseRequest(servicePath: "dj-rest-auth/password/reset/", method: .post, requiresToken: false) postRequest.httpBody = try jsonEncoder.encode(Email(email: email)) let response: Email = try await self._runRequest(postRequest) Logger.log("response = \(response)") diff --git a/LeStorage/Store.swift b/LeStorage/Store.swift index cbc5aa7..895c1db 100644 --- a/LeStorage/Store.swift +++ b/LeStorage/Store.swift @@ -282,8 +282,7 @@ public class Store { guard let failedAPICallsCollection = self._failedAPICallsCollection, let collection = self._collections[collectionName], - let apiCall = try? collection.apiCallById(apiCallId), - let userId = Store.main.userId else { + let apiCall = try? collection.apiCallById(apiCallId) else { return } @@ -291,7 +290,7 @@ public class Store { do { let string = try apiCall.jsonString() - let failedAPICall = FailedAPICall(user: userId, callId: apiCall.id, type: collectionName, apiCall: string, error: error) + let failedAPICall = FailedAPICall(callId: apiCall.id, type: collectionName, apiCall: string, error: error) try failedAPICallsCollection.addOrUpdate(instance: failedAPICall) } catch { Logger.error(error)