gourami

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

commit e1c7c719a89a6dc255edadd05fade192dd00445e
parent 0573c3c9d91edd20b549e1b28d8edebcc96f3667
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Fri,  5 Jun 2020 13:39:23 -0500

Fix user page bugs

Diffstat:
Msrc/lib.rs | 13++++++++++---
Mtemplates/base.html | 3++-
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs @@ -417,8 +417,10 @@ fn get_notes(logged_in: bool, params: &GetPostsParams) -> Result<Vec<UserNote>, use db::schema::notes::dsl as n; use db::schema::users::dsl as u; // TODO -- add whether this is complete so i can page properly - if let Some(n_id) = params.note_id { - return Ok(get_single_note(n_id).unwrap()) // TODO filter replies logged out + if logged_in { + if let Some(n_id) = params.note_id { + return Ok(get_single_note(n_id).unwrap()) // TODO filter replies logged out + } } let mut query = n::notes .inner_join(u::users) @@ -470,6 +472,11 @@ fn render_timeline( let mut header = Global::create(auth_user, url_with_params); header.page_title = ""; // wonky + 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, + }; header.page_num = params.page; // TODO -- ignore neighborhood replies match notes { @@ -481,7 +488,7 @@ fn render_timeline( render_template(&TimelineTemplate { global: header, notes: n, - user: None, // TODO + user: user, params: params }) } diff --git a/templates/base.html b/templates/base.html @@ -26,7 +26,8 @@ {% if global.logged_in %} <a href="/">local</a>{% endif %} <a href="/?neighborhood=true">neighborhood</a> {% if global.logged_in %} <a href="/?search_string={{global.me.username}}&all=true">mentions</a> {% endif %} - <a href="/server_info">server</a> {% if global.logged_in %} <a href="/user/{{global.me.username}}">@{{global.me.username}}</a>{% else %} <a href="login">login</a>{% endif %} + <a href="/server_info">server</a> {% if global.logged_in %} <a + href="/?user_id={{global.me.id}}">@{{global.me.username}}</a>{% else %} <a href="login">login</a>{% endif %} </div> </div> <div class="padded main-content">