aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authoralex <[email protected]>2017-05-08 06:59:48 +0200
committerzeyla <[email protected]>2017-05-07 21:59:48 -0700
commit404a089af267c5d5c33025a3d74826e02b6f8ca1 (patch)
treeb90781f322748ac6aefc4629ccb9111204c9865e /src/model
parentFix guild leaving result (diff)
downloadserenity-404a089af267c5d5c33025a3d74826e02b6f8ca1.tar.xz
serenity-404a089af267c5d5c33025a3d74826e02b6f8ca1.zip
Fix permissions when sending to DMs or groups
When performing an action on a DM Channel or Group, an arbitrary permission check would always fail, causing the action to error out with a lacking permissions error. To fix this, just assume the action will always succeed.
Diffstat (limited to 'src/model')
-rw-r--r--src/model/utils.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/model/utils.rs b/src/model/utils.rs
index a01f134..4d6b385 100644
--- a/src/model/utils.rs
+++ b/src/model/utils.rs
@@ -7,7 +7,7 @@ use super::*;
use ::internal::prelude::*;
#[cfg(feature="cache")]
-use super::permissions::{self, Permissions};
+use super::permissions::Permissions;
#[cfg(feature="cache")]
use ::client::CACHE;
@@ -148,10 +148,19 @@ pub fn user_has_perms(channel_id: ChannelId, mut permissions: Permissions) -> Re
};
let guild_id = match channel {
+ Channel::Guild(channel) => channel.read().unwrap().guild_id,
Channel::Group(_) | Channel::Private(_) => {
- return Ok(permissions == permissions::MANAGE_MESSAGES);
+ // Both users in DMs, and all users in groups, will have the same
+ // permissions.
+ //
+ // The only exception to this is when the current user is blocked by
+ // the recipient in a DM channel, which results in the current user
+ // not being able to send messages.
+ //
+ // Since serenity can't _reasonably_ check and keep track of these,
+ // just assume that all permissions are granted and return `true`.
+ return Ok(true);
},
- Channel::Guild(channel) => channel.read().unwrap().guild_id,
};
let guild = match cache.guild(guild_id) {