Skip to main content

privchat_protocol/rpc/account/
privacy.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};
20
21/// 获取隐私设置请求
22///
23/// RPC路由: `account/privacy/get`
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct AccountPrivacyGetRequest {
26    /// 用户ID(服务器端填充,客户端不可设置)
27    #[serde(skip_deserializing, default)]
28    pub user_id: u64,
29}
30
31/// 更新隐私设置请求
32///
33/// RPC路由: `account/privacy/update`
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct AccountPrivacyUpdateRequest {
36    /// 是否允许通过群组添加(可选)
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub allow_add_by_group: Option<bool>,
39    /// 是否允许通过手机号搜索(可选)
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub allow_search_by_phone: Option<bool>,
42    /// 是否允许通过用户名搜索(可选)
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub allow_search_by_username: Option<bool>,
45    /// 是否允许通过邮箱搜索(可选)
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub allow_search_by_email: Option<bool>,
48    /// 是否允许通过二维码搜索(可选)
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub allow_search_by_qrcode: Option<bool>,
51    /// 是否允许非好友查看资料(可选)
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub allow_view_by_non_friend: Option<bool>,
54    /// 是否允许接收非好友消息(可选)
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub allow_receive_message_from_non_friend: Option<bool>,
57
58    /// 用户ID(服务器端填充,客户端不可设置)
59    #[serde(skip_deserializing, default)]
60    pub user_id: u64,
61}
62
63/// 获取隐私设置响应
64///
65/// RPC路由: `account/privacy/get`
66#[derive(Debug, Clone, Serialize, Deserialize)]
67pub struct AccountPrivacySettings {
68    pub user_id: u64,
69    pub allow_add_by_group: bool,
70    pub allow_search_by_phone: bool,
71    pub allow_search_by_username: bool,
72    pub allow_search_by_email: bool,
73    pub allow_search_by_qrcode: bool,
74    pub allow_view_by_non_friend: bool,
75    pub allow_receive_message_from_non_friend: bool,
76    pub updated_at: String,
77}
78
79/// 获取隐私设置响应
80///
81/// RPC路由: `account/privacy/get`
82#[derive(Debug, Clone, Serialize, Deserialize)]
83pub struct AccountPrivacyGetResponse {
84    pub user_id: u64,
85    pub allow_add_by_group: bool,
86    pub allow_search_by_phone: bool,
87    pub allow_search_by_username: bool,
88    pub allow_search_by_email: bool,
89    pub allow_search_by_qrcode: bool,
90    pub allow_view_by_non_friend: bool,
91    pub allow_receive_message_from_non_friend: bool,
92    pub updated_at: String,
93}
94
95/// 更新隐私设置响应
96///
97/// RPC路由: `account/privacy/update`
98#[derive(Debug, Clone, Serialize, Deserialize)]
99pub struct AccountPrivacyUpdateResponse {
100    pub success: bool,
101    pub user_id: u64,
102    pub message: String,
103    pub allow_add_by_group: bool,
104    pub allow_search_by_phone: bool,
105    pub allow_search_by_username: bool,
106    pub allow_search_by_email: bool,
107    pub allow_search_by_qrcode: bool,
108    pub allow_view_by_non_friend: bool,
109    pub allow_receive_message_from_non_friend: bool,
110    pub updated_at: String,
111}