aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel/reaction.rs
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-08-24 15:26:49 +0200
committeracdenisSK <[email protected]>2017-08-24 16:36:01 +0200
commitb3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3 (patch)
tree315e16f7b252d22b5f832302e722a85c9e6a9b6e /src/model/channel/reaction.rs
parentAllow FromStr for User to use REST (#147) (diff)
downloadserenity-b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3.tar.xz
serenity-b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3.zip
Revamp `RwLock` usage in the lib
Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
Diffstat (limited to 'src/model/channel/reaction.rs')
-rw-r--r--src/model/channel/reaction.rs51
1 files changed, 25 insertions, 26 deletions
diff --git a/src/model/channel/reaction.rs b/src/model/channel/reaction.rs
index 88fd24c..be5dfb8 100644
--- a/src/model/channel/reaction.rs
+++ b/src/model/channel/reaction.rs
@@ -46,32 +46,31 @@ 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)
}