revolt_permissions/
trait.rs

1use crate::{ChannelType, Override, RelationshipStatus};
2
3#[async_trait]
4pub trait PermissionQuery {
5    // * For calculating user permission
6
7    /// Is our perspective user privileged?
8    async fn are_we_privileged(&mut self) -> bool;
9
10    /// Is our perspective user a bot?
11    async fn are_we_a_bot(&mut self) -> bool;
12
13    /// Is our perspective user and the currently selected user the same?
14    async fn are_the_users_same(&mut self) -> bool;
15
16    /// Get the relationship with have with the currently selected user
17    async fn user_relationship(&mut self) -> RelationshipStatus;
18
19    /// Whether the currently selected user is a bot
20    async fn user_is_bot(&mut self) -> bool;
21
22    /// Do we have a mutual connection with the currently selected user?
23    async fn have_mutual_connection(&mut self) -> bool;
24
25    // * For calculating server permission
26
27    /// Is our perspective user the server's owner?
28    async fn are_we_server_owner(&mut self) -> bool;
29
30    /// Is our perspective user a member of the server?
31    async fn are_we_a_member(&mut self) -> bool;
32
33    /// Get default server permission
34    async fn get_default_server_permissions(&mut self) -> u64;
35
36    /// Get the ordered role overrides (from lowest to highest) for this member in this server
37    async fn get_our_server_role_overrides(&mut self) -> Vec<Override>;
38
39    /// Is our perspective user timed out on this server?
40    async fn are_we_timed_out(&mut self) -> bool;
41
42    // * For calculating channel permission
43
44    /// Get the type of the channel
45    async fn get_channel_type(&mut self) -> ChannelType;
46
47    /// Get the default channel permissions
48    /// Group channel defaults should be mapped to an allow-only override
49    async fn get_default_channel_permissions(&mut self) -> Override;
50
51    /// Get the ordered role overrides (from lowest to highest) for this member in this channel
52    async fn get_our_channel_role_overrides(&mut self) -> Vec<Override>;
53
54    /// Do we own this group or saved messages channel if it is one of those?
55    async fn do_we_own_the_channel(&mut self) -> bool;
56
57    /// Are we a recipient of this channel?
58    async fn are_we_part_of_the_channel(&mut self) -> bool;
59
60    /// Set the current user as the recipient of this channel
61    /// (this will only ever be called for DirectMessage channels, use unimplemented!() for other code paths)
62    async fn set_recipient_as_user(&mut self);
63
64    /// Set the current server as the server owning this channel
65    /// (this will only ever be called for server channels, use unimplemented!() for other code paths)
66    async fn set_server_from_channel(&mut self);
67}