mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 12:21:18 +00:00
* Adding taglines to SiteResponse. Fixes #2925 * Fixing CI line.
This commit is contained in:
parent
bb625c3671
commit
ef1aa18fd2
5 changed files with 29 additions and 11 deletions
|
@ -263,7 +263,7 @@ pipeline:
|
|||
image: alpine:3
|
||||
commands:
|
||||
- apk add curl
|
||||
- "curl -d'Drone build failed: ${CI_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
|
||||
- "curl -d'Lemmy CI build failed: ${CI_BUILD_LINK}' ntfy.sh/lemmy_drone_ci"
|
||||
when:
|
||||
status: [failure]
|
||||
|
||||
|
|
|
@ -283,6 +283,7 @@ pub struct GetSite {
|
|||
/// The response for a site.
|
||||
pub struct SiteResponse {
|
||||
pub site_view: SiteView,
|
||||
pub taglines: Vec<Tagline>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
|
|
|
@ -19,6 +19,7 @@ use lemmy_db_schema::{
|
|||
local_site::{LocalSite, LocalSiteUpdateForm},
|
||||
local_site_rate_limit::{LocalSiteRateLimit, LocalSiteRateLimitUpdateForm},
|
||||
site::{Site, SiteUpdateForm},
|
||||
tagline::Tagline,
|
||||
},
|
||||
traits::Crud,
|
||||
utils::{diesel_option_overwrite, diesel_option_overwrite_to_url, naive_now},
|
||||
|
@ -146,6 +147,9 @@ impl PerformCrud for CreateSite {
|
|||
|
||||
let site_view = SiteView::read_local(context.pool()).await?;
|
||||
|
||||
let new_taglines = data.taglines.clone();
|
||||
let taglines = Tagline::replace(context.pool(), local_site.id, new_taglines).await?;
|
||||
|
||||
let rate_limit_config =
|
||||
local_site_rate_limit_to_rate_limit_config(&site_view.local_site_rate_limit);
|
||||
context
|
||||
|
@ -153,6 +157,9 @@ impl PerformCrud for CreateSite {
|
|||
.send(rate_limit_config)
|
||||
.await?;
|
||||
|
||||
Ok(SiteResponse { site_view })
|
||||
Ok(SiteResponse {
|
||||
site_view,
|
||||
taglines,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,8 +182,8 @@ impl PerformCrud for EditSite {
|
|||
.map_err(|e| LemmyError::from_error_message(e, "couldnt_set_all_email_verified"))?;
|
||||
}
|
||||
|
||||
let taglines = data.taglines.clone();
|
||||
Tagline::replace(context.pool(), local_site.id, taglines).await?;
|
||||
let new_taglines = data.taglines.clone();
|
||||
let taglines = Tagline::replace(context.pool(), local_site.id, new_taglines).await?;
|
||||
|
||||
let site_view = SiteView::read_local(context.pool()).await?;
|
||||
|
||||
|
@ -194,7 +194,10 @@ impl PerformCrud for EditSite {
|
|||
.send(rate_limit_config)
|
||||
.await?;
|
||||
|
||||
let res = SiteResponse { site_view };
|
||||
let res = SiteResponse {
|
||||
site_view,
|
||||
taglines,
|
||||
};
|
||||
|
||||
context.send_all_ws_message(&UserOperationCrud::EditSite, &res, websocket_id)?;
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ impl Tagline {
|
|||
pool: &DbPool,
|
||||
for_local_site_id: LocalSiteId,
|
||||
list_content: Option<Vec<String>>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
if let Some(list) = list_content {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
conn
|
||||
.build_transaction()
|
||||
.run(|conn| {
|
||||
|
@ -32,23 +32,30 @@ impl Tagline {
|
|||
.get_result::<Self>(conn)
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
Self::get_all_conn(conn, for_local_site_id).await
|
||||
}) as _
|
||||
})
|
||||
.await
|
||||
} else {
|
||||
Ok(())
|
||||
Self::get_all_conn(conn, for_local_site_id).await
|
||||
}
|
||||
}
|
||||
|
||||
async fn clear(conn: &mut AsyncPgConnection) -> Result<usize, Error> {
|
||||
diesel::delete(tagline).execute(conn).await
|
||||
}
|
||||
pub async fn get_all(pool: &DbPool, for_local_site_id: LocalSiteId) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
|
||||
async fn get_all_conn(
|
||||
conn: &mut AsyncPgConnection,
|
||||
for_local_site_id: LocalSiteId,
|
||||
) -> Result<Vec<Self>, Error> {
|
||||
tagline
|
||||
.filter(local_site_id.eq(for_local_site_id))
|
||||
.get_results::<Self>(conn)
|
||||
.await
|
||||
}
|
||||
pub async fn get_all(pool: &DbPool, for_local_site_id: LocalSiteId) -> Result<Vec<Self>, Error> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
Self::get_all_conn(conn, for_local_site_id).await
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue