Fix internal call values
parent: tbd commit: 8e8ab90
1 | use Arc; |
2 | |
3 | use |
4 | , | UserAuthenticationToken
5 | , |
6 | |
7 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
8 | , |
9 | , | ObjectBackend
10 | |
11 | Commit, DefaultBranch, Description, LatestCommit, Repository, RepositoryBranch, |
12 | RepositoryBranchesRequest, RepositoryCommitBeforeRequest, RepositoryCommitFromIdRequest, |
13 | RepositoryDiff, RepositoryDiffPatchRequest, RepositoryDiffRequest, RepositoryFile, |
14 | RepositoryFileFromIdRequest, RepositoryFileFromPathRequest, RepositoryFileInspectRequest, |
15 | RepositoryInfoRequest, RepositoryLastCommitOfFileRequest, RepositoryStatistics, |
16 | RepositoryStatisticsRequest, RepositorySummary, RepositoryView, Visibility, |
17 | , |
18 | , |
19 | ; |
20 | use ; |
21 | |
22 | use DatabaseBackend; |
23 | |
24 | pub async |
25 | object: User, |
26 | _operation: UserRepositoriesRequest, |
27 | state: DatabaseBackend, |
28 | _operation_state: StackOperationState, |
29 | requester: , |
30 | |
31 | let object = object.clone; |
32 | |
33 | let mut user_backend = state.user_backend.lock .await; |
34 | let repositories_response = user_backend |
35 | .repositories_for_user |
36 | .await |
37 | .as_internal_error?; |
38 | drop; |
39 | let mut repositories_backend = state.repository_backend.lock .await; |
40 | |
41 | let mut repositories = vec!; |
42 | |
43 | for repository in repositories_response |
44 | if repositories_backend |
45 | .exists |
46 | .await |
47 | .as_internal_error? |
48 | |
49 | repositories.push; |
50 | |
51 | |
52 | |
53 | Ok |
54 | |
55 | |
56 | pub async |
57 | object: Repository, |
58 | operation: RepositoryInfoRequest, |
59 | state: DatabaseBackend, |
60 | operation_state: StackOperationState, |
61 | backend: , |
62 | requester: , |
63 | |
64 | info!; |
65 | let mut object = backend |
66 | . |
67 | .await |
68 | .unwrap; |
69 | let mut repository_backend = state.repository_backend.lock .await; |
70 | let tree = repository_backend |
71 | .repository_file_inspect |
72 | &requester, |
73 | object.object, |
74 | &RepositoryFileInspectRequest |
75 | extra_metadata: operation.extra_metadata, |
76 | path: operation.path.clone, |
77 | rev: operation.rev.clone, |
78 | , |
79 | |
80 | .await |
81 | .as_internal_error?; |
82 | |
83 | let statistics = repository_backend |
84 | .repository_get_statistics |
85 | &requester, |
86 | object.object, |
87 | &RepositoryStatisticsRequest |
88 | rev: operation.rev.clone, |
89 | , |
90 | |
91 | .await |
92 | .as_internal_error?; |
93 | drop; |
94 | |
95 | let info = RepositoryView |
96 | name: object.object .name.clone, |
97 | owner: object.object .owner.clone, |
98 | description: object. .await.ok, |
99 | visibility: object |
100 | . |
101 | .await |
102 | .as_internal_error?, |
103 | default_branch: object |
104 | . |
105 | .await |
106 | .as_internal_error?, |
107 | // TODO: Can't be a simple get function, this needs to be returned alongside the tree as this differs depending on the rev and path. |
108 | latest_commit: object. .await.ok, |
109 | stats: statistics, |
110 | tree_rev: operation.rev.clone, |
111 | tree, |
112 | ; |
113 | |
114 | Ok |
115 | |
116 | |
117 | pub async |
118 | object: Repository, |
119 | operation: RepositoryStatisticsRequest, |
120 | state: DatabaseBackend, |
121 | operation_state: StackOperationState, |
122 | backend: , |
123 | requester: , |
124 | |
125 | let object = backend |
126 | . |
127 | .await |
128 | .unwrap; |
129 | |
130 | let mut repository_backend = state.repository_backend.lock .await; |
131 | let statistics = repository_backend |
132 | .repository_get_statistics |
133 | &requester, |
134 | object.object, |
135 | &RepositoryStatisticsRequest |
136 | rev: operation.rev.clone, |
137 | , |
138 | |
139 | .await |
140 | .as_internal_error?; |
141 | drop; |
142 | |
143 | Ok |
144 | |
145 | |
146 | pub async |
147 | object: Repository, |
148 | operation: RepositoryBranchesRequest, |
149 | state: DatabaseBackend, |
150 | operation_state: StackOperationState, |
151 | backend: , |
152 | requester: , |
153 | |
154 | let object = backend |
155 | . |
156 | .await |
157 | .unwrap; |
158 | |
159 | let mut repository_backend = state.repository_backend.lock .await; |
160 | let branches = repository_backend |
161 | .repository_get_branches |
162 | .await |
163 | .as_internal_error?; |
164 | drop; |
165 | |
166 | Ok |
167 | |
168 | |
169 | pub async |
170 | object: Repository, |
171 | operation: RepositoryFileFromIdRequest, |
172 | state: DatabaseBackend, |
173 | operation_state: StackOperationState, |
174 | backend: , |
175 | |
176 | requester: , |
177 | |
178 | let object = backend |
179 | . |
180 | .await |
181 | .unwrap; |
182 | |
183 | let mut repository_backend = state.repository_backend.lock .await; |
184 | let file = repository_backend |
185 | .repository_file_from_id |
186 | &requester, |
187 | object.object, |
188 | &RepositoryFileFromIdRequest, |
189 | |
190 | .await |
191 | .as_internal_error?; |
192 | drop; |
193 | |
194 | Ok |
195 | |
196 | |
197 | pub async |
198 | object: Repository, |
199 | operation: RepositoryFileFromPathRequest, |
200 | state: DatabaseBackend, |
201 | operation_state: StackOperationState, |
202 | backend: , |
203 | requester: , |
204 | |
205 | let object = backend |
206 | . |
207 | .await |
208 | .unwrap; |
209 | |
210 | let mut repository_backend = state.repository_backend.lock .await; |
211 | let file = repository_backend |
212 | .repository_file_from_path |
213 | &requester, |
214 | object.object, |
215 | &RepositoryFileFromPathRequest |
216 | rev: operation.rev.clone, |
217 | path: operation.path.clone, |
218 | , |
219 | |
220 | .await |
221 | .as_internal_error?; |
222 | drop; |
223 | |
224 | Ok |
225 | |
226 | |
227 | pub async |
228 | object: Repository, |
229 | operation: RepositoryLastCommitOfFileRequest, |
230 | state: DatabaseBackend, |
231 | operation_state: StackOperationState, |
232 | backend: , |
233 | requester: , |
234 | |
235 | let object = backend |
236 | . |
237 | .await |
238 | .unwrap; |
239 | |
240 | let mut repository_backend = state.repository_backend.lock .await; |
241 | let commit = repository_backend |
242 | .repository_last_commit_of_file |
243 | &requester, |
244 | object.object, |
245 | &RepositoryLastCommitOfFileRequest |
246 | start_commit: operation.start_commit.clone, |
247 | path: operation.path.clone, |
248 | , |
249 | |
250 | .await |
251 | .as_internal_error?; |
252 | drop; |
253 | |
254 | Ok |
255 | |
256 | |
257 | pub async |
258 | object: Repository, |
259 | operation: RepositoryCommitFromIdRequest, |
260 | state: DatabaseBackend, |
261 | operation_state: StackOperationState, |
262 | backend: , |
263 | requester: , |
264 | |
265 | let object = backend |
266 | . |
267 | .await |
268 | .unwrap; |
269 | |
270 | let mut repository_backend = state.repository_backend.lock .await; |
271 | let commit = repository_backend |
272 | .repository_commit_from_id |
273 | &requester, |
274 | object.object, |
275 | &RepositoryCommitFromIdRequest, |
276 | |
277 | .await |
278 | .as_internal_error?; |
279 | drop; |
280 | |
281 | Ok |
282 | |
283 | |
284 | pub async |
285 | object: Repository, |
286 | operation: RepositoryDiffRequest, |
287 | state: DatabaseBackend, |
288 | operation_state: StackOperationState, |
289 | backend: , |
290 | requester: , |
291 | |
292 | let object = backend |
293 | . |
294 | .await |
295 | .unwrap; |
296 | |
297 | let mut repository_backend = state.repository_backend.lock .await; |
298 | let diff = repository_backend |
299 | .repository_diff |
300 | .await |
301 | .as_internal_error?; |
302 | drop; |
303 | |
304 | Ok |
305 | |
306 | |
307 | pub async |
308 | object: Repository, |
309 | operation: RepositoryDiffPatchRequest, |
310 | state: DatabaseBackend, |
311 | operation_state: StackOperationState, |
312 | backend: , |
313 | requester: , |
314 | |
315 | let object = backend |
316 | . |
317 | .await |
318 | .unwrap; |
319 | |
320 | let mut repository_backend = state.repository_backend.lock .await; |
321 | let patch = repository_backend |
322 | .repository_diff_patch |
323 | .await |
324 | .as_internal_error?; |
325 | drop; |
326 | |
327 | Ok |
328 | |
329 | |
330 | pub async |
331 | object: Repository, |
332 | operation: RepositoryCommitBeforeRequest, |
333 | state: DatabaseBackend, |
334 | operation_state: StackOperationState, |
335 | backend: , |
336 | requester: , |
337 | |
338 | let object = backend |
339 | . |
340 | .await |
341 | .unwrap; |
342 | |
343 | let mut repository_backend = state.repository_backend.lock .await; |
344 | let file = repository_backend |
345 | .repository_commit_before |
346 | .await |
347 | .as_internal_error?; |
348 | drop; |
349 | |
350 | Ok |
351 | |
352 | |
353 | pub async |
354 | object: Instance, |
355 | operation: AuthenticationTokenRequest, |
356 | state: DatabaseBackend, |
357 | _operation_state: StackOperationState, |
358 | // Authorizes the request for SAME-INSTANCE |
359 | // _authorized_instance: AuthorizedInstance, |
360 | |
361 | let mut backend = state.user_backend.lock .await; |
362 | |
363 | backend |
364 | .login |
365 | .await |
366 | .as_internal_error |
367 | |
368 | |
369 | pub async |
370 | _object: Instance, |
371 | operation: RegisterAccountRequest, |
372 | state: DatabaseBackend, |
373 | _operation_state: StackOperationState, // Authorizes the request for SAME-INSTANCE |
374 | // _authorized_instance: AuthorizedInstance, |
375 | |
376 | let mut backend = state.user_backend.lock .await; |
377 | |
378 | backend |
379 | .register |
380 | .await |
381 | .as_internal_error |
382 | |
383 | |
384 | pub async |
385 | _object: Instance, |
386 | operation: RepositoryCreateRequest, |
387 | state: DatabaseBackend, |
388 | _operation_state: StackOperationState, |
389 | requester: AuthenticatedUser, |
390 | // Authorizes the request for SAME-INSTANCE |
391 | // _authorized_instance: AuthorizedInstance, |
392 | |
393 | let mut backend = state.repository_backend.lock .await; |
394 | |
395 | backend |
396 | .create_repository |
397 | .await |
398 | .as_internal_error |
399 | |
400 | |
401 | pub async |
402 | _repository: Repository, |
403 | _state: DatabaseBackend, |
404 | _operation_state: StackOperationState, |
405 | |
406 | Ok |
407 | |
408 |