You've already forked pages
forked from didirus/AstralRinth
* Fix not being able to connect to local friends socket * Start basic work on tunneling protocol and move some code into a common crate * Commonize message serialization logic * Serialize Base62Ids as u64 when human-readability is not required * Move ActiveSockets tuple into struct * Make CI run when rust-common is updated CI is currently broken for labrinth, however * Fix theseus-release.yml to reference itself correctly * Implement Labrinth side of tunneling * Implement non-friend part of theseus tunneling * Implement client-side except for socket loop * Implement the socket loop Doesn't work though. Debugging time! * Fix config.rs * Fix deadlock in labrinth socket handling * Update dockerfile * switch to workspace prepare at root level * Wait for connection before tunneling in playground * Move rust-common into labrinth * Remove rust-common references from Actions * Revert "Update dockerfile" This reverts commit 3caad59bb474ce425d0b8928d7cee7ae1a5011bd. * Fix Docker build * Rebuild Theseus if common code changes * Allow multiple connections from the same user * Fix test building * Move FriendSocketListening and FriendSocketStoppedListening to non-panicking TODO for now * Make message_serialization macro take varargs for binary messages * Improve syntax of message_serialization macro * Remove the ability to connect to a virtual socket, and disable the ability to listen on one * Allow the app to compile without running labrinth * Clippy fix * Update Rust and Clippy fix again --------- Co-authored-by: Jai A <jaiagr+gpg@pm.me>
37 lines
993 B
Rust
37 lines
993 B
Rust
use crate::state::{FriendsSocket, UserFriend};
|
|
use labrinth::common::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(())
|
|
}
|