mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-25 20:31:31 +00:00
Merge branch 'main' into ap-id-triggers
This commit is contained in:
commit
279d4b05e0
4 changed files with 23 additions and 12 deletions
|
@ -88,6 +88,7 @@ pub async fn get_post(
|
|||
let cross_posts = if let Some(url) = &post_view.post.url {
|
||||
let mut x_posts = PostQuery {
|
||||
url_search: Some(url.inner().as_str().into()),
|
||||
local_user: local_user_view.as_ref(),
|
||||
..Default::default()
|
||||
}
|
||||
.list(&local_site.site, &mut context.pool())
|
||||
|
|
|
@ -118,8 +118,9 @@ impl Crud for Comment {
|
|||
type IdType = CommentId;
|
||||
|
||||
/// This is unimplemented, use [[Comment::create]]
|
||||
async fn create(_pool: &mut DbPool<'_>, _comment_form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
unimplemented!();
|
||||
async fn create(pool: &mut DbPool<'_>, comment_form: &Self::InsertForm) -> Result<Self, Error> {
|
||||
debug_assert!(false);
|
||||
Comment::create(pool, comment_form, None).await
|
||||
}
|
||||
|
||||
async fn update(
|
||||
|
|
|
@ -167,6 +167,14 @@ impl InstanceWorker {
|
|||
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
|
||||
tokio::select! {
|
||||
() = sleep(*WORK_FINISHED_RECHECK_DELAY) => {},
|
||||
|
|
|
@ -11,8 +11,10 @@ static VALID_MATRIX_ID_REGEX: Lazy<Regex> = Lazy::new(|| {
|
|||
});
|
||||
// taken from https://en.wikipedia.org/wiki/UTM_parameters
|
||||
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$")
|
||||
.expect("compile regex")
|
||||
Regex::new(
|
||||
r"^(utm_source|utm_medium|utm_campaign|utm_term|utm_content|gclid|gclsrc|dclid|fbclid)=",
|
||||
)
|
||||
.expect("compile regex")
|
||||
});
|
||||
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 {
|
||||
let mut url_out = url.clone();
|
||||
if url.query().is_some() {
|
||||
let new_query = url
|
||||
.query_pairs()
|
||||
.filter(|q| !CLEAN_URL_PARAMS_REGEX.is_match(&q.0))
|
||||
.map(|q| format!("{}={}", q.0, q.1))
|
||||
.join("&");
|
||||
if let Some(query) = url.query() {
|
||||
let new_query = query
|
||||
.split_inclusive('&')
|
||||
.filter(|q| !CLEAN_URL_PARAMS_REGEX.is_match(q))
|
||||
.collect::<String>();
|
||||
url_out.set_query(Some(&new_query));
|
||||
}
|
||||
url_out
|
||||
|
@ -369,9 +370,9 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
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 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());
|
||||
|
||||
let url = Url::parse("https://example.com/path/123")?;
|
||||
|
|
Loading…
Reference in a new issue