X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fdb_views_actor%2Fsrc%2Fcomment_reply_view.rs;h=39ba74ccb2e6dd50fe7b44c4a9671498b1cef057;hb=c9f140742925d6da20103124b49f2b58a35fc2b8;hp=c8f9df9ce2b6aa4624899b1b64a64d87103cbade;hpb=4e6409f325bca5b2727b19c24d77ffa2b59109b1;p=lemmy.git diff --git a/crates/db_views_actor/src/comment_reply_view.rs b/crates/db_views_actor/src/comment_reply_view.rs index c8f9df9c..39ba74cc 100644 --- a/crates/db_views_actor/src/comment_reply_view.rs +++ b/crates/db_views_actor/src/comment_reply_view.rs @@ -13,7 +13,6 @@ use lemmy_db_schema::{ community_follower, community_person_ban, person, - person_alias_1, person_block, post, }, @@ -21,7 +20,7 @@ use lemmy_db_schema::{ comment::{Comment, CommentSaved}, comment_reply::CommentReply, community::{Community, CommunityFollower, CommunityPersonBan, CommunitySafe}, - person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person::{Person, PersonSafe}, person_block::PersonBlock, post::Post, }, @@ -37,7 +36,7 @@ type CommentReplyViewTuple = ( PersonSafe, Post, CommunitySafe, - PersonSafeAlias1, + PersonSafe, CommentAggregates, Option, Option, @@ -48,10 +47,12 @@ type CommentReplyViewTuple = ( impl CommentReplyView { pub fn read( - conn: &PgConnection, + conn: &mut PgConnection, comment_reply_id: CommentReplyId, my_person_id: Option, ) -> Result { + let person_alias_1 = diesel::alias!(person as person1); + // The left join below will return None in this case let person_id_join = my_person_id.unwrap_or(PersonId(-1)); @@ -74,7 +75,7 @@ impl CommentReplyView { .inner_join(person::table.on(comment::creator_id.eq(person::id))) .inner_join(post::table.on(comment::post_id.eq(post::id))) .inner_join(community::table.on(post::community_id.eq(community::id))) - .inner_join(person_alias_1::table) + .inner_join(person_alias_1) .inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id))) .left_join( community_person_ban::table.on( @@ -122,7 +123,7 @@ impl CommentReplyView { Person::safe_columns_tuple(), post::all_columns, Community::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), comment_aggregates::all_columns, community_person_ban::all_columns.nullable(), community_follower::all_columns.nullable(), @@ -149,7 +150,7 @@ impl CommentReplyView { } /// Gets the number of unread replies - pub fn get_unread_replies(conn: &PgConnection, my_person_id: PersonId) -> Result { + pub fn get_unread_replies(conn: &mut PgConnection, my_person_id: PersonId) -> Result { use diesel::dsl::*; comment_reply::table @@ -164,7 +165,7 @@ impl CommentReplyView { #[builder(field_defaults(default))] pub struct CommentReplyQuery<'a> { #[builder(!default)] - conn: &'a PgConnection, + conn: &'a mut PgConnection, my_person_id: Option, recipient_id: Option, sort: Option, @@ -178,6 +179,8 @@ impl<'a> CommentReplyQuery<'a> { pub fn list(self) -> Result, Error> { use diesel::dsl::*; + let person_alias_1 = diesel::alias!(person as person1); + // The left join below will return None in this case let person_id_join = self.my_person_id.unwrap_or(PersonId(-1)); @@ -186,7 +189,7 @@ impl<'a> CommentReplyQuery<'a> { .inner_join(person::table.on(comment::creator_id.eq(person::id))) .inner_join(post::table.on(comment::post_id.eq(post::id))) .inner_join(community::table.on(post::community_id.eq(community::id))) - .inner_join(person_alias_1::table) + .inner_join(person_alias_1) .inner_join(comment_aggregates::table.on(comment::id.eq(comment_aggregates::comment_id))) .left_join( community_person_ban::table.on( @@ -234,7 +237,7 @@ impl<'a> CommentReplyQuery<'a> { Person::safe_columns_tuple(), post::all_columns, Community::safe_columns_tuple(), - PersonAlias1::safe_columns_tuple(), + person_alias_1.fields(Person::safe_columns_tuple()), comment_aggregates::all_columns, community_person_ban::all_columns.nullable(), community_follower::all_columns.nullable(),