mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-01 01:21:19 +00:00
Merge branch 'main' into ap-id-triggers
This commit is contained in:
commit
279d4b05e0
|
@ -88,6 +88,7 @@ pub async fn get_post(
|
||||||
let cross_posts = if let Some(url) = &post_view.post.url {
|
let cross_posts = if let Some(url) = &post_view.post.url {
|
||||||
let mut x_posts = PostQuery {
|
let mut x_posts = PostQuery {
|
||||||
url_search: Some(url.inner().as_str().into()),
|
url_search: Some(url.inner().as_str().into()),
|
||||||
|
local_user: local_user_view.as_ref(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.list(&local_site.site, &mut context.pool())
|
.list(&local_site.site, &mut context.pool())
|
||||||
|
|
|
@ -118,8 +118,9 @@ impl Crud for Comment {
|
||||||
type IdType = CommentId;
|
type IdType = CommentId;
|
||||||
|
|
||||||
/// This is unimplemented, use [[Comment::create]]
|
/// This is unimplemented, use [[Comment::create]]
|
||||||
async fn create(_pool: &mut DbPool<'_>, _comment_form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, comment_form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
unimplemented!();
|
debug_assert!(false);
|
||||||
|
Comment::create(pool, comment_form, None).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(
|
async fn update(
|
||||||
|
|
|
@ -167,6 +167,14 @@ impl InstanceWorker {
|
||||||
latest_id
|
latest_id
|
||||||
};
|
};
|
||||||
if id >= latest_id {
|
if id >= latest_id {
|
||||||
|
if id > latest_id {
|
||||||
|
tracing::error!(
|
||||||
|
"{}: last successful id {} is higher than latest id {} in database (did the db get cleared?)",
|
||||||
|
self.instance.domain,
|
||||||
|
id.0,
|
||||||
|
latest_id.0
|
||||||
|
);
|
||||||
|
}
|
||||||
// no more work to be done, wait before rechecking
|
// no more work to be done, wait before rechecking
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
() = sleep(*WORK_FINISHED_RECHECK_DELAY) => {},
|
() = sleep(*WORK_FINISHED_RECHECK_DELAY) => {},
|
||||||
|
|
|
@ -11,7 +11,9 @@ static VALID_MATRIX_ID_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||||
});
|
});
|
||||||
// taken from https://en.wikipedia.org/wiki/UTM_parameters
|
// taken from https://en.wikipedia.org/wiki/UTM_parameters
|
||||||
static CLEAN_URL_PARAMS_REGEX: Lazy<Regex> = Lazy::new(|| {
|
static CLEAN_URL_PARAMS_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||||
Regex::new(r"^utm_source|utm_medium|utm_campaign|utm_term|utm_content|gclid|gclsrc|dclid|fbclid$")
|
Regex::new(
|
||||||
|
r"^(utm_source|utm_medium|utm_campaign|utm_term|utm_content|gclid|gclsrc|dclid|fbclid)=",
|
||||||
|
)
|
||||||
.expect("compile regex")
|
.expect("compile regex")
|
||||||
});
|
});
|
||||||
const ALLOWED_POST_URL_SCHEMES: [&str; 3] = ["http", "https", "magnet"];
|
const ALLOWED_POST_URL_SCHEMES: [&str; 3] = ["http", "https", "magnet"];
|
||||||
|
@ -256,12 +258,11 @@ pub fn build_and_check_regex(regex_str_opt: &Option<&str>) -> LemmyResult<Option
|
||||||
|
|
||||||
pub fn clean_url_params(url: &Url) -> Url {
|
pub fn clean_url_params(url: &Url) -> Url {
|
||||||
let mut url_out = url.clone();
|
let mut url_out = url.clone();
|
||||||
if url.query().is_some() {
|
if let Some(query) = url.query() {
|
||||||
let new_query = url
|
let new_query = query
|
||||||
.query_pairs()
|
.split_inclusive('&')
|
||||||
.filter(|q| !CLEAN_URL_PARAMS_REGEX.is_match(&q.0))
|
.filter(|q| !CLEAN_URL_PARAMS_REGEX.is_match(q))
|
||||||
.map(|q| format!("{}={}", q.0, q.1))
|
.collect::<String>();
|
||||||
.join("&");
|
|
||||||
url_out.set_query(Some(&new_query));
|
url_out.set_query(Some(&new_query));
|
||||||
}
|
}
|
||||||
url_out
|
url_out
|
||||||
|
@ -369,9 +370,9 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_clean_url_params() -> LemmyResult<()> {
|
fn test_clean_url_params() -> LemmyResult<()> {
|
||||||
let url = Url::parse("https://example.com/path/123?utm_content=buffercf3b2&utm_medium=social&username=randomuser&id=123")?;
|
let url = Url::parse("https://example.com/path/123?utm_content=buffercf3b2&utm_medium=social&user+name=random+user%20&id=123")?;
|
||||||
let cleaned = clean_url_params(&url);
|
let cleaned = clean_url_params(&url);
|
||||||
let expected = Url::parse("https://example.com/path/123?username=randomuser&id=123")?;
|
let expected = Url::parse("https://example.com/path/123?user+name=random+user%20&id=123")?;
|
||||||
assert_eq!(expected.to_string(), cleaned.to_string());
|
assert_eq!(expected.to_string(), cleaned.to_string());
|
||||||
|
|
||||||
let url = Url::parse("https://example.com/path/123")?;
|
let url = Url::parse("https://example.com/path/123")?;
|
||||||
|
|
Loading…
Reference in a new issue