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