JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Add all the user request handling

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨e3bda14

⁨src/messages/user.rs⁩ - ⁨1958⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::model::{instance::Instance, repository::Repository, user::User};
4
5 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
6 pub struct UserMessage {
7 pub instance: Instance,
8 pub message: UserMessageKind,
9 }
10
11 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
12 pub enum UserMessageKind {
13 Request(UserMessageRequest),
14 Response(UserMessageResponse),
15 }
16
17 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
18 pub enum UserMessageRequest {
19 DisplayName(UserDisplayNameRequest),
20 DisplayImage(UserDisplayImageRequest),
21 Bio(UserBioRequest),
22 Repositories(UserRepositoriesRequest),
23 }
24
25 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
26 pub enum UserMessageResponse {
27 DisplayName(UserDisplayNameResponse),
28 DisplayImage(UserDisplayImageResponse),
29 Bio(UserBioResponse),
30 Repositories(UserRepositoriesResponse),
31 }
32
33 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
34 pub struct UserDisplayNameRequest {
35 pub user: User,
36 }
37
38 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
39 pub struct UserDisplayNameResponse {
40 pub display_name: Option<String>,
41 }
42
43 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
44 pub struct UserDisplayImageRequest {
45 pub user: User,
46 }
47
48 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
49 pub struct UserDisplayImageResponse {
50 pub image_url: Option<String>,
51 }
52
53 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
54 pub struct UserBioRequest {
55 pub user: User,
56 }
57
58 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
59 pub struct UserBioResponse {
60 pub bio: Option<String>,
61 }
62
63 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
64 pub struct UserRepositoriesRequest {
65 pub user: User,
66 }
67
68 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
69 pub struct UserRepositoriesResponse {
70 pub repositories: Vec<Repository>,
71 }
72