diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index e038f107..c43b15e8 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -281,7 +281,7 @@ impl User { users::table.filter(users::id.eq(any(follows))).load::(conn).unwrap() } - pub fn is_following(&self, conn: &PgConnection, other_id: i32) -> bool { + pub fn is_followed_by(&self, conn: &PgConnection, other_id: i32) -> bool { use schema::follows; follows::table .filter(follows::follower_id.eq(other_id)) @@ -291,6 +291,16 @@ impl User { .len() > 0 } + pub fn is_following(&self, conn: &PgConnection, other_id: i32) -> bool { + use schema::follows; + follows::table + .filter(follows::follower_id.eq(self.id)) + .filter(follows::following_id.eq(other_id)) + .load::(conn) + .expect("Couldn't load follow relationship") + .len() > 0 + } + pub fn has_liked(&self, conn: &PgConnection, post: &Post) -> bool { use schema::likes; likes::table diff --git a/plume.md b/plume.md new file mode 100644 index 00000000..687307f5 --- /dev/null +++ b/plume.md @@ -0,0 +1,8 @@ +Page de présentation Plume + +Plume +Moteur de blog décentralisé. + +Les auteurs peuvent gérer différents blogs au sein d'un même site. + +Les articles sont également visibles sur d'autres sites Plume et vous pouvez interagir avec eux directement depuis d'autres plateformes telles que Mastodon. diff --git a/templates/users/header.html.tera b/templates/users/header.html.tera index c9e1797c..53864f7c 100644 --- a/templates/users/header.html.tera +++ b/templates/users/header.html.tera @@ -18,11 +18,12 @@ {{ "Open on {{ instance_url }}" | _(instance_url=instance_url) }} {% endif %} - {% if not is_self and account %} + {% set not_self = not is_self %} + {% if not_self and (account is defined) %} {% if follows %} - {{ "Follow" | _ }} - {% else %} {{ "Unfollow" | _ }} + {% else %} + {{ "Follow" | _ }} {% endif %} {% endif %}