From cae25486e40bbeada8e13c9b32f4e478017d6955 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 19 Oct 2023 20:16:12 -0400 Subject: [PATCH] Adding ts-rs directives for login_token. (#4063) * Adding ts-rs directives for login_token. * Fixing ts-rs derive. --- crates/api/src/community/hide.rs | 8 ++++---- crates/api_common/src/community.rs | 1 - crates/db_schema/src/source/login_token.rs | 7 ++++++- src/api_routes_http.rs | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/api/src/community/hide.rs b/crates/api/src/community/hide.rs index dd8343927..27919a42b 100644 --- a/crates/api/src/community/hide.rs +++ b/crates/api/src/community/hide.rs @@ -1,11 +1,11 @@ use activitypub_federation::config::Data; use actix_web::web::Json; use lemmy_api_common::{ - build_response::build_community_response, - community::{CommunityResponse, HideCommunity}, + community::HideCommunity, context::LemmyContext, send_activity::{ActivityChannel, SendActivityData}, utils::is_admin, + SuccessResponse, }; use lemmy_db_schema::{ source::{ @@ -22,7 +22,7 @@ pub async fn hide_community( data: Json, context: Data, local_user_view: LocalUserView, -) -> Result, LemmyError> { +) -> Result, LemmyError> { // Verify its a admin (only admin can hide or unhide it) is_admin(&local_user_view)?; @@ -51,5 +51,5 @@ pub async fn hide_community( ) .await?; - build_community_response(&context, local_user_view, community_id).await + Ok(Json(SuccessResponse::default())) } diff --git a/crates/api_common/src/community.rs b/crates/api_common/src/community.rs index 8e87ab750..1f4a94636 100644 --- a/crates/api_common/src/community.rs +++ b/crates/api_common/src/community.rs @@ -154,7 +154,6 @@ pub struct EditCommunity { #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] /// Hide a community from the main view. -// TODO this should really be a part of edit community. And why does it contain a reason, that should be in the mod tables. pub struct HideCommunity { pub community_id: CommunityId, pub hidden: bool, diff --git a/crates/db_schema/src/source/login_token.rs b/crates/db_schema/src/source/login_token.rs index 008b96e04..45f74c41f 100644 --- a/crates/db_schema/src/source/login_token.rs +++ b/crates/db_schema/src/source/login_token.rs @@ -3,11 +3,16 @@ use crate::newtypes::LocalUserId; use crate::schema::login_token; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; +use serde_with::skip_serializing_none; +#[cfg(feature = "full")] +use ts_rs::TS; /// Stores data related to a specific user login session. +#[skip_serializing_none] #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] -#[cfg_attr(feature = "full", derive(Queryable, Identifiable))] +#[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))] #[cfg_attr(feature = "full", diesel(table_name = login_token))] +#[cfg_attr(feature = "full", ts(export))] pub struct LoginToken { pub id: i32, /// Jwt token for this login diff --git a/src/api_routes_http.rs b/src/api_routes_http.rs index 26d6b9e8d..fb784b3b3 100644 --- a/src/api_routes_http.rs +++ b/src/api_routes_http.rs @@ -275,7 +275,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) { .route("/ban", web::post().to(ban_from_site)) .route("/banned", web::get().to(list_banned_users)) .route("/block", web::post().to(block_person)) - // Account actions. I don't like that they're in /user maybe /accounts + // TODO Account actions. I don't like that they're in /user maybe /accounts .route("/login", web::post().to(login)) .route("/logout", web::post().to(logout)) .route("/delete_account", web::post().to(delete_account)) @@ -284,7 +284,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) { "/password_change", web::post().to(change_password_after_reset), ) - // mark_all_as_read feels off being in this section as well + // TODO mark_all_as_read feels off being in this section as well .route( "/mark_all_as_read", web::post().to(mark_all_notifications_read),