Skip to main content

privchat_protocol/rpc/group/
group.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路由: `group/group/create`
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct GroupCreateRequest {
26    /// 群组名称
27    pub name: String,
28    /// 群组描述(可选)
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub description: Option<String>,
31    /// 初始成员ID列表(可选)
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub member_ids: Option<Vec<u64>>,
34
35    /// 创建者ID(服务器端填充,客户端不可设置)
36    #[serde(skip_deserializing, default)]
37    pub creator_id: u64,
38}
39
40/// 获取群组信息请求
41///
42/// RPC路由: `group/group/info`
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct GroupInfoRequest {
45    /// 群组ID
46    pub group_id: u64,
47
48    /// 用户ID(服务器端填充,客户端不可设置)
49    #[serde(skip_deserializing, default)]
50    pub user_id: u64,
51}
52
53/// 创建群组响应
54///
55/// RPC路由: `group/group/create`
56#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct GroupCreateResponse {
58    pub group_id: u64,
59    pub name: String,
60    pub description: Option<String>,
61    pub member_count: u32,
62    pub created_at: String, // ISO 8601
63    pub creator_id: u64,
64}
65
66/// 获取群组信息响应
67///
68/// RPC路由: `group/group/info`
69#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct GroupInfoResponse {
71    pub group_id: u64,
72    pub name: String,
73    pub description: Option<String>,
74    pub avatar_url: Option<String>,
75    pub owner_id: u64,
76    pub created_at: String,
77    pub updated_at: String,
78    pub member_count: u32,
79    pub message_count: Option<u32>,
80    pub is_archived: Option<bool>,
81    pub tags: Option<serde_json::Value>,
82    pub custom_fields: Option<serde_json::Value>,
83}