Add authentication operations
parent: tbd commit: c27b4f3
1 | use Error; |
2 | |
3 | use ; |
4 | use |
5 | , | UserAuthenticationToken
6 | , |
7 | , |
8 | , | ObjectBackend
9 | |
10 | Commit, DefaultBranch, Description, LatestCommit, Repository, |
11 | RepositoryCommitBeforeRequest, RepositoryDiff, RepositoryDiffRequest, RepositoryFile, |
12 | RepositoryFileFromIdRequest, RepositoryFileInspectRequest, RepositoryInfoRequest, |
13 | RepositorySummary, RepositoryView, Visibility, |
14 | , |
15 | , |
16 | , |
17 | , |
18 | ; |
19 | use ; |
20 | |
21 | use DatabaseBackend; |
22 | |
23 | |
24 | object: &User, |
25 | _operation: UserRepositoriesRequest, |
26 | state: DatabaseBackend, |
27 | |
28 | let object = object.clone; |
29 | |
30 | async move |
31 | let mut user_backend = state.user_backend.lock .await; |
32 | let repositories = user_backend |
33 | .repositories_for_user |
34 | .await |
35 | .map_err?; |
36 | |
37 | Ok |
38 | |
39 | .boxed |
40 | |
41 | |
42 | |
43 | object: &User, |
44 | operation: , |
45 | state: DatabaseBackend, |
46 | |
47 | let object = object.clone; |
48 | |
49 | async move |
50 | let mut user_backend = state.user_backend.lock .await; |
51 | let value = user_backend |
52 | .get_value |
53 | .await |
54 | .map_err?; |
55 | |
56 | Ok |
57 | |
58 | .boxed |
59 | |
60 | |
61 | |
62 | object: &User, |
63 | operation: , |
64 | state: DatabaseBackend, |
65 | |
66 | let object = object.clone; |
67 | |
68 | async move |
69 | let mut user_backend = state.user_backend.lock .await; |
70 | let value = user_backend |
71 | .get_setting |
72 | .await |
73 | .map_err?; |
74 | |
75 | Ok |
76 | |
77 | .boxed |
78 | |
79 | |
80 | |
81 | object: &User, |
82 | operation: , |
83 | state: DatabaseBackend, |
84 | |
85 | let object = object.clone; |
86 | |
87 | async move |
88 | let mut user_backend = state.user_backend.lock .await; |
89 | let value = user_backend |
90 | .write_setting |
91 | .await |
92 | .map_err?; |
93 | |
94 | Ok |
95 | |
96 | .boxed |
97 | |
98 | |
99 | |
100 | object: &Repository, |
101 | operation: RepositoryInfoRequest, |
102 | state: DatabaseBackend, |
103 | operation_state: StackOperationState, |
104 | backend: BackendWrapper, |
105 | |
106 | let object = object.clone; |
107 | |
108 | async move |
109 | let mut object = backend |
110 | . |
111 | .await |
112 | .unwrap; |
113 | |
114 | let mut repository_backend = state.repository_backend.lock .await; |
115 | let tree = repository_backend |
116 | .repository_file_inspect |
117 | None, |
118 | object.object, |
119 | &RepositoryFileInspectRequest |
120 | extra_metadata: operation.extra_metadata, |
121 | path: operation.path, |
122 | rev: operation.rev.clone, |
123 | , |
124 | |
125 | .await |
126 | .map_err?; |
127 | drop; |
128 | |
129 | let info = RepositoryView |
130 | name: object.object .name.clone, |
131 | owner: object.object .owner.clone, |
132 | description: object. .await.ok, |
133 | visibility: object |
134 | . |
135 | .await |
136 | .map_err?, |
137 | default_branch: object |
138 | . |
139 | .await |
140 | .map_err?, |
141 | // 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. |
142 | latest_commit: object. .await.ok, |
143 | tree_rev: operation.rev, |
144 | tree, |
145 | ; |
146 | |
147 | Ok |
148 | |
149 | .boxed |
150 | |
151 | |
152 | |
153 | object: &Repository, |
154 | operation: RepositoryFileFromIdRequest, |
155 | state: DatabaseBackend, |
156 | operation_state: StackOperationState, |
157 | backend: BackendWrapper, |
158 | |
159 | let object = object.clone; |
160 | |
161 | async move |
162 | let object = backend |
163 | . |
164 | .await |
165 | .unwrap; |
166 | |
167 | let mut repository_backend = state.repository_backend.lock .await; |
168 | let file = repository_backend |
169 | .repository_file_from_id |
170 | None, |
171 | object.object, |
172 | &RepositoryFileFromIdRequest, |
173 | |
174 | .await |
175 | .map_err?; |
176 | drop; |
177 | |
178 | Ok |
179 | |
180 | .boxed |
181 | |
182 | |
183 | |
184 | object: &Repository, |
185 | operation: RepositoryDiffRequest, |
186 | state: DatabaseBackend, |
187 | operation_state: StackOperationState, |
188 | backend: BackendWrapper, |
189 | |
190 | let object = object.clone; |
191 | |
192 | async move |
193 | let object = backend |
194 | . |
195 | .await |
196 | .unwrap; |
197 | |
198 | let mut repository_backend = state.repository_backend.lock .await; |
199 | let file = repository_backend |
200 | .repository_diff |
201 | .await |
202 | .map_err?; |
203 | drop; |
204 | |
205 | Ok |
206 | |
207 | .boxed |
208 | |
209 | |
210 | |
211 | object: &Repository, |
212 | operation: RepositoryCommitBeforeRequest, |
213 | state: DatabaseBackend, |
214 | operation_state: StackOperationState, |
215 | backend: BackendWrapper, |
216 | |
217 | let object = object.clone; |
218 | |
219 | async move |
220 | let object = backend |
221 | . |
222 | .await |
223 | .unwrap; |
224 | |
225 | let mut repository_backend = state.repository_backend.lock .await; |
226 | let file = repository_backend |
227 | .repository_commit_before |
228 | .await |
229 | .map_err?; |
230 | drop; |
231 | |
232 | Ok |
233 | |
234 | .boxed |
235 | |
236 | |
237 | |
238 | object: &Repository, |
239 | operation: , |
240 | state: DatabaseBackend, |
241 | |
242 | let object = object.clone; |
243 | |
244 | async move |
245 | let mut repository_backend = state.repository_backend.lock .await; |
246 | let value = repository_backend |
247 | .get_value |
248 | .await |
249 | .map_err |
250 | Internal |
251 | ?; |
252 | |
253 | Ok |
254 | |
255 | .boxed |
256 | |
257 | |
258 | |
259 | object: &Repository, |
260 | operation: , |
261 | state: DatabaseBackend, |
262 | |
263 | let object = object.clone; |
264 | |
265 | async move |
266 | let mut repository_backend = state.repository_backend.lock .await; |
267 | let value = repository_backend |
268 | .get_setting |
269 | .await |
270 | .map_err?; |
271 | |
272 | Ok |
273 | |
274 | .boxed |
275 | |
276 | |
277 | |
278 | object: &Repository, |
279 | operation: , |
280 | state: DatabaseBackend, |
281 | |
282 | let object = object.clone; |
283 | |
284 | async move |
285 | let mut repository_backend = state.repository_backend.lock .await; |
286 | let value = repository_backend |
287 | .write_setting |
288 | .await |
289 | .map_err?; |
290 | |
291 | Ok |
292 | |
293 | .boxed |
294 | |
295 | |
296 | |
297 | object: &Instance, |
298 | operation: AuthenticationTokenRequest, |
299 | state: DatabaseBackend, |
300 | |
301 | let object = object.clone; |
302 | async move |
303 | let mut backend = state.user_backend.lock .await; |
304 | |
305 | backend |
306 | .login |
307 | .await |
308 | .map_err |
309 | |
310 | .boxed |
311 | |
312 | |
313 | |
314 | _object: &Instance, |
315 | operation: RegisterAccountRequest, |
316 | state: DatabaseBackend, |
317 | |
318 | async move |
319 | let mut backend = state.user_backend.lock .await; |
320 | |
321 | backend |
322 | .register |
323 | .await |
324 | .map_err |
325 | |
326 | .boxed |
327 | |
328 |