From ef49a0eb8d2e173c8e1db9235358f3c11280c061 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 10 Sep 2024 06:41:30 -0400 Subject: [PATCH] Changing list_logins to return a ListLoginsResponse object. (#4888) - Fixes #4873 --- crates/api/src/local_user/list_logins.rs | 6 +++--- crates/api_common/src/person.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/api/src/local_user/list_logins.rs b/crates/api/src/local_user/list_logins.rs index 013236dcd..b5aaf8972 100644 --- a/crates/api/src/local_user/list_logins.rs +++ b/crates/api/src/local_user/list_logins.rs @@ -1,5 +1,5 @@ use actix_web::web::{Data, Json}; -use lemmy_api_common::context::LemmyContext; +use lemmy_api_common::{context::LemmyContext, person::ListLoginsResponse}; use lemmy_db_schema::source::login_token::LoginToken; use lemmy_db_views::structs::LocalUserView; use lemmy_utils::error::LemmyResult; @@ -7,8 +7,8 @@ use lemmy_utils::error::LemmyResult; pub async fn list_logins( context: Data, local_user_view: LocalUserView, -) -> LemmyResult>> { +) -> LemmyResult> { let logins = LoginToken::list(&mut context.pool(), local_user_view.local_user.id).await?; - Ok(Json(logins)) + Ok(Json(ListLoginsResponse { logins })) } diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index f61f784c2..29e9ef084 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -1,7 +1,7 @@ use lemmy_db_schema::{ newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId}, sensitive::SensitiveString, - source::site::Site, + source::{login_token::LoginToken, site::Site}, CommentSortType, ListingType, PostListingMode, @@ -441,3 +441,10 @@ pub struct ListMedia { pub struct ListMediaResponse { pub images: Vec, } + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[cfg_attr(feature = "full", derive(TS))] +#[cfg_attr(feature = "full", ts(export))] +pub struct ListLoginsResponse { + pub logins: Vec, +}