1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use serde_repr::{Deserialize_repr, Serialize_repr};
use crate::{impl_default, impl_display};
/// A deprecated representation of a superset of the users who have permission to use wildcard mentions in large channels, available for backwards-compatibility.
///
/// Clients should use `can_mention_many_users_group` instead.
///
/// It is an enum with the following possible values, corresponding to roles/system groups:
///
/// - 1: Any user can use wildcard mentions in large channels.
/// - 2: Only members can use wildcard mentions in large channels.
/// - 3: Only [full members](https://zulip.com/api/roles-and-permissions#determining-if-a-user-is-a-full-member) can use wildcard mentions in large channels.
/// - 5: Only organization administrators can use wildcard mentions in large channels.
/// - 6: Nobody can use wildcard mentions in large channels.
/// - 7: Only organization administrators and moderators can use wildcard mentions in large channels.
///
/// All users will receive a warning/reminder when using mentions in large channels, even when permitted to do so.
///
/// **Changes**: Deprecated in Zulip 10.0 (feature level 352) and replaced by `realm_can_mention_many_users_group`,
/// which supports finer resolution of configurations, resulting in this property being inaccurate following that transition.
///
/// Channel administrators option removed in Zulip 6.0 (feature level 133).
///
/// Moderators option added in Zulip 4.0 (feature level 62).
///
/// New in Zulip 4.0 (feature level 33).
///
/// [permission-level](https://zulip.com/api/roles-and-permissions#permission-levels)
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize_repr, Serialize_repr)]
pub enum RealmWildcardMentionPolicy {
/// Any user can use wildcard mentions in large channels.
AnyUser = 1,
/// Only members can use wildcard mentions in large channels.
MembersOnly = 2,
/// Only [full members](https://zulip.com/api/roles-and-permissions#determining-if-a-user-is-a-full-member) can use wildcard mentions in large channels.
FullMembersOnly = 3,
/// Only organization administrators can use wildcard mentions in large channels.
AdminsOnly = 5,
/// Nobody can use wildcard mentions in large channels.
Nobody = 6,
/// Only organization administrators and moderators can use wildcard mentions in large channels.
Admins = 7,
}
impl RealmWildcardMentionPolicy {
/// Represents the string value of the any user policy.
pub const ANY_USER: &str = "any_user";
/// Represents the string value of the members only policy.
pub const MEMBERS_ONLY: &str = "members_only";
/// Represents the string value of the full members policy.
pub const FULL_MEMBERS_ONLY: &str = "full_members_only";
/// Represents the string value of the admins only policy.
pub const ADMINS_ONLY: &str = "admins_only";
/// Represents the string value of the admins or nobody policy.
pub const NOBODY: &str = "nobody";
/// Represents the string value of the admins or moderators policy.
pub const ADMINS: &str = "admins";
/// Creates a new [Self].
pub const fn new() -> Self {
Self::MembersOnly
}
/// Gets the string representation of the [Self].
pub const fn as_str(&self) -> &'static str {
match self {
Self::AnyUser => Self::ANY_USER,
Self::MembersOnly => Self::MEMBERS_ONLY,
Self::FullMembersOnly => Self::FULL_MEMBERS_ONLY,
Self::AdminsOnly => Self::ADMINS_ONLY,
Self::Nobody => Self::NOBODY,
Self::Admins => Self::ADMINS,
}
}
}
impl_default!(RealmWildcardMentionPolicy);
impl_display!(RealmWildcardMentionPolicy: str);