Adding ts-rs directives for login_token. (#4063)

* Adding ts-rs directives for login_token.

* Fixing ts-rs derive.
person_view_tests
Dessalines 2023-10-19 20:16:12 -04:00 committed by GitHub
parent c1db65c6e5
commit cae25486e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View File

@ -1,11 +1,11 @@
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use actix_web::web::Json; use actix_web::web::Json;
use lemmy_api_common::{ use lemmy_api_common::{
build_response::build_community_response, community::HideCommunity,
community::{CommunityResponse, HideCommunity},
context::LemmyContext, context::LemmyContext,
send_activity::{ActivityChannel, SendActivityData}, send_activity::{ActivityChannel, SendActivityData},
utils::is_admin, utils::is_admin,
SuccessResponse,
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{ source::{
@ -22,7 +22,7 @@ pub async fn hide_community(
data: Json<HideCommunity>, data: Json<HideCommunity>,
context: Data<LemmyContext>, context: Data<LemmyContext>,
local_user_view: LocalUserView, local_user_view: LocalUserView,
) -> Result<Json<CommunityResponse>, LemmyError> { ) -> Result<Json<SuccessResponse>, LemmyError> {
// Verify its a admin (only admin can hide or unhide it) // Verify its a admin (only admin can hide or unhide it)
is_admin(&local_user_view)?; is_admin(&local_user_view)?;
@ -51,5 +51,5 @@ pub async fn hide_community(
) )
.await?; .await?;
build_community_response(&context, local_user_view, community_id).await Ok(Json(SuccessResponse::default()))
} }

View File

@ -154,7 +154,6 @@ pub struct EditCommunity {
#[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))] #[cfg_attr(feature = "full", ts(export))]
/// Hide a community from the main view. /// 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 struct HideCommunity {
pub community_id: CommunityId, pub community_id: CommunityId,
pub hidden: bool, pub hidden: bool,

View File

@ -3,11 +3,16 @@ use crate::newtypes::LocalUserId;
use crate::schema::login_token; use crate::schema::login_token;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize}; 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. /// Stores data related to a specific user login session.
#[skip_serializing_none]
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] #[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", diesel(table_name = login_token))]
#[cfg_attr(feature = "full", ts(export))]
pub struct LoginToken { pub struct LoginToken {
pub id: i32, pub id: i32,
/// Jwt token for this login /// Jwt token for this login

View File

@ -275,7 +275,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
.route("/ban", web::post().to(ban_from_site)) .route("/ban", web::post().to(ban_from_site))
.route("/banned", web::get().to(list_banned_users)) .route("/banned", web::get().to(list_banned_users))
.route("/block", web::post().to(block_person)) .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("/login", web::post().to(login))
.route("/logout", web::post().to(logout)) .route("/logout", web::post().to(logout))
.route("/delete_account", web::post().to(delete_account)) .route("/delete_account", web::post().to(delete_account))
@ -284,7 +284,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
"/password_change", "/password_change",
web::post().to(change_password_after_reset), 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( .route(
"/mark_all_as_read", "/mark_all_as_read",
web::post().to(mark_all_notifications_read), web::post().to(mark_all_notifications_read),