gourami

[UNMAINTAINED] Activitypub server in Rust
Log | Files | Refs | README | LICENSE

commit b8a24641f3c47b9bcb504e2c7400f3b7112827d0
parent e6e9377db5e946b5873a2efcc7e2d19d559326ed
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Fri,  5 Jun 2020 17:10:06 -0500

Fix note tag links

Diffstat:
Msrc/db/note.rs | 4++--
Msrc/lib.rs | 8+++++++-
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/db/note.rs b/src/db/note.rs @@ -139,12 +139,12 @@ pub fn parse_note_text(text: &str) -> String { .replace_all(&html_clean, &replace_str as &str) .to_string(); let note_regex = Regex::new(r"\B(📝|&gt;&gt;)(\d+)").unwrap(); - let replace_str = "<a href=\"/note/$2\">$0</a>"; + let replace_str = "<a href=\"?note_id=$2\">$0</a>"; let notes_parsed = note_regex .replace_all(&urls_parsed, &replace_str as &str) .to_string(); let person_regex = Regex::new(r"\B(@)(\S+)").unwrap(); - let replace_str = "<a href=\"/user/$2\">$0</a>"; + let replace_str = "<a href=\"?username=$2\">$0</a>"; let people_parsed = person_regex .replace_all(&notes_parsed, &replace_str as &str) .to_string(); diff --git a/src/lib.rs b/src/lib.rs @@ -431,6 +431,9 @@ fn get_notes(logged_in: bool, params: &GetPostsParams) -> Result<Vec<UserNote>, if let Some(u_id) = params.user_id { query = query.filter(u::id.eq(u_id)); } + if let Some(uname) = &params.username { + query = query.filter(u::username.eq(uname)); + } if let Some(search) = params.search_string.clone() { query = query.filter(n::content.like(format!("%{}%", search))); } @@ -475,7 +478,10 @@ fn render_timeline( use db::schema::users::dsl as u; let user = match params.user_id { Some(u_id) => u::users.filter(u::id.eq(u_id)).first(&POOL.get().unwrap()).ok(), - None => None, + None => match &params.username { + Some(uname) => u::users.filter(u::username.eq(uname)).first(&POOL.get().unwrap()).ok(), + None => None, + } }; header.page_num = params.page; // TODO -- ignore neighborhood replies