Merge branch 'master' into master

This commit is contained in:
Madeorsk 2018-06-17 22:22:34 +02:00 committed by GitHub
commit faade5ff25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 42 additions and 11 deletions

View File

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
ALTER TABLE notifications DROP COLUMN data;

View File

@ -0,0 +1,2 @@
-- Your SQL goes here
ALTER TABLE notifications ADD COLUMN data VARCHAR;

View File

@ -249,3 +249,17 @@ msgstr ""
msgid "You need to be logged in order to edit your profile" msgid "You need to be logged in order to edit your profile"
msgstr "" msgstr ""
msgid "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name }}{{ link_4 }}"
msgstr ""
msgid "{{ data }} reshared your article"
msgstr ""
msgid "{{ data }} started following you"
msgstr ""
msgid "{{ data }} liked your article"
msgstr ""
msgid "{{ data }} commented your article"
msgstr ""

View File

@ -152,7 +152,8 @@ impl Notify<Note> for Comment {
for author in comment.clone().get_post(conn).get_authors(conn) { for author in comment.clone().get_post(conn).get_authors(conn) {
let comment = comment.clone(); let comment = comment.clone();
Notification::insert(conn, NewNotification { Notification::insert(conn, NewNotification {
title: format!("{} commented your article", comment.get_author(conn).display_name.clone()), title: "{{ data }} commented your article".to_string(),
data: Some(comment.get_author(conn).display_name.clone()),
content: Some(comment.get_post(conn).title), content: Some(comment.get_post(conn).title),
link: comment.ap_url, link: comment.ap_url,
user_id: author.id user_id: author.id

View File

@ -78,7 +78,8 @@ impl Notify<FollowAct> for Follow {
fn notify(conn: &PgConnection, follow: FollowAct, actor: Id) { fn notify(conn: &PgConnection, follow: FollowAct, actor: Id) {
let follower = User::from_url(conn, actor.into()).unwrap(); let follower = User::from_url(conn, actor.into()).unwrap();
Notification::insert(conn, NewNotification { Notification::insert(conn, NewNotification {
title: format!("{} started following you", follower.display_name.clone()), title: "{{ data }} started following you".to_string(),
data: Some(follower.display_name.clone()),
content: None, content: None,
link: Some(follower.ap_url), link: Some(follower.ap_url),
user_id: User::from_url(conn, follow.follow_props.object_link::<Id>().unwrap().into()).unwrap().id user_id: User::from_url(conn, follow.follow_props.object_link::<Id>().unwrap().into()).unwrap().id

View File

@ -118,7 +118,8 @@ impl Notify<activity::Like> for Like {
for author in post.get_authors(conn) { for author in post.get_authors(conn) {
let post = post.clone(); let post = post.clone();
Notification::insert(conn, NewNotification { Notification::insert(conn, NewNotification {
title: format!("{} liked your article", liker.display_name.clone()), title: "{{ data }} liked your article".to_string(),
data: Some(liker.display_name.clone()),
content: Some(post.title), content: Some(post.title),
link: Some(post.ap_url), link: Some(post.ap_url),
user_id: author.id user_id: author.id

View File

@ -11,7 +11,8 @@ pub struct Notification {
pub content: Option<String>, pub content: Option<String>,
pub link: Option<String>, pub link: Option<String>,
pub user_id: i32, pub user_id: i32,
pub creation_date: NaiveDateTime pub creation_date: NaiveDateTime,
pub data: Option<String>
} }
#[derive(Insertable)] #[derive(Insertable)]
@ -20,7 +21,8 @@ pub struct NewNotification {
pub title: String, pub title: String,
pub content: Option<String>, pub content: Option<String>,
pub link: Option<String>, pub link: Option<String>,
pub user_id: i32 pub user_id: i32,
pub data: Option<String>
} }
impl Notification { impl Notification {

View File

@ -120,7 +120,8 @@ impl Notify<Announce> for Reshare {
for author in post.get_authors(conn) { for author in post.get_authors(conn) {
let post = post.clone(); let post = post.clone();
Notification::insert(conn, NewNotification { Notification::insert(conn, NewNotification {
title: format!("{} reshared your article", actor.display_name.clone()), title: "{{ data }} reshared your article".to_string(),
data: Some(actor.display_name.clone()),
content: Some(post.title), content: Some(post.title),
link: Some(post.ap_url), link: Some(post.ap_url),
user_id: author.id user_id: author.id

View File

@ -74,6 +74,7 @@ table! {
link -> Nullable<Varchar>, link -> Nullable<Varchar>,
user_id -> Int4, user_id -> Int4,
creation_date -> Timestamp, creation_date -> Timestamp,
data -> Nullable<Varchar>,
} }
} }

View File

@ -9,7 +9,6 @@
<form method="post"> <form method="post">
<label for="title">{{ "Title" | _ }}</label> <label for="title">{{ "Title" | _ }}</label>
<input type="text" id="title" name="title" /> <input type="text" id="title" name="title" />
<input type="submit" value="{{ "Create blog" | _ }}"/>
<input type="submit" value="{{ "Create blog"}}" />
</form> </form>
| _ {% endblock content %} {% endblock content %}

View File

@ -10,7 +10,14 @@
<p>{{ article.post.content | striptags | truncate(length=200) }}</p> <p>{{ article.post.content | striptags | truncate(length=200) }}</p>
</main> </main>
<p class="author"> <p class="author">
By <a href="/@/{{ article.author.fqn }}/">{{ name }}</a> ⋅ {{ article.date | date(format="%B %e") }} {{ "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name }}{{ link_4 }}" | _(
link_1='<a href="/@/',
link_2=article.author.fqn,
link_3='/">',
name=name,
link_4="</a>")
}}
⋅ {{ article.date | date(format="%B %e") }}
</p> </p>
</div> </div>
{% endmacro post_card %} {% endmacro post_card %}

View File

@ -9,7 +9,7 @@
<div class="list"> <div class="list">
{% for notification in notifications %} {% for notification in notifications %}
<div class="card"> <div class="card">
<h3><a href="{% if notification.link %}{{ notification.link }}/{% else %}#{% endif %}">{{ notification.title }}</h3> <h3><a href="{% if notification.link %}{{ notification.link }}/{% else %}#{% endif %}">{{ notification.title | _(data=notification.data) }}</h3>
{% if notification.content %} {% if notification.content %}
<p>{{ notification.content }}</p> <p>{{ notification.content }}</p>
{% endif %} {% endif %}