Git repository hosting, collaboration, and discovery for the Fediverse.
Add authentication back into the API
parent: tbd commit: c3639d1
1 | use ; |
2 | |
3 | use ; |
4 | use |
5 | , |
6 | , | OperationError
7 | , | GiteratedMessage
8 | , |
9 | , | ObjectBackend
10 | , | GiteratedOperation
11 | ; |
12 | use DeserializeOwned; |
13 | use Message; |
14 | |
15 | use crate::; |
16 | |
17 | |
18 | |
19 | authentication: , |
20 | |
21 | |
22 | |
23 | |
24 | Self |
25 | authentication: vec!, |
26 | |
27 | |
28 | |
29 | |
30 | &mut self, |
31 | source: S, |
32 | |
33 | self.authentication.push |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | async |
40 | &self, |
41 | object: O, |
42 | operation: &str, |
43 | payload: D, |
44 | operation_state: &NetworkOperationState, |
45 | |
46 | let message = GiteratedMessage |
47 | object, |
48 | operation: operation.to_string, |
49 | payload, |
50 | ; |
51 | |
52 | let mut connection = self |
53 | .0 |
54 | .get |
55 | .await |
56 | .map_err?; |
57 | |
58 | let mut authenticated = new; |
59 | for authentication in &operation_state.authentication |
60 | authenticated.append_authentication; |
61 | |
62 | |
63 | send_expect .await |
64 | |
65 | |
66 | async |
67 | &self, |
68 | object_str: &str, |
69 | operation_state: &NetworkOperationState, |
70 | |
71 | let operation = ObjectRequest; |
72 | info!; |
73 | let message = GiteratedMessage |
74 | object: self.0.manager .target_instance.clone, |
75 | operation: operation_name .to_string, |
76 | payload: operation, |
77 | ; |
78 | |
79 | let mut connection = self |
80 | .0 |
81 | .get |
82 | .await |
83 | .map_err?; |
84 | |
85 | let mut authenticated = new; |
86 | for authentication in &operation_state.authentication |
87 | authenticated.append_authentication; |
88 | |
89 | |
90 | let object_raw: ObjectResponse = send_expect .await?; |
91 | Ok |
92 | new_unchecked |
93 | from_str |
94 | .map_err?, |
95 | self.clone, |
96 | |
97 | |
98 | |
99 | |
100 | |
101 | async |
102 | O: GiteratedObject, |
103 | D: , |
104 | B: DeserializeOwned, |
105 | R: DeserializeOwned, |
106 | > |
107 | socket: &mut Socket, |
108 | message: , |
109 | |
110 | let payload = serialize .unwrap; |
111 | |
112 | socket |
113 | .send |
114 | .await |
115 | .map_err?; |
116 | |
117 | while let Some = socket.next .await |
118 | let payload = match message.map_err? |
119 | => payload, | Binary
120 | _ => |
121 | continue; |
122 | |
123 | ; |
124 | |
125 | let raw_result = |
126 | .map_err?; |
127 | |
128 | // Map ok |
129 | let raw_result = match raw_result |
130 | Ok => Ok |
131 | .map_err?, |
132 | Err => Err |
133 | => Operation | Operation
134 | from_slice |
135 | .map_err?, |
136 | , |
137 | => Internal, | Internal
138 | => Unhandled, | Unhandled
139 | , |
140 | ; |
141 | |
142 | return raw_result; |
143 | |
144 | |
145 | panic! |
146 | |
147 |