Merge pull request #49 from fdb-hiroshima/master

allow html on user.summary
This commit is contained in:
Baptiste Gelez 2018-06-11 15:15:13 +01:00 committed by GitHub
commit eaf0622b86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -45,6 +45,7 @@ use models::{
posts::Post posts::Post
}; };
use schema::users; use schema::users;
use safe_string::SafeString;
pub const AUTH_COOKIE: &'static str = "user_id"; pub const AUTH_COOKIE: &'static str = "user_id";
@ -56,7 +57,7 @@ pub struct User {
pub outbox_url: String, pub outbox_url: String,
pub inbox_url: String, pub inbox_url: String,
pub is_admin: bool, pub is_admin: bool,
pub summary: String, pub summary: SafeString,
pub email: Option<String>, pub email: Option<String>,
pub hashed_password: Option<String>, pub hashed_password: Option<String>,
pub instance_id: i32, pub instance_id: i32,
@ -75,7 +76,7 @@ pub struct NewUser {
pub outbox_url: String, pub outbox_url: String,
pub inbox_url: String, pub inbox_url: String,
pub is_admin: bool, pub is_admin: bool,
pub summary: String, pub summary: SafeString,
pub email: Option<String>, pub email: Option<String>,
pub hashed_password: Option<String>, pub hashed_password: Option<String>,
pub instance_id: i32, pub instance_id: i32,
@ -200,7 +201,7 @@ impl User {
outbox_url: acct["outbox"].as_str().unwrap().to_string(), outbox_url: acct["outbox"].as_str().unwrap().to_string(),
inbox_url: acct["inbox"].as_str().unwrap().to_string(), inbox_url: acct["inbox"].as_str().unwrap().to_string(),
is_admin: false, is_admin: false,
summary: acct["summary"].as_str().unwrap().to_string(), summary: SafeString::new(&acct["summary"].as_str().unwrap().to_string()),
email: None, email: None,
hashed_password: None, hashed_password: None,
instance_id: instance.id, instance_id: instance.id,
@ -371,7 +372,7 @@ impl APActor for User {
} }
fn get_summary(&self) -> String { fn get_summary(&self) -> String {
self.summary.clone() self.summary.get().clone()
} }
fn get_instance(&self, conn: &PgConnection) -> Instance { fn get_instance(&self, conn: &PgConnection) -> Instance {
@ -561,7 +562,7 @@ impl NewUser {
outbox_url: String::from(""), outbox_url: String::from(""),
inbox_url: String::from(""), inbox_url: String::from(""),
is_admin: is_admin, is_admin: is_admin,
summary: summary, summary: SafeString::new(&summary),
email: Some(email), email: Some(email),
hashed_password: Some(password), hashed_password: Some(password),
instance_id: instance_id, instance_id: instance_id,

View File

@ -28,7 +28,7 @@
</div> </div>
<div> <div>
{{ user.summary }} {{ user.summary | safe }}
</div> </div>
{% if recents | length != 0 %} {% if recents | length != 0 %}

View File

@ -23,7 +23,7 @@
{% for follower in followers %} {% for follower in followers %}
<div class="card"> <div class="card">
<h3><a href="{{ follower.ap_url }}/">{{ follower.display_name }}</a> &mdash; @{{ follower.fqn }}</h3> <h3><a href="{{ follower.ap_url }}/">{{ follower.display_name }}</a> &mdash; @{{ follower.fqn }}</h3>
<main><p>{{ follower.summary }}</p></main> <main><p>{{ follower.summary | safe }}</p></main>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>