diff --git a/Mlem/API/APIClient/APIClient.swift b/Mlem/API/APIClient/APIClient.swift index 6ca59cc29..c7eac2019 100644 --- a/Mlem/API/APIClient/APIClient.swift +++ b/Mlem/API/APIClient/APIClient.swift @@ -141,6 +141,10 @@ class APIClient { defintion.headers.forEach { header in urlRequest.setValue(header.value, forHTTPHeaderField: header.key) } + + if case let .authenticated(_, token) = session { + urlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") + } if defintion as? any APIGetRequest != nil { urlRequest.httpMethod = "GET" diff --git a/Mlem/API/Models/Person/APIPersonAggregates.swift b/Mlem/API/Models/Person/APIPersonAggregates.swift index 74f40ed7a..4903f4b3e 100644 --- a/Mlem/API/Models/Person/APIPersonAggregates.swift +++ b/Mlem/API/Models/Person/APIPersonAggregates.swift @@ -12,7 +12,7 @@ struct APIPersonAggregates: Decodable { let id: Int let personId: Int let postCount: Int - let postScore: Int + let postScore: Int? let commentCount: Int - let commentScore: Int + let commentScore: Int? } diff --git a/Mlem/API/Requests/Post/GetPosts.swift b/Mlem/API/Requests/Post/GetPosts.swift index 7fe3019ce..8c6618a84 100644 --- a/Mlem/API/Requests/Post/GetPosts.swift +++ b/Mlem/API/Requests/Post/GetPosts.swift @@ -14,29 +14,6 @@ struct GetPostsRequest: APIGetRequest { let instanceURL: URL let path = "post/list" let queryItems: [URLQueryItem] - - init( - account: SavedAccount, // TODO: needs to move to a session based call... - communityId: Int?, - page: Int, - sort: PostSortType?, - type: FeedType, - limit: Int? = nil, - savedOnly: Bool? = nil, - communityName: String? = nil - ) { - self.instanceURL = account.instanceLink - self.queryItems = [ - .init(name: "auth", value: account.accessToken), - .init(name: "page", value: "\(page)"), - .init(name: "type_", value: type.rawValue), - .init(name: "sort", value: sort.map(\.rawValue)), - .init(name: "community_id", value: communityId.map(String.init)), - .init(name: "community_name", value: communityName), - .init(name: "limit", value: limit.map(String.init)), - .init(name: "saved_only", value: savedOnly.map(String.init)) - ] - } init( session: APISession,