From 1c9ef671edf10403b08a93690f016de7dba55d53 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 13 Aug 2020 10:36:49 -0400 Subject: [PATCH] Changing some location_infos. --- server/src/api/community.rs | 5 +++-- server/src/api/site.rs | 4 ++-- server/src/api/user.rs | 3 ++- server/src/routes/feeds.rs | 25 +++++++++---------------- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/server/src/api/community.rs b/server/src/api/community.rs index 33695cd96..b8215cc44 100644 --- a/server/src/api/community.rs +++ b/server/src/api/community.rs @@ -24,6 +24,7 @@ use lemmy_db::{ use lemmy_utils::{ generate_actor_keypair, is_valid_community_name, + location_info, make_apub_endpoint, naive_from_unix, EndpointType, @@ -826,7 +827,7 @@ impl Perform for TransferCommunity { let creator_index = admins .iter() .position(|r| r.id == site_creator_id) - .context("missing creator")?; + .context(location_info!())?; let creator_user = admins.remove(creator_index); admins.insert(0, creator_user); @@ -851,7 +852,7 @@ impl Perform for TransferCommunity { let creator_index = community_mods .iter() .position(|r| r.user_id == data.user_id) - .context("missing creator")?; + .context(location_info!())?; let creator_user = community_mods.remove(creator_index); community_mods.insert(0, creator_user); diff --git a/server/src/api/site.rs b/server/src/api/site.rs index 2b954a781..d4999ad3a 100644 --- a/server/src/api/site.rs +++ b/server/src/api/site.rs @@ -35,7 +35,7 @@ use lemmy_db::{ SearchType, SortType, }; -use lemmy_utils::settings::Settings; +use lemmy_utils::{location_info, settings::Settings}; use log::{debug, info}; use serde::{Deserialize, Serialize}; use std::str::FromStr; @@ -656,7 +656,7 @@ impl Perform for TransferSite { let creator_index = admins .iter() .position(|r| r.id == site_view.creator_id) - .context("missing creator")?; + .context(location_info!())?; let creator_user = admins.remove(creator_index); admins.insert(0, creator_user); diff --git a/server/src/api/user.rs b/server/src/api/user.rs index db9823848..d8c03b695 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -54,6 +54,7 @@ use lemmy_utils::{ generate_random_string, is_valid_preferred_username, is_valid_username, + location_info, make_apub_endpoint, naive_from_unix, remove_slurs, @@ -808,7 +809,7 @@ impl Perform for AddAdmin { let creator_index = admins .iter() .position(|r| r.id == site_creator_id) - .context("missing creator")?; + .context(location_info!())?; let creator_user = admins.remove(creator_index); admins.insert(0, creator_user); diff --git a/server/src/routes/feeds.rs b/server/src/routes/feeds.rs index c18b08b7a..e81d33b7f 100644 --- a/server/src/routes/feeds.rs +++ b/server/src/routes/feeds.rs @@ -16,7 +16,7 @@ use lemmy_db::{ ListingType, SortType, }; -use lemmy_utils::{location_info, markdown_to_html, settings::Settings}; +use lemmy_utils::{markdown_to_html, settings::Settings}; use rss::{CategoryBuilder, ChannelBuilder, GuidBuilder, Item, ItemBuilder}; use serde::Deserialize; use std::str::FromStr; @@ -74,12 +74,7 @@ fn get_feed_all_data(conn: &PgConnection, sort_type: &SortType) -> Result, LemmyError>>()?; let mut mention_items: Vec = mentions .iter() @@ -266,9 +260,8 @@ fn create_reply_and_mention_items( m.id ); build_item(&m.creator_name, &m.published, &mention_url, &m.content) - .unwrap_or_else(|_| panic!(location_info!())) }) - .collect(); + .collect::, LemmyError>>()?; reply_items.append(&mut mention_items); Ok(reply_items) @@ -294,13 +287,13 @@ fn build_item( .permalink(true) .value(url) .build() - .map_err(|_| anyhow!(location_info!()))?; + .map_err(|e| anyhow!(e))?; i.guid(guid); i.link(url.to_owned()); // TODO add images let html = markdown_to_html(&content.to_string()); i.description(html); - Ok(i.build().map_err(|_| anyhow!(location_info!()))?) + Ok(i.build().map_err(|e| anyhow!(e))?) } fn create_post_items(posts: Vec) -> Result, LemmyError> { @@ -326,7 +319,7 @@ fn create_post_items(posts: Vec) -> Result, LemmyError> { .permalink(true) .value(&post_url) .build() - .map_err(|_| anyhow!(location_info!()))?; + .map_err(|e| anyhow!(e))?; i.guid(guid); let community_url = format!( @@ -342,7 +335,7 @@ fn create_post_items(posts: Vec) -> Result, LemmyError> { )) .domain(Settings::get().hostname.to_owned()) .build() - .map_err(|_| anyhow!(location_info!()))?; + .map_err(|e| anyhow!(e))?; i.categories(vec![category]); @@ -367,7 +360,7 @@ fn create_post_items(posts: Vec) -> Result, LemmyError> { i.description(description); - items.push(i.build().map_err(|_| anyhow!(location_info!()))?); + items.push(i.build().map_err(|e| anyhow!(e))?); } Ok(items)