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::{
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);

View file

@ -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);

View file

@ -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);

View file

@ -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<String
channel_builder.description(&site_desc);
}
Ok(
channel_builder
.build()
.map_err(|_| anyhow!(location_info!()))?
.to_string(),
)
Ok(channel_builder.build().map_err(|e| anyhow!(e))?.to_string())
}
async fn get_feed(
@ -252,9 +247,8 @@ fn create_reply_and_mention_items(
r.id
);
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
.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::<Result<Vec<Item>, 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<PostView>) -> Result<Vec<Item>, LemmyError> {
@ -326,7 +319,7 @@ fn create_post_items(posts: Vec<PostView>) -> Result<Vec<Item>, 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<PostView>) -> Result<Vec<Item>, 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<PostView>) -> Result<Vec<Item>, LemmyError> {
i.description(description);
items.push(i.build().map_err(|_| anyhow!(location_info!()))?);
items.push(i.build().map_err(|e| anyhow!(e))?);
}
Ok(items)