mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-09-25 22:29:45 +00:00
Make all HTTP routes asynchronous
This commit is contained in:
@@ -35,13 +35,13 @@ impl HttpRequestHandler {
|
||||
}
|
||||
|
||||
/// Count the number of unread notifications
|
||||
pub fn count_unread(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
pub async fn count_unread(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let number = notifications_helper::count_unread(r.user_id_ref()?)?;
|
||||
r.set_response(ResNumberUnreadNotifications::new(number))
|
||||
}
|
||||
|
||||
/// Count the number of unread notifications
|
||||
pub fn count_all_news(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
pub async fn count_all_news(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let notifications = notifications_helper::count_unread(r.user_id_ref()?)?;
|
||||
let conversations = conversations_helper::count_unread_for_user(r.user_id_ref()?)?;
|
||||
let friends_requests = match r.post_bool_opt("friends_request", false) {
|
||||
@@ -53,14 +53,14 @@ pub fn count_all_news(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
}
|
||||
|
||||
/// Get the list of unread notifications
|
||||
pub fn get_list_unread(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
pub async fn get_list_unread(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let list = notifications_helper::get_list_unread(r.user_id_ref()?)?;
|
||||
|
||||
r.set_response(NotificationAPI::for_list(&list))
|
||||
}
|
||||
|
||||
/// Mark a notification as seen
|
||||
pub fn mark_seen(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
pub async fn mark_seen(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let notif = r.post_notif_id("notifID")?;
|
||||
let delete_similar = r.post_bool_opt("delete_similar", false);
|
||||
|
||||
@@ -79,7 +79,7 @@ pub fn mark_seen(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
}
|
||||
|
||||
/// Delete all the notifications of the current user
|
||||
pub fn delete_all(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
pub async fn delete_all(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
notifications_helper::delete_all_user(r.user_id_ref()?)?;
|
||||
|
||||
r.success("Notifications deleted.")
|
||||
|
Reference in New Issue
Block a user