Skip to main content

zaun_community_protocol/command/
membership.rs

1//! Membership and admission commands (specification §8.9, §6.4).
2
3mod policy;
4mod validate;
5
6pub use policy::{PolicyGet, PolicyResponse, PolicyUpdate, PolicyUpdated};
7
8use serde::{Deserialize, Serialize};
9
10use super::object::{Member, NewProfile};
11use crate::ids::MemberId;
12use crate::json::SignedJson;
13use crate::keys::PublicKey;
14
15/// `membership.request` (§8.9). Unbound; responds with [`super::invite::Admitted`]. The
16/// target community is the envelope's `community_id`, as for `invite.redeem` (§7.1).
17#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
18pub struct Request {
19    /// The requesting member's key.
20    pub member_public_key: PublicKey,
21    /// Signed `MemberKeyRegistration`, purpose 3.
22    pub registration: SignedJson,
23    /// The requesting member's display profile.
24    pub profile: NewProfile,
25    /// ≤ 500 scalars, shown to approvers.
26    #[serde(default, skip_serializing_if = "Option::is_none")]
27    pub note: Option<String>,
28}
29
30/// `membership.approve` (§8.9).
31#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
32pub struct Approve {
33    /// A `pending` or `probation` member.
34    pub member_id: MemberId,
35    /// From `pending` straight to `active`.
36    #[serde(default, skip_serializing_if = "Option::is_none")]
37    pub skip_probation: Option<bool>,
38}
39
40/// `membership.reject` (§8.9).
41#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
42pub struct Reject {
43    /// A `pending` member.
44    pub member_id: MemberId,
45    /// ≤ 512 scalars.
46    #[serde(default, skip_serializing_if = "Option::is_none")]
47    pub reason: Option<String>,
48}
49
50/// `membership.suspend` (§8.9). `until` is absolute; the 90-day bound is checked by
51/// [`Command::validate_at`](super::Command::validate_at).
52#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
53pub struct Suspend {
54    /// A `probation` or `active` member.
55    pub member_id: MemberId,
56    /// End of the suspension, ms; absent or `null` = until restored.
57    #[serde(default, skip_serializing_if = "Option::is_none")]
58    pub until: Option<u64>,
59    /// ≤ 512 scalars.
60    #[serde(default, skip_serializing_if = "Option::is_none")]
61    pub reason: Option<String>,
62}
63
64/// `membership.restore` (§8.9).
65#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
66pub struct Restore {
67    /// A `suspended` member.
68    pub member_id: MemberId,
69}
70
71/// `membership.pending` (§8.9).
72#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
73pub struct Pending {
74    /// Page start (exclusive).
75    #[serde(default, skip_serializing_if = "Option::is_none")]
76    pub after: Option<MemberId>,
77    /// 1–100.
78    pub limit: u32,
79}
80
81/// `membership.pending` response.
82#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
83pub struct PendingPage {
84    /// Pending members with `note` and `admission`.
85    pub members: Vec<Member>,
86    /// The `after` of the next page; absent on the last page.
87    #[serde(default, skip_serializing_if = "Option::is_none")]
88    pub next: Option<MemberId>,
89}