Fix settings
parent: tbd commit: c518454
1 | |
2 | |
3 | |
4 | use Any; |
5 | use Arc; |
6 | |
7 | use Context; |
8 | use OperationError; |
9 | use Instance; |
10 | use ; |
11 | use ObjectBackend; |
12 | use GiteratedOperation; |
13 | use ; |
14 | use ; |
15 | use MetadataProvider; |
16 | use ; |
17 | use ; |
18 | use Value; |
19 | use PgPool; |
20 | use Debug; |
21 | use ; |
22 | |
23 | use crate; |
24 | use crate; |
25 | |
26 | use |
27 | instance_authentication_request, instance_create_repository_request, |
28 | instance_registration_request, repository_commit_before, repository_commit_by_id, |
29 | repository_diff, repository_diff_patch, repository_file_from_id, repository_file_from_path, |
30 | repository_get_branches, repository_get_default_branch, repository_get_latest_commit, |
31 | repository_get_statistics, repository_get_value_description, repository_get_value_visibility, |
32 | repository_info, repository_last_commit_of_file, user_get_repositories, user_get_value_bio, |
33 | user_get_value_display_name, |
34 | ; |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | async |
42 | &self, |
43 | _object: O, |
44 | _operation: &str, |
45 | _payload: D, |
46 | _operation_state: &StackOperationState, |
47 | |
48 | // We don't handle operations with this backend |
49 | Err |
50 | |
51 | |
52 | async |
53 | &self, |
54 | _object_str: &str, |
55 | _operation_state: &StackOperationState, |
56 | |
57 | Err |
58 | |
59 | |
60 | |
61 | /// A backend implementation which attempts to resolve data from the instance's database. |
62 | |
63 | |
64 | |
65 | pub(self) our_instance: Instance, |
66 | pub(self) pool: PgPool, |
67 | pub(self) user_backend: , |
68 | pub(self) repository_backend: , |
69 | pub stack: , |
70 | |
71 | |
72 | |
73 | |
74 | instance: Instance, |
75 | user_backend: , |
76 | repository_backend: , |
77 | pool: PgPool, |
78 | stack: , |
79 | |
80 | Self |
81 | our_instance: instance, |
82 | user_backend, |
83 | repository_backend, |
84 | pool, |
85 | stack, |
86 | |
87 | |
88 | |
89 | |
90 | let mut builder = new; |
91 | |
92 | builder.object_metadata_provider; |
93 | |
94 | builder |
95 | . |
96 | . |
97 | .; |
98 | |
99 | // Register value settings, which are settings that directly correspond to |
100 | // value types. |
101 | builder |
102 | . |
103 | . |
104 | . |
105 | . |
106 | .; |
107 | |
108 | builder.value; |
109 | |
110 | builder |
111 | .operation |
112 | .operation |
113 | .operation |
114 | .operation |
115 | .operation |
116 | .operation |
117 | .operation |
118 | .operation |
119 | .operation |
120 | .operation |
121 | .operation |
122 | .operation |
123 | .operation |
124 | .operation; |
125 | |
126 | builder |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | f.debug_struct .finish |
133 | |
134 | |
135 | |
136 | |
137 | |
138 | |
139 | object.|| object. || object. |
140 | |
141 | |
142 | async |
143 | &self, |
144 | object: & , |
145 | _object_meta: &ObjectMeta, |
146 | setting: & , |
147 | setting_meta: &SettingMeta, |
148 | |
149 | if let Some = object. |
150 | ! | query
151 | repository.to_string, setting_meta.name, to_string? |
152 | .execute .await?; |
153 | |
154 | Ok |
155 | else if let Some = object. |
156 | ! | query
157 | user.username, setting_meta.name, to_string? |
158 | .execute .await?; |
159 | |
160 | Ok |
161 | else |
162 | unreachable! |
163 | |
164 | |
165 | |
166 | async |
167 | &self, |
168 | object: & , |
169 | _object_meta: &ObjectMeta, |
170 | setting_meta: &SettingMeta, |
171 | |
172 | if let Some = object. |
173 | let row = query_as! |
174 | RepositorySettingRow, |
175 | "SELECT * FROM repository_settings WHERE repository = $1 AND name = $2", |
176 | repository.to_string, |
177 | setting_meta.name |
178 | |
179 | .fetch_one |
180 | .await?; |
181 | |
182 | let setting = |
183 | context?; | from_str .
184 | |
185 | Ok |
186 | else if let Some = object. |
187 | info!; |
188 | let row = query_as! |
189 | UserSettingRow, |
190 | "SELECT * FROM user_settings WHERE username = $1 AND name = $2", |
191 | user.username, |
192 | setting_meta.name |
193 | |
194 | .fetch_one |
195 | .await?; |
196 | |
197 | let setting = |
198 | context?; | from_str .
199 | |
200 | Ok |
201 | else |
202 | unreachable! |
203 | |
204 | |
205 | |
206 |