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
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

@ -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)")

@ -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)

Loading…
Cancel
Save