aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-25 13:33:54 -0800
committerAustin Hellyer <[email protected]>2016-11-25 13:42:01 -0800
commitcc26c98403c3463bbd72b4165b40dc337f9284e6 (patch)
tree9ee0afa1c8ecc02ba0d0e7806d8416f5618fbb28 /src
parentRename the `http` module to `rest` (diff)
downloadserenity-cc26c98403c3463bbd72b4165b40dc337f9284e6.tar.xz
serenity-cc26c98403c3463bbd72b4165b40dc337f9284e6.zip
Fix permission check on Message::delete
Diffstat (limited to 'src')
-rw-r--r--src/model/channel.rs10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/model/channel.rs b/src/model/channel.rs
index ffc8658..8911487 100644
--- a/src/model/channel.rs
+++ b/src/model/channel.rs
@@ -426,9 +426,6 @@ impl Message {
///
/// # Errors
///
- /// Returns a [`ClientError::InvalidUser`] if the current user is not the
- /// author.
- ///
/// Returns a [`ClientError::InvalidPermissions`] if the current user does
/// not have the required permissions.
///
@@ -439,12 +436,9 @@ impl Message {
pub fn delete(&self) -> Result<()> {
let req = permissions::MANAGE_MESSAGES;
let is_author = self.author.id != CACHE.read().unwrap().user.id;
+ let has_perms = try!(utils::user_has_perms(self.channel_id, req));
- if is_author {
- return Err(Error::Client(ClientError::InvalidUser));
- }
-
- if !try!(utils::user_has_perms(self.channel_id, req)) && !is_author {
+ if !is_author && !has_perms {
return Err(Error::Client(ClientError::InvalidPermissions(req)));
}