mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-26 10:46:10 +00:00
Adding ts-rs directives for login_token. (#4063)
* Adding ts-rs directives for login_token. * Fixing ts-rs derive.
This commit is contained in:
parent
c1db65c6e5
commit
cae25486e4
|
@ -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<HideCommunity>,
|
||||
context: Data<LemmyContext>,
|
||||
local_user_view: LocalUserView,
|
||||
) -> Result<Json<CommunityResponse>, LemmyError> {
|
||||
) -> Result<Json<SuccessResponse>, 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()))
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue