blocking(context.pool(), move |conn| ModAdd::create(conn, &form)).await??;
// Reread site and admins
- let site_view = blocking(context.pool(), SiteView::read).await??;
+ let site_view = blocking(context.pool(), SiteView::read_local).await??;
let admins = blocking(context.pool(), PersonViewSafe::admins).await??;
let federated_instances = build_federated_instances(
return Err(LemmyError::from_message("site_already_exists"));
}
- let site_view = blocking(context.pool(), SiteView::read).await??;
+ let site_view = blocking(context.pool(), SiteView::read_local).await??;
Ok(SiteResponse { site_view })
}
) -> Result<GetSiteResponse, LemmyError> {
let data: &GetSite = self;
- let site_view = match blocking(context.pool(), SiteView::read).await? {
+ let site_view = match blocking(context.pool(), SiteView::read_local).await? {
Ok(site_view) => Some(site_view),
// If the site isn't created yet, check the setup
Err(_) => {
};
create_site.perform(context, websocket_id).await?;
info!("Site {} created", setup.site_name);
- Some(blocking(context.pool(), SiteView::read).await??)
+ Some(blocking(context.pool(), SiteView::read_local).await??)
} else {
None
}
.map_err(|e| e.with_message("couldnt_set_all_email_verified"))?;
}
- let site_view = blocking(context.pool(), SiteView::read).await??;
+ let site_view = blocking(context.pool(), SiteView::read_local).await??;
let res = SiteResponse { site_view };
}
impl SiteView {
- pub fn read(conn: &PgConnection) -> Result<Self, Error> {
+ pub fn read_local(conn: &PgConnection) -> Result<Self, Error> {
let (mut site, counts) = site::table
.inner_join(site_aggregates::table)
.select((site::all_columns, site_aggregates::all_columns))
+ .order_by(site::id)
.first::<(Site, SiteAggregates)>(conn)?;
site.private_key = None;
listing_type: ListingType,
sort_type: SortType,
) -> Result<HttpResponse, LemmyError> {
- let site_view = blocking(context.pool(), SiteView::read).await??;
+ let site_view = blocking(context.pool(), SiteView::read_local).await??;
let posts = blocking(context.pool(), move |conn| {
PostQueryBuilder::create(conn)
user_name: &str,
protocol_and_hostname: &str,
) -> Result<ChannelBuilder, LemmyError> {
- let site_view = SiteView::read(conn)?;
+ let site_view = SiteView::read_local(conn)?;
let person = Person::read_from_name(conn, user_name)?;
let posts = PostQueryBuilder::create(conn)
community_name: &str,
protocol_and_hostname: &str,
) -> Result<ChannelBuilder, LemmyError> {
- let site_view = SiteView::read(conn)?;
+ let site_view = SiteView::read_local(conn)?;
let community = Community::read_from_name(conn, community_name)?;
let posts = PostQueryBuilder::create(conn)
jwt: &str,
protocol_and_hostname: &str,
) -> Result<ChannelBuilder, LemmyError> {
- let site_view = SiteView::read(conn)?;
+ let site_view = SiteView::read_local(conn)?;
let local_user_id = LocalUserId(Claims::decode(jwt, jwt_secret)?.claims.sub);
let local_user = LocalUser::read(conn, local_user_id)?;
jwt: &str,
protocol_and_hostname: &str,
) -> Result<ChannelBuilder, LemmyError> {
- let site_view = SiteView::read(conn)?;
+ let site_view = SiteView::read_local(conn)?;
let local_user_id = LocalUserId(Claims::decode(jwt, jwt_secret)?.claims.sub);
let local_user = LocalUser::read(conn, local_user_id)?;
let person_id = local_user.person_id;
}
async fn node_info(context: web::Data<LemmyContext>) -> Result<HttpResponse, Error> {
- let site_view = blocking(context.pool(), SiteView::read)
+ let site_view = blocking(context.pool(), SiteView::read_local)
.await?
.map_err(|_| ErrorBadRequest(LemmyError::from(anyhow!("not_found"))))?;