Expose errors
parent: tbd commit: 6b2125c
1 | use Error; |
2 | |
3 | |
4 | use crate AuthenticatedUser; |
5 | use crate User; |
6 | use crate:: |
7 | |
8 | UserBioRequest, UserDisplayImageRequest, UserDisplayNameRequest, UserRepositoriesRequest, |
9 | UserRepositoriesResponse, |
10 | , |
11 | , |
12 | ; |
13 | |
14 | use ; |
15 | |
16 | pub async |
17 | message_type: &str, |
18 | message: &NetworkMessage, |
19 | state: &ConnectionState, |
20 | |
21 | match message_type |
22 | "&giterated_daemon::messages::user::UserDisplayNameRequest" => |
23 | display_name.handle_message .await?; |
24 | |
25 | Ok |
26 | |
27 | "&giterated_daemon::messages::user::UserDisplayImageRequest" => |
28 | display_image.handle_message .await?; |
29 | |
30 | Ok |
31 | |
32 | "&giterated_daemon::messages::user::UserBioRequest" => |
33 | bio.handle_message .await?; |
34 | |
35 | Ok |
36 | |
37 | "&giterated_daemon::messages::user::UserRepositoriesRequest" => |
38 | repositories.handle_message .await?; |
39 | |
40 | Ok |
41 | |
42 | _ => Ok, |
43 | |
44 | |
45 | |
46 | async |
47 | Message | : ,
48 | State | : ,
49 | |
50 | let mut user_backend = connection_state.user_backend.lock .await; |
51 | let response = user_backend.display_name .await?; |
52 | |
53 | drop; |
54 | |
55 | connection_state.send .await?; |
56 | |
57 | Ok |
58 | |
59 | |
60 | async |
61 | Message | : ,
62 | State | : ,
63 | |
64 | let mut user_backend = connection_state.user_backend.lock .await; |
65 | let response = user_backend.display_image .await?; |
66 | |
67 | drop; |
68 | |
69 | connection_state.send .await?; |
70 | |
71 | Ok |
72 | |
73 | |
74 | async |
75 | Message | : ,
76 | State | : ,
77 | |
78 | let mut user_backend = connection_state.user_backend.lock .await; |
79 | let response = user_backend.bio .await?; |
80 | |
81 | drop; |
82 | |
83 | connection_state.send .await?; |
84 | |
85 | Ok |
86 | |
87 | |
88 | async |
89 | Message | : ,
90 | State | : ,
91 | requesting_user: , |
92 | |
93 | let requesting_user = requesting_user.map; |
94 | |
95 | let mut repository_backend = connection_state.repository_backend.lock .await; |
96 | let repositories = repository_backend |
97 | .repositories_for_user |
98 | .await; |
99 | |
100 | let repositories = match repositories |
101 | Ok => repositories, |
102 | Err => |
103 | error!; |
104 | return Ok; |
105 | |
106 | ; |
107 | drop; |
108 | |
109 | let mut user_backend = connection_state.user_backend.lock .await; |
110 | let user_exists = user_backend.exists .await; |
111 | |
112 | if repositories.is_empty && !matches! |
113 | return Err; |
114 | |
115 | |
116 | let response: UserRepositoriesResponse = UserRepositoriesResponse ; |
117 | |
118 | connection_state.send .await?; |
119 | |
120 | Ok |
121 | |
122 | |
123 | |
124 | |
125 | |
126 | InvalidUser, |
127 | |
128 | Other, |
129 | |
130 |