mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-12 02:19:21 +00:00
Remove local_site_id from tagline and custom_emoji
This commit is contained in:
parent
562c909f4b
commit
6935acba2f
|
@ -61,7 +61,7 @@ pub async fn leave_admin(
|
||||||
let all_languages = Language::read_all(&mut context.pool()).await?;
|
let all_languages = Language::read_all(&mut context.pool()).await?;
|
||||||
let discussion_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?;
|
let discussion_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?;
|
||||||
let blocked_urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;
|
let blocked_urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;
|
||||||
let tagline = Tagline::get_random(&mut context.pool(), site_view.local_site.id).await?;
|
let tagline = Tagline::get_random(&mut context.pool()).await?;
|
||||||
|
|
||||||
Ok(Json(GetSiteResponse {
|
Ok(Json(GetSiteResponse {
|
||||||
site_view,
|
site_view,
|
||||||
|
|
|
@ -9,7 +9,6 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
custom_emoji::{CustomEmoji, CustomEmojiInsertForm},
|
custom_emoji::{CustomEmoji, CustomEmojiInsertForm},
|
||||||
custom_emoji_keyword::{CustomEmojiKeyword, CustomEmojiKeywordInsertForm},
|
custom_emoji_keyword::{CustomEmojiKeyword, CustomEmojiKeywordInsertForm},
|
||||||
local_site::LocalSite,
|
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
@ -22,12 +21,10 @@ pub async fn create_custom_emoji(
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
) -> Result<Json<CustomEmojiResponse>, LemmyError> {
|
) -> Result<Json<CustomEmojiResponse>, LemmyError> {
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
|
||||||
// Make sure user is an admin
|
// Make sure user is an admin
|
||||||
is_admin(&local_user_view)?;
|
is_admin(&local_user_view)?;
|
||||||
|
|
||||||
let emoji_form = CustomEmojiInsertForm::builder()
|
let emoji_form = CustomEmojiInsertForm::builder()
|
||||||
.local_site_id(local_site.id)
|
|
||||||
.shortcode(data.shortcode.to_lowercase().trim().to_string())
|
.shortcode(data.shortcode.to_lowercase().trim().to_string())
|
||||||
.alt_text(data.alt_text.to_string())
|
.alt_text(data.alt_text.to_string())
|
||||||
.category(data.category.to_string())
|
.category(data.category.to_string())
|
||||||
|
|
|
@ -3,7 +3,7 @@ use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
custom_emoji::{ListCustomEmojis, ListCustomEmojisResponse},
|
custom_emoji::{ListCustomEmojis, ListCustomEmojisResponse},
|
||||||
};
|
};
|
||||||
use lemmy_db_views::structs::{CustomEmojiView, LocalUserView, SiteView};
|
use lemmy_db_views::structs::{CustomEmojiView, LocalUserView};
|
||||||
use lemmy_utils::error::LemmyError;
|
use lemmy_utils::error::LemmyError;
|
||||||
|
|
||||||
#[tracing::instrument(skip(context))]
|
#[tracing::instrument(skip(context))]
|
||||||
|
@ -12,15 +12,8 @@ pub async fn list_custom_emojis(
|
||||||
local_user_view: Option<LocalUserView>,
|
local_user_view: Option<LocalUserView>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
) -> Result<Json<ListCustomEmojisResponse>, LemmyError> {
|
) -> Result<Json<ListCustomEmojisResponse>, LemmyError> {
|
||||||
let local_site = SiteView::read_local(&mut context.pool()).await?;
|
let custom_emojis =
|
||||||
let custom_emojis = CustomEmojiView::list(
|
CustomEmojiView::list(&mut context.pool(), &data.category, data.page, data.limit).await?;
|
||||||
&mut context.pool(),
|
|
||||||
local_site.local_site.id,
|
|
||||||
&data.category,
|
|
||||||
data.page,
|
|
||||||
data.limit,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(Json(ListCustomEmojisResponse { custom_emojis }))
|
Ok(Json(ListCustomEmojisResponse { custom_emojis }))
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ use lemmy_db_schema::{
|
||||||
source::{
|
source::{
|
||||||
custom_emoji::{CustomEmoji, CustomEmojiUpdateForm},
|
custom_emoji::{CustomEmoji, CustomEmojiUpdateForm},
|
||||||
custom_emoji_keyword::{CustomEmojiKeyword, CustomEmojiKeywordInsertForm},
|
custom_emoji_keyword::{CustomEmojiKeyword, CustomEmojiKeywordInsertForm},
|
||||||
local_site::LocalSite,
|
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
@ -22,12 +21,10 @@ pub async fn update_custom_emoji(
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
local_user_view: LocalUserView,
|
local_user_view: LocalUserView,
|
||||||
) -> Result<Json<CustomEmojiResponse>, LemmyError> {
|
) -> Result<Json<CustomEmojiResponse>, LemmyError> {
|
||||||
let local_site = LocalSite::read(&mut context.pool()).await?;
|
|
||||||
// Make sure user is an admin
|
// Make sure user is an admin
|
||||||
is_admin(&local_user_view)?;
|
is_admin(&local_user_view)?;
|
||||||
|
|
||||||
let emoji_form = CustomEmojiUpdateForm::builder()
|
let emoji_form = CustomEmojiUpdateForm::builder()
|
||||||
.local_site_id(local_site.id)
|
|
||||||
.alt_text(data.alt_text.to_string())
|
.alt_text(data.alt_text.to_string())
|
||||||
.category(data.category.to_string())
|
.category(data.category.to_string())
|
||||||
.image_url(data.clone().image_url.into())
|
.image_url(data.clone().image_url.into())
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub async fn get_site(
|
||||||
let all_languages = Language::read_all(&mut context.pool()).await?;
|
let all_languages = Language::read_all(&mut context.pool()).await?;
|
||||||
let discussion_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?;
|
let discussion_languages = SiteLanguage::read_local_raw(&mut context.pool()).await?;
|
||||||
let blocked_urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;
|
let blocked_urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;
|
||||||
let tagline = Tagline::get_random(&mut context.pool(), site_view.local_site.id).await?;
|
let tagline = Tagline::get_random(&mut context.pool()).await?;
|
||||||
Ok(GetSiteResponse {
|
Ok(GetSiteResponse {
|
||||||
site_view,
|
site_view,
|
||||||
admins,
|
admins,
|
||||||
|
|
|
@ -31,10 +31,7 @@ pub async fn create_tagline(
|
||||||
let content = process_markdown(&data.content, &slur_regex, &url_blocklist, &context).await?;
|
let content = process_markdown(&data.content, &slur_regex, &url_blocklist, &context).await?;
|
||||||
is_valid_tagline_content(&content)?;
|
is_valid_tagline_content(&content)?;
|
||||||
|
|
||||||
let tagline_form = TaglineInsertForm {
|
let tagline_form = TaglineInsertForm { content };
|
||||||
local_site_id: local_site.id,
|
|
||||||
content,
|
|
||||||
};
|
|
||||||
|
|
||||||
let tagline = Tagline::create(&mut context.pool(), &tagline_form).await?;
|
let tagline = Tagline::create(&mut context.pool(), &tagline_form).await?;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use lemmy_api_common::{
|
||||||
tagline::{ListTaglines, ListTaglinesResponse},
|
tagline::{ListTaglines, ListTaglinesResponse},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::source::tagline::Tagline;
|
use lemmy_db_schema::source::tagline::Tagline;
|
||||||
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
use lemmy_db_views::structs::LocalUserView;
|
||||||
use lemmy_utils::error::LemmyError;
|
use lemmy_utils::error::LemmyError;
|
||||||
|
|
||||||
#[tracing::instrument(skip(context))]
|
#[tracing::instrument(skip(context))]
|
||||||
|
@ -13,14 +13,7 @@ pub async fn list_taglines(
|
||||||
local_user_view: Option<LocalUserView>,
|
local_user_view: Option<LocalUserView>,
|
||||||
context: Data<LemmyContext>,
|
context: Data<LemmyContext>,
|
||||||
) -> Result<Json<ListTaglinesResponse>, LemmyError> {
|
) -> Result<Json<ListTaglinesResponse>, LemmyError> {
|
||||||
let local_site = SiteView::read_local(&mut context.pool()).await?;
|
let taglines = Tagline::list(&mut context.pool(), data.page, data.limit).await?;
|
||||||
let taglines = Tagline::list(
|
|
||||||
&mut context.pool(),
|
|
||||||
local_site.local_site.id,
|
|
||||||
data.page,
|
|
||||||
data.limit,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(Json(ListTaglinesResponse { taglines }))
|
Ok(Json(ListTaglinesResponse { taglines }))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
newtypes::{LocalSiteId, TaglineId},
|
newtypes::TaglineId,
|
||||||
schema::tagline::dsl::{local_site_id, published, tagline},
|
schema::tagline::dsl::{published, tagline},
|
||||||
source::tagline::{Tagline, TaglineInsertForm, TaglineUpdateForm},
|
source::tagline::{Tagline, TaglineInsertForm, TaglineUpdateForm},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
utils::{get_conn, limit_and_offset, DbPool},
|
utils::{get_conn, limit_and_offset, DbPool},
|
||||||
|
@ -38,7 +38,6 @@ impl Crud for Tagline {
|
||||||
impl Tagline {
|
impl Tagline {
|
||||||
pub async fn list(
|
pub async fn list(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
for_local_site_id: LocalSiteId,
|
|
||||||
page: Option<i64>,
|
page: Option<i64>,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
) -> Result<Vec<Self>, Error> {
|
) -> Result<Vec<Self>, Error> {
|
||||||
|
@ -48,21 +47,16 @@ impl Tagline {
|
||||||
.order(published.desc())
|
.order(published.desc())
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.filter(local_site_id.eq(for_local_site_id))
|
|
||||||
.get_results::<Self>(conn)
|
.get_results::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_random(
|
pub async fn get_random(pool: &mut DbPool<'_>) -> Result<Option<Self>, Error> {
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
for_local_site_id: LocalSiteId,
|
|
||||||
) -> Result<Option<Self>, Error> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
sql_function!(fn random() -> Text);
|
sql_function!(fn random() -> Text);
|
||||||
tagline
|
tagline
|
||||||
.order(random())
|
.order(random())
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.filter(local_site_id.eq(for_local_site_id))
|
|
||||||
.first::<Self>(conn)
|
.first::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
.optional()
|
.optional()
|
||||||
|
|
|
@ -254,7 +254,6 @@ diesel::table! {
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
custom_emoji (id) {
|
custom_emoji (id) {
|
||||||
id -> Int4,
|
id -> Int4,
|
||||||
local_site_id -> Int4,
|
|
||||||
#[max_length = 128]
|
#[max_length = 128]
|
||||||
shortcode -> Varchar,
|
shortcode -> Varchar,
|
||||||
image_url -> Text,
|
image_url -> Text,
|
||||||
|
@ -929,7 +928,6 @@ diesel::table! {
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
tagline (id) {
|
tagline (id) {
|
||||||
id -> Int4,
|
id -> Int4,
|
||||||
local_site_id -> Int4,
|
|
||||||
content -> Text,
|
content -> Text,
|
||||||
published -> Timestamptz,
|
published -> Timestamptz,
|
||||||
updated -> Nullable<Timestamptz>,
|
updated -> Nullable<Timestamptz>,
|
||||||
|
@ -966,7 +964,6 @@ diesel::joinable!(community_moderator -> community (community_id));
|
||||||
diesel::joinable!(community_moderator -> person (person_id));
|
diesel::joinable!(community_moderator -> person (person_id));
|
||||||
diesel::joinable!(community_person_ban -> community (community_id));
|
diesel::joinable!(community_person_ban -> community (community_id));
|
||||||
diesel::joinable!(community_person_ban -> person (person_id));
|
diesel::joinable!(community_person_ban -> person (person_id));
|
||||||
diesel::joinable!(custom_emoji -> local_site (local_site_id));
|
|
||||||
diesel::joinable!(custom_emoji_keyword -> custom_emoji (custom_emoji_id));
|
diesel::joinable!(custom_emoji_keyword -> custom_emoji (custom_emoji_id));
|
||||||
diesel::joinable!(email_verification -> local_user (local_user_id));
|
diesel::joinable!(email_verification -> local_user (local_user_id));
|
||||||
diesel::joinable!(federation_allowlist -> instance (instance_id));
|
diesel::joinable!(federation_allowlist -> instance (instance_id));
|
||||||
|
@ -1028,7 +1025,6 @@ diesel::joinable!(site -> instance (instance_id));
|
||||||
diesel::joinable!(site_aggregates -> site (site_id));
|
diesel::joinable!(site_aggregates -> site (site_id));
|
||||||
diesel::joinable!(site_language -> language (language_id));
|
diesel::joinable!(site_language -> language (language_id));
|
||||||
diesel::joinable!(site_language -> site (site_id));
|
diesel::joinable!(site_language -> site (site_id));
|
||||||
diesel::joinable!(tagline -> local_site (local_site_id));
|
|
||||||
|
|
||||||
diesel::allow_tables_to_appear_in_same_query!(
|
diesel::allow_tables_to_appear_in_same_query!(
|
||||||
admin_purge_comment,
|
admin_purge_comment,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::newtypes::{CustomEmojiId, DbUrl, LocalSiteId};
|
use crate::newtypes::{CustomEmojiId, DbUrl};
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
use crate::schema::custom_emoji;
|
use crate::schema::custom_emoji;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
@ -10,21 +10,13 @@ use typed_builder::TypedBuilder;
|
||||||
|
|
||||||
#[skip_serializing_none]
|
#[skip_serializing_none]
|
||||||
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
||||||
feature = "full",
|
|
||||||
derive(Queryable, Selectable, Associations, Identifiable, TS)
|
|
||||||
)]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
|
#[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
|
||||||
#[cfg_attr(
|
|
||||||
feature = "full",
|
|
||||||
diesel(belongs_to(crate::source::local_site::LocalSite))
|
|
||||||
)]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
/// A custom emoji.
|
/// A custom emoji.
|
||||||
pub struct CustomEmoji {
|
pub struct CustomEmoji {
|
||||||
pub id: CustomEmojiId,
|
pub id: CustomEmojiId,
|
||||||
pub local_site_id: LocalSiteId,
|
|
||||||
pub shortcode: String,
|
pub shortcode: String,
|
||||||
pub image_url: DbUrl,
|
pub image_url: DbUrl,
|
||||||
pub alt_text: String,
|
pub alt_text: String,
|
||||||
|
@ -37,7 +29,6 @@ pub struct CustomEmoji {
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
|
#[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
|
||||||
pub struct CustomEmojiInsertForm {
|
pub struct CustomEmojiInsertForm {
|
||||||
pub local_site_id: LocalSiteId,
|
|
||||||
pub shortcode: String,
|
pub shortcode: String,
|
||||||
pub image_url: DbUrl,
|
pub image_url: DbUrl,
|
||||||
pub alt_text: String,
|
pub alt_text: String,
|
||||||
|
@ -48,7 +39,6 @@ pub struct CustomEmojiInsertForm {
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
|
#[cfg_attr(feature = "full", diesel(table_name = custom_emoji))]
|
||||||
pub struct CustomEmojiUpdateForm {
|
pub struct CustomEmojiUpdateForm {
|
||||||
pub local_site_id: LocalSiteId,
|
|
||||||
pub image_url: DbUrl,
|
pub image_url: DbUrl,
|
||||||
pub alt_text: String,
|
pub alt_text: String,
|
||||||
pub category: String,
|
pub category: String,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use crate::newtypes::LocalSiteId;
|
|
||||||
#[cfg(feature = "full")]
|
#[cfg(feature = "full")]
|
||||||
use crate::schema::tagline;
|
use crate::schema::tagline;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
@ -9,21 +8,13 @@ use ts_rs::TS;
|
||||||
|
|
||||||
#[skip_serializing_none]
|
#[skip_serializing_none]
|
||||||
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(feature = "full", derive(Queryable, Selectable, Identifiable, TS))]
|
||||||
feature = "full",
|
|
||||||
derive(Queryable, Selectable, Associations, Identifiable, TS)
|
|
||||||
)]
|
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = tagline))]
|
#[cfg_attr(feature = "full", diesel(table_name = tagline))]
|
||||||
#[cfg_attr(
|
|
||||||
feature = "full",
|
|
||||||
diesel(belongs_to(crate::source::local_site::LocalSite))
|
|
||||||
)]
|
|
||||||
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
/// A tagline, shown at the top of your site.
|
/// A tagline, shown at the top of your site.
|
||||||
pub struct Tagline {
|
pub struct Tagline {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub local_site_id: LocalSiteId,
|
|
||||||
pub content: String,
|
pub content: String,
|
||||||
pub published: DateTime<Utc>,
|
pub published: DateTime<Utc>,
|
||||||
pub updated: Option<DateTime<Utc>>,
|
pub updated: Option<DateTime<Utc>>,
|
||||||
|
@ -33,7 +24,6 @@ pub struct Tagline {
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = tagline))]
|
#[cfg_attr(feature = "full", diesel(table_name = tagline))]
|
||||||
pub struct TaglineInsertForm {
|
pub struct TaglineInsertForm {
|
||||||
pub local_site_id: LocalSiteId,
|
|
||||||
pub content: String,
|
pub content: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::structs::CustomEmojiView;
|
||||||
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, NullableExpressionMethods, QueryDsl};
|
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, NullableExpressionMethods, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
newtypes::{CustomEmojiId, LocalSiteId},
|
newtypes::CustomEmojiId,
|
||||||
schema::{custom_emoji, custom_emoji_keyword},
|
schema::{custom_emoji, custom_emoji_keyword},
|
||||||
source::{custom_emoji::CustomEmoji, custom_emoji_keyword::CustomEmojiKeyword},
|
source::{custom_emoji::CustomEmoji, custom_emoji_keyword::CustomEmojiKeyword},
|
||||||
utils::{get_conn, limit_and_offset, DbPool},
|
utils::{get_conn, limit_and_offset, DbPool},
|
||||||
|
@ -35,13 +35,9 @@ impl CustomEmojiView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_all(
|
pub async fn get_all(pool: &mut DbPool<'_>) -> Result<Vec<Self>, Error> {
|
||||||
pool: &mut DbPool<'_>,
|
|
||||||
for_local_site_id: LocalSiteId,
|
|
||||||
) -> Result<Vec<Self>, Error> {
|
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
let emojis = custom_emoji::table
|
let emojis = custom_emoji::table
|
||||||
.filter(custom_emoji::local_site_id.eq(for_local_site_id))
|
|
||||||
.left_join(
|
.left_join(
|
||||||
custom_emoji_keyword::table.on(custom_emoji_keyword::custom_emoji_id.eq(custom_emoji::id)),
|
custom_emoji_keyword::table.on(custom_emoji_keyword::custom_emoji_id.eq(custom_emoji::id)),
|
||||||
)
|
)
|
||||||
|
@ -59,7 +55,6 @@ impl CustomEmojiView {
|
||||||
|
|
||||||
pub async fn list(
|
pub async fn list(
|
||||||
pool: &mut DbPool<'_>,
|
pool: &mut DbPool<'_>,
|
||||||
for_local_site_id: LocalSiteId,
|
|
||||||
category: &Option<String>,
|
category: &Option<String>,
|
||||||
page: Option<i64>,
|
page: Option<i64>,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
|
@ -72,8 +67,6 @@ impl CustomEmojiView {
|
||||||
)
|
)
|
||||||
.into_boxed();
|
.into_boxed();
|
||||||
|
|
||||||
query = query.filter(custom_emoji::local_site_id.eq(for_local_site_id));
|
|
||||||
|
|
||||||
if let Some(category) = category {
|
if let Some(category) = category {
|
||||||
query = query.filter(custom_emoji::category.eq(category))
|
query = query.filter(custom_emoji::category.eq(category))
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
ALTER TABLE custom_emoji
|
||||||
|
ADD COLUMN local_site_id int REFERENCES local_site (site_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
custom_emoji
|
||||||
|
SET
|
||||||
|
local_site_id = (
|
||||||
|
SELECT
|
||||||
|
site_id
|
||||||
|
FROM
|
||||||
|
local_site
|
||||||
|
LIMIT 1);
|
||||||
|
|
||||||
|
ALTER TABLE custom_emoji
|
||||||
|
ALTER COLUMN local_site_id SET NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE tagline
|
||||||
|
ADD COLUMN local_site_id int REFERENCES local_site (site_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
tagline
|
||||||
|
SET
|
||||||
|
local_site_id = (
|
||||||
|
SELECT
|
||||||
|
site_id
|
||||||
|
FROM
|
||||||
|
local_site
|
||||||
|
LIMIT 1);
|
||||||
|
|
||||||
|
ALTER TABLE tagline
|
||||||
|
ALTER COLUMN local_site_id SET NOT NULL;
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
ALTER TABLE custom_emoji
|
||||||
|
DROP COLUMN local_site_id;
|
||||||
|
|
||||||
|
ALTER TABLE tagline
|
||||||
|
DROP COLUMN local_site_id;
|
||||||
|
|
Loading…
Reference in a new issue