mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-30 06:03:34 -05:00
SetLastSeenUpdate
This commit is contained in:
@@ -39,6 +39,7 @@ enum WriteRequest {
|
||||
|
||||
// ==== USER ====
|
||||
PushRecentlyViewed(PushRecentlyViewed),
|
||||
SetLastSeenUpdate(SetLastSeenUpdate),
|
||||
|
||||
// ==== PERMISSIONS ====
|
||||
UpdateUserPerimissions(UpdateUserPermissions),
|
||||
|
||||
@@ -2,7 +2,13 @@ use std::collections::VecDeque;
|
||||
|
||||
use anyhow::Context;
|
||||
use async_trait::async_trait;
|
||||
use monitor_types::requests::write::{PushRecentlyViewed, PushRecentlyViewedResponse};
|
||||
use monitor_types::{
|
||||
monitor_timestamp,
|
||||
requests::write::{
|
||||
PushRecentlyViewed, PushRecentlyViewedResponse, SetLastSeenUpdate,
|
||||
SetLastSeenUpdateResponse,
|
||||
},
|
||||
};
|
||||
use mungos::mongodb::bson::{doc, to_bson};
|
||||
use resolver_api::Resolve;
|
||||
|
||||
@@ -49,3 +55,24 @@ impl Resolve<PushRecentlyViewed, RequestUser> for State {
|
||||
Ok(PushRecentlyViewedResponse {})
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Resolve<SetLastSeenUpdate, RequestUser> for State {
|
||||
async fn resolve(
|
||||
&self,
|
||||
SetLastSeenUpdate {}: SetLastSeenUpdate,
|
||||
user: RequestUser,
|
||||
) -> anyhow::Result<SetLastSeenUpdateResponse> {
|
||||
self.db
|
||||
.users
|
||||
.update_one(
|
||||
&user.id,
|
||||
mungos::Update::Set(doc! {
|
||||
"last_update_view": monitor_timestamp()
|
||||
}),
|
||||
)
|
||||
.await
|
||||
.context("failed to update user last_update_view")?;
|
||||
Ok(SetLastSeenUpdateResponse {})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user