forked from github-starred/komodo
Merge branch 'next' of https://github.com/mbecker20/monitor into next
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 {})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ export type WriteResponses = {
|
||||
|
||||
// ==== USER ====
|
||||
PushRecentlyViewed: Types.PushRecentlyViewedResponse;
|
||||
SetLastSeenUpdate: Types.SetLastSeenUpdateResponse;
|
||||
|
||||
// ==== PERMISSIONS ====
|
||||
UpdateUserPerimissions: Types.Update;
|
||||
|
||||
@@ -1279,6 +1279,12 @@ export interface PushRecentlyViewed {
|
||||
export interface PushRecentlyViewedResponse {
|
||||
}
|
||||
|
||||
export interface SetLastSeenUpdate {
|
||||
}
|
||||
|
||||
export interface SetLastSeenUpdateResponse {
|
||||
}
|
||||
|
||||
export type AuthRequest =
|
||||
| { type: "GetLoginOptions", params: GetLoginOptions }
|
||||
| { type: "CreateLocalUser", params: CreateLocalUser }
|
||||
@@ -1356,6 +1362,7 @@ export type WriteRequest =
|
||||
| { type: "CreateLoginSecret", params: CreateLoginSecret }
|
||||
| { type: "DeleteLoginSecret", params: DeleteLoginSecret }
|
||||
| { type: "PushRecentlyViewed", params: PushRecentlyViewed }
|
||||
| { type: "SetLastSeenUpdate", params: SetLastSeenUpdate }
|
||||
| { type: "UpdateUserPerimissions", params: UpdateUserPermissions }
|
||||
| { type: "UpdateUserPermissionsOnTarget", params: UpdateUserPermissionsOnTarget }
|
||||
| { type: "UpdateDescription", params: UpdateDescription }
|
||||
|
||||
@@ -4,6 +4,8 @@ use typeshare::typeshare;
|
||||
|
||||
use crate::entities::update::ResourceTarget;
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(PushRecentlyViewedResponse)]
|
||||
@@ -14,3 +16,14 @@ pub struct PushRecentlyViewed {
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct PushRecentlyViewedResponse {}
|
||||
|
||||
//
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Request)]
|
||||
#[response(SetLastSeenUpdateResponse)]
|
||||
pub struct SetLastSeenUpdate {}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct SetLastSeenUpdateResponse {}
|
||||
|
||||
Reference in New Issue
Block a user