Remove user from FailedAPICall + fix service

multistore
Laurent 1 year ago
parent e965e72e9a
commit 8b8eb804fe
  1. 6
      LeStorage/Codables/FailedAPICall.swift
  2. 2
      LeStorage/Services.swift
  3. 5
      LeStorage/Store.swift

@ -17,9 +17,6 @@ class FailedAPICall: ModelObject, Storable {
/// The creation date of the call /// The creation date of the call
var date: Date = Date() var date: Date = Date()
/// The user having the issue
var user: String
/// The id of the API call /// The id of the API call
var callId: String var callId: String
@ -32,8 +29,7 @@ class FailedAPICall: ModelObject, Storable {
/// The server error /// The server error
var error: String var error: String
init(user: String, callId: String, type: String, apiCall: String, error: String) { init(callId: String, type: String, apiCall: String, error: String) {
self.user = user
self.callId = callId self.callId = callId
self.type = type self.type = type
self.apiCall = apiCall self.apiCall = apiCall

@ -349,7 +349,7 @@ public class Services {
/// - Parameters: /// - Parameters:
/// - email: the email of the user /// - email: the email of the user
public func forgotPassword(email: String) async throws { 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)) postRequest.httpBody = try jsonEncoder.encode(Email(email: email))
let response: Email = try await self._runRequest(postRequest) let response: Email = try await self._runRequest(postRequest)
Logger.log("response = \(response)") Logger.log("response = \(response)")

@ -282,8 +282,7 @@ public class Store {
guard let failedAPICallsCollection = self._failedAPICallsCollection, guard let failedAPICallsCollection = self._failedAPICallsCollection,
let collection = self._collections[collectionName], let collection = self._collections[collectionName],
let apiCall = try? collection.apiCallById(apiCallId), let apiCall = try? collection.apiCallById(apiCallId) else {
let userId = Store.main.userId else {
return return
} }
@ -291,7 +290,7 @@ public class Store {
do { do {
let string = try apiCall.jsonString() 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) try failedAPICallsCollection.addOrUpdate(instance: failedAPICall)
} catch { } catch {
Logger.error(error) Logger.error(error)

Loading…
Cancel
Save