You've already forked AstralRinth
forked from didirus/AstralRinth
Distributed rate limit, fix search panic, add migration task (#3419)
* Distributed rate limit, fix search panic, add migration task * Add binary info to root endpoint
This commit is contained in:
@@ -7,7 +7,13 @@ pub async fn index_get() -> HttpResponse {
|
||||
"name": "modrinth-labrinth",
|
||||
"version": env!("CARGO_PKG_VERSION"),
|
||||
"documentation": "https://docs.modrinth.com",
|
||||
"about": "Welcome traveler!"
|
||||
"about": "Welcome traveler!",
|
||||
|
||||
"build_info": {
|
||||
"comp_date": env!("COMPILATION_DATE"),
|
||||
"git_hash": env!("GIT_HASH", "unknown"),
|
||||
"profile": env!("COMPILATION_PROFILE"),
|
||||
}
|
||||
});
|
||||
|
||||
HttpResponse::Ok().json(data)
|
||||
|
||||
@@ -91,30 +91,30 @@ pub async fn ws_init(
|
||||
let friend_statuses = if !friends.is_empty() {
|
||||
let db = db.clone();
|
||||
let redis = redis.clone();
|
||||
tokio_stream::iter(friends.iter())
|
||||
|
||||
let statuses = tokio_stream::iter(friends.iter())
|
||||
.map(|x| {
|
||||
let db = db.clone();
|
||||
let redis = redis.clone();
|
||||
async move {
|
||||
async move {
|
||||
get_user_status(
|
||||
if x.user_id == user_id.into() {
|
||||
x.friend_id
|
||||
} else {
|
||||
x.user_id
|
||||
}
|
||||
.into(),
|
||||
&db,
|
||||
&redis,
|
||||
)
|
||||
.await
|
||||
}
|
||||
get_user_status(
|
||||
if x.user_id == user_id.into() {
|
||||
x.friend_id
|
||||
} else {
|
||||
x.user_id
|
||||
}
|
||||
.into(),
|
||||
&db,
|
||||
&redis,
|
||||
)
|
||||
.await
|
||||
}
|
||||
})
|
||||
.buffer_unordered(16)
|
||||
.filter_map(|x| x)
|
||||
.collect::<Vec<_>>()
|
||||
.await
|
||||
.await;
|
||||
|
||||
statuses.into_iter().flatten().collect()
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user