Files
AstralRinth/packages/app-lib/src/api/friends.rs
Jai Agrawal 19787a3f51 Subpackage common -> ariadne (#3323)
* Subpackage common -> ariadne

* add common

* Remove build

* only build labrinth

* common

* set sqlx offline

* copy dirs

* Fix build
2025-03-01 20:53:43 -08:00

37 lines
984 B
Rust

use crate::state::{FriendsSocket, UserFriend};
use ariadne::users::UserStatus;
#[tracing::instrument]
pub async fn friends() -> crate::Result<Vec<UserFriend>> {
let state = crate::State::get().await?;
let friends =
FriendsSocket::friends(&state.pool, &state.api_semaphore).await?;
Ok(friends)
}
pub async fn friend_statuses() -> crate::Result<Vec<UserStatus>> {
let state = crate::State::get().await?;
let statuses = state.friends_socket.friend_statuses();
Ok(statuses)
}
#[tracing::instrument]
pub async fn add_friend(user_id: &str) -> crate::Result<()> {
let state = crate::State::get().await?;
FriendsSocket::add_friend(user_id, &state.pool, &state.api_semaphore)
.await?;
Ok(())
}
#[tracing::instrument]
pub async fn remove_friend(user_id: &str) -> crate::Result<()> {
let state = crate::State::get().await?;
FriendsSocket::remove_friend(user_id, &state.pool, &state.api_semaphore)
.await?;
Ok(())
}