Update version checks
parent: tbd commit: 1ed7c39
1 | use |
2 | , | DefaultHasher
3 | , |
4 | ; |
5 | |
6 | use Error; |
7 | use ; |
8 | use ; |
9 | use ; |
10 | use PgPool; |
11 | |
12 | use crate:: |
13 | , |
14 | , |
15 | ; |
16 | |
17 | use DiscoveryBackend; |
18 | |
19 | |
20 | pub pool: PgPool, |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | Instance, |
27 | Repository, |
28 | |
29 | |
30 | |
31 | |
32 | async |
33 | if request |
34 | .message |
35 | .validate |
36 | .await |
37 | .is_err |
38 | |
39 | return Ok; |
40 | |
41 | |
42 | let inner = request.message.inner .await.clone; |
43 | |
44 | match inner |
45 | => | Discoveries
46 | let discoveries = discoveries.discoveries.drain .map |
47 | let hash = |
48 | let mut hasher = new; |
49 | discovery.hash; |
50 | STANDARD.encode |
51 | ; |
52 | |
53 | let = match discovery |
54 | Instance |
55 | instance, |
56 | signature, |
57 | => , |
58 | Repository |
59 | repository, |
60 | signature, |
61 | => , |
62 | ; |
63 | |
64 | DiscoveriesRow |
65 | discovery_hash: hash, |
66 | discovery_time: now, |
67 | discovery_type, |
68 | discovery, |
69 | |
70 | ; |
71 | |
72 | for row in discoveries |
73 | let result = query! |
74 | r#"INSERT INTO discoveries VALUES ($1, $2, $3, $4)"#, |
75 | row.discovery_hash, |
76 | row.discovery_time.to_string, |
77 | row.discovery_type as _, |
78 | row.discovery |
79 | |
80 | .execute |
81 | .await; |
82 | |
83 | match result |
84 | Ok => , |
85 | Err => |
86 | error!; |
87 | |
88 | |
89 | |
90 | Ok |
91 | |
92 | => Ok, | Offer
93 | => Ok, | Request
94 | |
95 | |
96 | |
97 | async |
98 | todo! |
99 | |
100 | |
101 | |
102 | |
103 | |
104 | discovery_hash: String, |
105 | discovery_time: , |
106 | discovery_type: DiscoveryType, |
107 | discovery: String, |
108 |