Skip to content

Commit e4cbcc2

Browse files
committed
feat:(AccountJob): Account info list
1 parent d32d68d commit e4cbcc2

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Infomaniak kDrive - Desktop
3+
Copyright (C) 2023-2025 Infomaniak Network SA
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
import Foundation
20+
import InfomaniakConcurrency
21+
import InfomaniakDI
22+
23+
public struct AccountJobs: Sendable {
24+
@LazyInjectService private var coherentCache: CoherentCacheProtocol
25+
@LazyInjectService private var queryFetcher: XPCQueryFetcherProtocol
26+
27+
public enum AccountJobsError: Error {
28+
case noReplyData
29+
case responseListNotFound
30+
}
31+
32+
public init() {}
33+
34+
public func accountInfoList() async throws -> [AccountInfoResponse] {
35+
IKLogger.data.log("Query for accountInfoList")
36+
let query = EmptyQuery()
37+
let request = await RequestMessage<EmptyQuery>(num: RequestNum.ACCOUNT_INFOLIST, body: query)
38+
39+
do {
40+
let decodedMessage = try await queryFetcher.query(request, responseType:
41+
CallbackMessage<AccountListResponse>.self)
42+
43+
guard let accountList = decodedMessage?.body.accountInfoList else {
44+
throw AccountJobsError.responseListNotFound
45+
}
46+
47+
// TODO: Bump cache
48+
49+
return accountList
50+
} catch XPCQueryFetcher.QueryError.noReplyData {
51+
throw AccountJobsError.noReplyData
52+
} catch {
53+
throw error
54+
}
55+
}
56+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Infomaniak kDrive - Desktop
3+
Copyright (C) 2023-2025 Infomaniak Network SA
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
public struct AccountInfoResponse: Codable, Sendable {
20+
let userDbId: Int32
21+
let dbId: Int32
22+
}
23+
24+
struct AccountListResponse: Codable, Sendable {
25+
let accountInfoList: [AccountInfoResponse]
26+
}

0 commit comments

Comments
 (0)