privchat_protocol/rpc/account/profile.rs
1// Copyright 2025 Shanghai Boyu Information Technology Co., Ltd.
2// https://privchat.dev
3//
4// Author: zoujiaqing <zoujiaqing@gmail.com>
5//
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18/// 账号资料相关 RPC
19use serde::{Deserialize, Serialize};
20use std::collections::HashMap;
21
22/// 获取个人资料请求
23///
24/// RPC路由: `account/profile/get`
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct AccountProfileGetRequest {
27 /// 用户ID(服务器端填充,客户端不需要传)
28 #[serde(skip_deserializing, default)]
29 pub user_id: u64,
30}
31
32/// 更新个人资料请求
33///
34/// RPC路由: `account/profile/update`
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct AccountProfileUpdateRequest {
37 /// 显示名称(可选)
38 #[serde(skip_serializing_if = "Option::is_none")]
39 pub display_name: Option<String>,
40 /// 头像 URL(可选)
41 #[serde(skip_serializing_if = "Option::is_none")]
42 pub avatar_url: Option<String>,
43 /// 个人简介(可选)
44 #[serde(skip_serializing_if = "Option::is_none")]
45 pub bio: Option<String>,
46 /// 兼容扩展字段(可选)
47 #[serde(default, skip_serializing_if = "HashMap::is_empty")]
48 pub extra_fields: HashMap<String, String>,
49 /// 用户ID(服务器端填充,客户端不需要传)
50 #[serde(skip_deserializing, default)]
51 pub user_id: u64,
52}
53
54/// 获取个人资料响应
55///
56/// RPC路由: `account/profile/get`
57#[derive(Debug, Clone, Serialize, Deserialize)]
58pub struct AccountProfileGetResponse {
59 pub status: String,
60 pub action: String,
61 pub timestamp: String,
62}
63
64/// 更新个人资料响应
65///
66/// RPC路由: `account/profile/update`
67#[derive(Debug, Clone, Serialize, Deserialize)]
68pub struct AccountProfileUpdateResponse {
69 pub status: String,
70 pub action: String,
71 pub timestamp: String,
72}