Changing some location_infos.

This commit is contained in:
Dessalines 2020-08-13 10:36:49 -04:00
parent a43797e523
commit 1c9ef671ed
4 changed files with 16 additions and 21 deletions

View file

@ -24,6 +24,7 @@ use lemmy_db::{
use lemmy_utils::{ use lemmy_utils::{
generate_actor_keypair, generate_actor_keypair,
is_valid_community_name, is_valid_community_name,
location_info,
make_apub_endpoint, make_apub_endpoint,
naive_from_unix, naive_from_unix,
EndpointType, EndpointType,
@ -826,7 +827,7 @@ impl Perform for TransferCommunity {
let creator_index = admins let creator_index = admins
.iter() .iter()
.position(|r| r.id == site_creator_id) .position(|r| r.id == site_creator_id)
.context("missing creator")?; .context(location_info!())?;
let creator_user = admins.remove(creator_index); let creator_user = admins.remove(creator_index);
admins.insert(0, creator_user); admins.insert(0, creator_user);
@ -851,7 +852,7 @@ impl Perform for TransferCommunity {
let creator_index = community_mods let creator_index = community_mods
.iter() .iter()
.position(|r| r.user_id == data.user_id) .position(|r| r.user_id == data.user_id)
.context("missing creator")?; .context(location_info!())?;
let creator_user = community_mods.remove(creator_index); let creator_user = community_mods.remove(creator_index);
community_mods.insert(0, creator_user); community_mods.insert(0, creator_user);

View file

@ -35,7 +35,7 @@ use lemmy_db::{
SearchType, SearchType,
SortType, SortType,
}; };
use lemmy_utils::settings::Settings; use lemmy_utils::{location_info, settings::Settings};
use log::{debug, info}; use log::{debug, info};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::str::FromStr; use std::str::FromStr;
@ -656,7 +656,7 @@ impl Perform for TransferSite {
let creator_index = admins let creator_index = admins
.iter() .iter()
.position(|r| r.id == site_view.creator_id) .position(|r| r.id == site_view.creator_id)
.context("missing creator")?; .context(location_info!())?;
let creator_user = admins.remove(creator_index); let creator_user = admins.remove(creator_index);
admins.insert(0, creator_user); admins.insert(0, creator_user);

View file

@ -54,6 +54,7 @@ use lemmy_utils::{
generate_random_string, generate_random_string,
is_valid_preferred_username, is_valid_preferred_username,
is_valid_username, is_valid_username,
location_info,
make_apub_endpoint, make_apub_endpoint,
naive_from_unix, naive_from_unix,
remove_slurs, remove_slurs,
@ -808,7 +809,7 @@ impl Perform for AddAdmin {
let creator_index = admins let creator_index = admins
.iter() .iter()
.position(|r| r.id == site_creator_id) .position(|r| r.id == site_creator_id)
.context("missing creator")?; .context(location_info!())?;
let creator_user = admins.remove(creator_index); let creator_user = admins.remove(creator_index);
admins.insert(0, creator_user); admins.insert(0, creator_user);

View file

@ -16,7 +16,7 @@ use lemmy_db::{
ListingType, ListingType,
SortType, 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 rss::{CategoryBuilder, ChannelBuilder, GuidBuilder, Item, ItemBuilder};
use serde::Deserialize; use serde::Deserialize;
use std::str::FromStr; use std::str::FromStr;
@ -74,12 +74,7 @@ fn get_feed_all_data(conn: &PgConnection, sort_type: &SortType) -> Result<String
channel_builder.description(&site_desc); channel_builder.description(&site_desc);
} }
Ok( Ok(channel_builder.build().map_err(|e| anyhow!(e))?.to_string())
channel_builder
.build()
.map_err(|_| anyhow!(location_info!()))?
.to_string(),
)
} }
async fn get_feed( async fn get_feed(
@ -252,9 +247,8 @@ fn create_reply_and_mention_items(
r.id r.id
); );
build_item(&r.creator_name, &r.published, &reply_url, &r.content) build_item(&r.creator_name, &r.published, &reply_url, &r.content)
.unwrap_or_else(|_| panic!(location_info!()))
}) })
.collect(); .collect::<Result<Vec<Item>, LemmyError>>()?;
let mut mention_items: Vec<Item> = mentions let mut mention_items: Vec<Item> = mentions
.iter() .iter()
@ -266,9 +260,8 @@ fn create_reply_and_mention_items(
m.id m.id
); );
build_item(&m.creator_name, &m.published, &mention_url, &m.content) build_item(&m.creator_name, &m.published, &mention_url, &m.content)
.unwrap_or_else(|_| panic!(location_info!()))
}) })
.collect(); .collect::<Result<Vec<Item>, LemmyError>>()?;
reply_items.append(&mut mention_items); reply_items.append(&mut mention_items);
Ok(reply_items) Ok(reply_items)
@ -294,13 +287,13 @@ fn build_item(
.permalink(true) .permalink(true)
.value(url) .value(url)
.build() .build()
.map_err(|_| anyhow!(location_info!()))?; .map_err(|e| anyhow!(e))?;
i.guid(guid); i.guid(guid);
i.link(url.to_owned()); i.link(url.to_owned());
// TODO add images // TODO add images
let html = markdown_to_html(&content.to_string()); let html = markdown_to_html(&content.to_string());
i.description(html); 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<PostView>) -> Result<Vec<Item>, LemmyError> { fn create_post_items(posts: Vec<PostView>) -> Result<Vec<Item>, LemmyError> {
@ -326,7 +319,7 @@ fn create_post_items(posts: Vec<PostView>) -> Result<Vec<Item>, LemmyError> {
.permalink(true) .permalink(true)
.value(&post_url) .value(&post_url)
.build() .build()
.map_err(|_| anyhow!(location_info!()))?; .map_err(|e| anyhow!(e))?;
i.guid(guid); i.guid(guid);
let community_url = format!( let community_url = format!(
@ -342,7 +335,7 @@ fn create_post_items(posts: Vec<PostView>) -> Result<Vec<Item>, LemmyError> {
)) ))
.domain(Settings::get().hostname.to_owned()) .domain(Settings::get().hostname.to_owned())
.build() .build()
.map_err(|_| anyhow!(location_info!()))?; .map_err(|e| anyhow!(e))?;
i.categories(vec![category]); i.categories(vec![category]);
@ -367,7 +360,7 @@ fn create_post_items(posts: Vec<PostView>) -> Result<Vec<Item>, LemmyError> {
i.description(description); i.description(description);
items.push(i.build().map_err(|_| anyhow!(location_info!()))?); items.push(i.build().map_err(|e| anyhow!(e))?);
} }
Ok(items) Ok(items)