aboutsummaryrefslogtreecommitdiff
path: root/src/client/rest
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-03-20 22:05:12 -0700
committerZeyla Hellyer <[email protected]>2017-03-20 22:10:15 -0700
commitcd914f503c8f0ada7473b5b56e4ad7830370ea45 (patch)
tree3f72ca3f878efe2d96a1e64479e6e23dc7c95113 /src/client/rest
parentFix deadlock/panic on channel create event for private messages (diff)
downloadserenity-cd914f503c8f0ada7473b5b56e4ad7830370ea45.tar.xz
serenity-cd914f503c8f0ada7473b5b56e4ad7830370ea45.zip
Fix Member methods due to variant joined_at values
Fix an issue where the library would check the Id of the guild that a member is in by checking the Member's ID and joined_at value with those of the members of guilds present in the cache. Performing this check would have the issue of where a joined_at for a member received over websocket would potentially have a varying value than that of the same member retrieved over REST. To fix this, attach the relevant guild's Id to the member on creation, where the Id is available. Fixes #68.
Diffstat (limited to 'src/client/rest')
-rw-r--r--src/client/rest/mod.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/client/rest/mod.rs b/src/client/rest/mod.rs
index 6b5b055..a9dc88c 100644
--- a/src/client/rest/mod.rs
+++ b/src/client/rest/mod.rs
@@ -48,7 +48,7 @@ use std::sync::{Arc, Mutex};
use ::constants::{self, ErrorCode};
use ::internal::prelude::*;
use ::model::*;
-use ::utils::decode_array;
+use ::utils::{decode_array, into_array};
/// An method used for ratelimiting special routes.
///
@@ -1048,7 +1048,10 @@ pub fn get_guild_members(guild_id: u64, limit: Option<u64>, after: Option<u64>)
limit.unwrap_or(500),
after.unwrap_or(0));
- decode_array(serde_json::from_reader(response)?, Member::decode)
+ into_array(serde_json::from_reader(response)?)
+ .and_then(|x| x.into_iter()
+ .map(|v| Member::decode_guild(GuildId(guild_id), v))
+ .collect())
}
/// Gets the amount of users that can be pruned.
@@ -1167,7 +1170,7 @@ pub fn get_member(guild_id: u64, user_id: u64) -> Result<Member> {
guild_id,
user_id);
- Member::decode(serde_json::from_reader(response)?)
+ Member::decode_guild(GuildId(guild_id), serde_json::from_reader(response)?)
}
/// Gets a message by an Id, bots only.