let data: &EditSite = self;
let local_user_view =
get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
- let local_site = LocalSite::read(context.pool()).await?;
+ let site_view = SiteView::read_local(context.pool()).await?;
+ let local_site = site_view.local_site;
+ let site = site_view.site;
// Make sure user is an admin
is_admin(&local_user_view)?;
}
}
- let site_id = local_site.site_id;
if let Some(discussion_languages) = data.discussion_languages.clone() {
- let site = Site::read(context.pool(), site_id).await?;
SiteLanguage::update(context.pool(), discussion_languages.clone(), &site).await?;
}
.updated(Some(Some(naive_now())))
.build();
- Site::update(context.pool(), site_id, &site_form)
+ Site::update(context.pool(), site.id, &site_form)
.await
// Ignore errors for all these, so as to not throw errors if no update occurs
// Diesel will throw an error for empty update forms
type UpdateForm = SiteUpdateForm;
type IdType = SiteId;
- async fn read(pool: &DbPool, _site_id: SiteId) -> Result<Self, Error> {
- let conn = &mut get_conn(pool).await?;
- site.first::<Self>(conn).await
+ /// Use SiteView::read_local, or Site::read_from_apub_id instead
+ async fn read(_pool: &DbPool, _site_id: SiteId) -> Result<Self, Error> {
+ unimplemented!()
}
async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {