Fix errors.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
use super::get_collection;
|
use super::get_collection;
|
||||||
use super::channel::Channel;
|
use super::channel::fetch_channels;
|
||||||
|
|
||||||
use lru::LruCache;
|
use lru::LruCache;
|
||||||
use mongodb::bson::{doc, from_bson, Bson};
|
use mongodb::bson::{doc, from_bson, Bson};
|
||||||
@@ -166,14 +166,14 @@ pub fn fetch_guilds(ids: &Vec<String>) -> Result<Vec<Guild>, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn serialise_guilds_with_channels(ids: &Vec<String>) -> Result<Vec<JsonValue>, String> {
|
pub fn serialise_guilds_with_channels(ids: &Vec<String>) -> Result<Vec<JsonValue>, String> {
|
||||||
let guilds = fetch_guilds(&gids)?;
|
let guilds = fetch_guilds(&ids)?;
|
||||||
let cids: Vec<String> = guilds
|
let cids: Vec<String> = guilds
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|x| x.channels.clone())
|
.flat_map(|x| x.channels.clone())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let channels = database::channel::fetch_channels(&cids)?;
|
let channels = fetch_channels(&cids)?;
|
||||||
let data: Vec<rocket_contrib::json::JsonValue> = guilds
|
Ok(guilds
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
let id = x.id.clone();
|
let id = x.id.clone();
|
||||||
@@ -187,7 +187,7 @@ pub fn serialise_guilds_with_channels(ids: &Vec<String>) -> Result<Vec<JsonValue
|
|||||||
);
|
);
|
||||||
obj
|
obj
|
||||||
})
|
})
|
||||||
.collect()
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fetch_member(key: MemberKey) -> Result<Option<Member>, String> {
|
pub fn fetch_member(key: MemberKey) -> Result<Option<Member>, String> {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ macro_rules! with_permissions {
|
|||||||
pub fn my_guilds(user: User) -> Response {
|
pub fn my_guilds(user: User) -> Response {
|
||||||
if let Ok(gids) = user.find_guilds() {
|
if let Ok(gids) = user.find_guilds() {
|
||||||
if let Ok(data) = serialise_guilds_with_channels(&gids) {
|
if let Ok(data) = serialise_guilds_with_channels(&gids) {
|
||||||
Response::Success(data)
|
Response::Success(json!(data))
|
||||||
} else {
|
} else {
|
||||||
Response::InternalServerError(json!({ "error": "Failed to fetch guilds." }))
|
Response::InternalServerError(json!({ "error": "Failed to fetch guilds." }))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user