diff options
Diffstat (limited to 'src/model/channel/reaction.rs')
| -rw-r--r-- | src/model/channel/reaction.rs | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/model/channel/reaction.rs b/src/model/channel/reaction.rs index be5dfb8..121bf43 100644 --- a/src/model/channel/reaction.rs +++ b/src/model/channel/reaction.rs @@ -46,31 +46,34 @@ impl Reaction { /// [Manage Messages]: permissions/constant.MANAGE_MESSAGES.html /// [permissions]: permissions pub fn delete(&self) -> Result<()> { - let user_id = feature_cache! {{ - let user = if self.user_id == CACHE.read().unwrap().user.id { - None - } else { - Some(self.user_id.0) - }; - - // If the reaction is one _not_ made by the current user, then ensure - // that the current user has permission* to delete the reaction. - // - // Normally, users can only delete their own reactions. - // - // * The `Manage Messages` permission. - if user.is_some() { - let req = permissions::MANAGE_MESSAGES; - - if !utils::user_has_perms(self.channel_id, req).unwrap_or(true) { - return Err(Error::Model(ModelError::InvalidPermissions(req))); - } - } - - user - } else { - Some(self.user_id.0) - }}; + let user_id = + feature_cache! { + { + let user = if self.user_id == CACHE.read().unwrap().user.id { + None + } else { + Some(self.user_id.0) + }; + + // If the reaction is one _not_ made by the current user, then ensure + // that the current user has permission* to delete the reaction. + // + // Normally, users can only delete their own reactions. + // + // * The `Manage Messages` permission. + if user.is_some() { + let req = permissions::MANAGE_MESSAGES; + + if !utils::user_has_perms(self.channel_id, req).unwrap_or(true) { + return Err(Error::Model(ModelError::InvalidPermissions(req))); + } + } + + user + } else { + Some(self.user_id.0) + } + }; http::delete_reaction(self.channel_id.0, self.message_id.0, user_id, &self.emoji) } |