mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-02-27 08:06:42 +00:00
Fixing some merge issues.
This commit is contained in:
parent
d912b00fdc
commit
eec0de7db5
4 changed files with 17 additions and 4 deletions
|
@ -40,6 +40,7 @@ use lemmy_db_schema::{
|
|||
ModTransferCommunityForm,
|
||||
},
|
||||
person::Person,
|
||||
site::Site,
|
||||
},
|
||||
traits::{Bannable, Blockable, Crud, Followable, Joinable},
|
||||
};
|
||||
|
|
|
@ -473,7 +473,7 @@ impl Perform for TransferSite {
|
|||
|
||||
is_admin(&local_user_view)?;
|
||||
|
||||
let read_site = blocking(context.pool(), Site::read_simple).await??;
|
||||
let read_site = blocking(context.pool(), Site::read_local_site).await??;
|
||||
|
||||
// Make sure user is the creator
|
||||
if read_site.creator_id != local_user_view.person.id {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{source::site::*, traits::Crud, DbUrl};
|
||||
use crate::{naive_now, newtypes::PersonId, source::site::*, traits::Crud, DbUrl};
|
||||
use diesel::{dsl::*, result::Error, *};
|
||||
use url::Url;
|
||||
|
||||
|
@ -28,6 +28,13 @@ impl Crud for Site {
|
|||
}
|
||||
|
||||
impl Site {
|
||||
pub fn transfer(conn: &PgConnection, new_creator_id: PersonId) -> Result<Site, Error> {
|
||||
use crate::schema::site::dsl::*;
|
||||
diesel::update(site.find(1))
|
||||
.set((creator_id.eq(new_creator_id), updated.eq(naive_now())))
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
pub fn read_local_site(conn: &PgConnection) -> Result<Self, Error> {
|
||||
use crate::schema::site::dsl::*;
|
||||
site.order_by(id).first::<Self>(conn)
|
||||
|
|
|
@ -19,8 +19,9 @@ pub struct SiteView {
|
|||
|
||||
impl SiteView {
|
||||
pub fn read(conn: &PgConnection) -> Result<Self, Error> {
|
||||
let (mut site, counts) = site::table
|
||||
let (mut site, creator, counts) = site::table
|
||||
.inner_join(site_aggregates::table)
|
||||
.inner_join(person::table)
|
||||
.select((
|
||||
site::all_columns,
|
||||
Person::safe_columns_tuple(),
|
||||
|
@ -29,6 +30,10 @@ impl SiteView {
|
|||
.first::<(Site, PersonSafe, SiteAggregates)>(conn)?;
|
||||
|
||||
site.private_key = None;
|
||||
Ok(SiteView { site, counts })
|
||||
Ok(SiteView {
|
||||
site,
|
||||
creator,
|
||||
counts,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue