1 use crate::structs::PostView;
4 dsl::{now, IntervalDsl},
12 NullableExpressionMethods,
13 PgTextExpressionMethods,
16 use diesel_async::RunQueryDsl;
17 use lemmy_db_schema::{
18 aggregates::structs::PostAggregates,
19 newtypes::{CommunityId, LocalUserId, PersonId, PostId},
28 person_post_aggregates,
36 community::{Community, CommunityFollower, CommunityPersonBan},
37 local_user::LocalUser,
39 person_block::PersonBlock,
40 post::{Post, PostRead, PostSaved},
43 utils::{fuzzy_search, get_conn, limit_and_offset, DbPool},
49 type PostViewTuple = (
53 Option<CommunityPersonBan>,
55 Option<CommunityFollower>,
63 sql_function!(fn coalesce(x: sql_types::Nullable<sql_types::BigInt>, y: sql_types::BigInt) -> sql_types::BigInt);
67 pool: &mut DbPool<'_>,
69 my_person_id: Option<PersonId>,
70 is_mod_or_admin: Option<bool>,
71 ) -> Result<Self, Error> {
72 let conn = &mut get_conn(pool).await?;
74 // The left join below will return None in this case
75 let person_id_join = my_person_id.unwrap_or(PersonId(-1));
76 let mut query = post::table
78 .inner_join(person::table)
79 .inner_join(community::table)
81 community_person_ban::table.on(
83 .eq(community_person_ban::community_id)
84 .and(community_person_ban::person_id.eq(post::creator_id)),
87 .inner_join(post_aggregates::table)
89 community_follower::table.on(
91 .eq(community_follower::community_id)
92 .and(community_follower::person_id.eq(person_id_join)),
98 .eq(post_saved::post_id)
99 .and(post_saved::person_id.eq(person_id_join)),
105 .eq(post_read::post_id)
106 .and(post_read::person_id.eq(person_id_join)),
110 person_block::table.on(
112 .eq(person_block::target_id)
113 .and(person_block::person_id.eq(person_id_join)),
119 .eq(post_like::post_id)
120 .and(post_like::person_id.eq(person_id_join)),
124 person_post_aggregates::table.on(
126 .eq(person_post_aggregates::post_id)
127 .and(person_post_aggregates::person_id.eq(person_id_join)),
133 community::all_columns,
134 community_person_ban::all_columns.nullable(),
135 post_aggregates::all_columns,
136 community_follower::all_columns.nullable(),
137 post_saved::all_columns.nullable(),
138 post_read::all_columns.nullable(),
139 person_block::all_columns.nullable(),
140 post_like::score.nullable(),
142 post_aggregates::comments.nullable() - person_post_aggregates::read_comments.nullable(),
143 post_aggregates::comments,
148 // Hide deleted and removed for non-admins or mods
149 if !is_mod_or_admin.unwrap_or(false) {
151 .filter(community::removed.eq(false))
152 .filter(community::deleted.eq(false))
153 .filter(post::removed.eq(false))
154 .filter(post::deleted.eq(false));
161 creator_banned_from_community,
169 ) = query.first::<PostViewTuple>(conn).await?;
171 // If a person is given, then my_vote, if None, should be 0, not null
172 // Necessary to differentiate between other person's votes
173 let my_vote = if my_person_id.is_some() && post_like.is_none() {
183 creator_banned_from_community: creator_banned_from_community.is_some(),
185 subscribed: CommunityFollower::to_subscribed_type(&follower),
186 saved: saved.is_some(),
187 read: read.is_some(),
188 creator_blocked: creator_blocked.is_some(),
196 pub struct PostQuery<'a> {
197 pub listing_type: Option<ListingType>,
198 pub sort: Option<SortType>,
199 pub creator_id: Option<PersonId>,
200 pub community_id: Option<CommunityId>,
201 pub local_user: Option<&'a LocalUser>,
202 pub search_term: Option<String>,
203 pub url_search: Option<String>,
204 pub saved_only: Option<bool>,
205 /// Used to show deleted or removed posts for admins
206 pub is_mod_or_admin: Option<bool>,
207 pub page: Option<i64>,
208 pub limit: Option<i64>,
211 impl<'a> PostQuery<'a> {
212 pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<PostView>, Error> {
213 let conn = &mut get_conn(pool).await?;
215 // The left join below will return None in this case
216 let person_id_join = self.local_user.map(|l| l.person_id).unwrap_or(PersonId(-1));
217 let local_user_id_join = self.local_user.map(|l| l.id).unwrap_or(LocalUserId(-1));
219 let mut query = post::table
220 .inner_join(person::table)
221 .inner_join(community::table)
223 community_person_ban::table.on(
225 .eq(community_person_ban::community_id)
226 .and(community_person_ban::person_id.eq(post::creator_id)),
229 .inner_join(post_aggregates::table)
231 community_follower::table.on(
233 .eq(community_follower::community_id)
234 .and(community_follower::person_id.eq(person_id_join)),
238 post_saved::table.on(
240 .eq(post_saved::post_id)
241 .and(post_saved::person_id.eq(person_id_join)),
247 .eq(post_read::post_id)
248 .and(post_read::person_id.eq(person_id_join)),
252 person_block::table.on(
254 .eq(person_block::target_id)
255 .and(person_block::person_id.eq(person_id_join)),
259 community_block::table.on(
261 .eq(community_block::community_id)
262 .and(community_block::person_id.eq(person_id_join)),
268 .eq(post_like::post_id)
269 .and(post_like::person_id.eq(person_id_join)),
273 person_post_aggregates::table.on(
275 .eq(person_post_aggregates::post_id)
276 .and(person_post_aggregates::person_id.eq(person_id_join)),
280 local_user_language::table.on(
282 .eq(local_user_language::language_id)
283 .and(local_user_language::local_user_id.eq(local_user_id_join)),
289 community::all_columns,
290 community_person_ban::all_columns.nullable(),
291 post_aggregates::all_columns,
292 community_follower::all_columns.nullable(),
293 post_saved::all_columns.nullable(),
294 post_read::all_columns.nullable(),
295 person_block::all_columns.nullable(),
296 post_like::score.nullable(),
298 post_aggregates::comments.nullable() - person_post_aggregates::read_comments.nullable(),
299 post_aggregates::comments,
304 // Hide deleted and removed for non-admins or mods
305 // TODO This eventually needs to show posts where you are the creator
306 if !self.is_mod_or_admin.unwrap_or(false) {
308 .filter(community::removed.eq(false))
309 .filter(community::deleted.eq(false))
310 .filter(post::removed.eq(false))
311 .filter(post::deleted.eq(false));
314 if self.community_id.is_none() {
315 query = query.then_order_by(post_aggregates::featured_local.desc());
316 } else if let Some(community_id) = self.community_id {
318 .filter(post::community_id.eq(community_id))
319 .then_order_by(post_aggregates::featured_community.desc());
322 if let Some(creator_id) = self.creator_id {
323 query = query.filter(post::creator_id.eq(creator_id));
326 if let Some(listing_type) = self.listing_type {
328 ListingType::Subscribed => {
329 query = query.filter(community_follower::person_id.is_not_null())
331 ListingType::Local => {
332 query = query.filter(community::local.eq(true)).filter(
335 .or(community_follower::person_id.eq(person_id_join)),
338 ListingType::All => {
339 query = query.filter(
342 .or(community_follower::person_id.eq(person_id_join)),
348 if let Some(url_search) = self.url_search {
349 query = query.filter(post::url.eq(url_search));
352 if let Some(search_term) = self.search_term {
353 let searcher = fuzzy_search(&search_term);
354 query = query.filter(
356 .ilike(searcher.clone())
357 .or(post::body.ilike(searcher)),
361 if !self.local_user.map(|l| l.show_nsfw).unwrap_or(false) {
363 .filter(post::nsfw.eq(false))
364 .filter(community::nsfw.eq(false));
367 if !self.local_user.map(|l| l.show_bot_accounts).unwrap_or(true) {
368 query = query.filter(person::bot_account.eq(false));
371 if self.saved_only.unwrap_or(false) {
372 query = query.filter(post_saved::post_id.is_not_null());
374 // Only hide the read posts, if the saved_only is false. Otherwise ppl with the hide_read
375 // setting wont be able to see saved posts.
376 else if !self.local_user.map(|l| l.show_read_posts).unwrap_or(true) {
377 query = query.filter(post_read::post_id.is_null());
380 if self.local_user.is_some() {
381 // Filter out the rows with missing languages
382 query = query.filter(local_user_language::language_id.is_not_null());
384 // Don't show blocked communities or persons
385 query = query.filter(community_block::person_id.is_null());
386 query = query.filter(person_block::person_id.is_null());
389 query = match self.sort.unwrap_or(SortType::Hot) {
390 SortType::Active => query.then_order_by(post_aggregates::hot_rank_active.desc()),
391 SortType::Hot => query.then_order_by(post_aggregates::hot_rank.desc()),
392 SortType::New => query.then_order_by(post_aggregates::published.desc()),
393 SortType::Old => query.then_order_by(post_aggregates::published.asc()),
394 SortType::NewComments => query.then_order_by(post_aggregates::newest_comment_time.desc()),
395 SortType::MostComments => query
396 .then_order_by(post_aggregates::comments.desc())
397 .then_order_by(post_aggregates::published.desc()),
398 SortType::TopAll => query
399 .then_order_by(post_aggregates::score.desc())
400 .then_order_by(post_aggregates::published.desc()),
401 SortType::TopYear => query
402 .filter(post_aggregates::published.gt(now - 1.years()))
403 .then_order_by(post_aggregates::score.desc())
404 .then_order_by(post_aggregates::published.desc()),
405 SortType::TopMonth => query
406 .filter(post_aggregates::published.gt(now - 1.months()))
407 .then_order_by(post_aggregates::score.desc())
408 .then_order_by(post_aggregates::published.desc()),
409 SortType::TopWeek => query
410 .filter(post_aggregates::published.gt(now - 1.weeks()))
411 .then_order_by(post_aggregates::score.desc())
412 .then_order_by(post_aggregates::published.desc()),
413 SortType::TopDay => query
414 .filter(post_aggregates::published.gt(now - 1.days()))
415 .then_order_by(post_aggregates::score.desc())
416 .then_order_by(post_aggregates::published.desc()),
417 SortType::TopHour => query
418 .filter(post_aggregates::published.gt(now - 1.hours()))
419 .then_order_by(post_aggregates::score.desc())
420 .then_order_by(post_aggregates::published.desc()),
421 SortType::TopSixHour => query
422 .filter(post_aggregates::published.gt(now - 6.hours()))
423 .then_order_by(post_aggregates::score.desc())
424 .then_order_by(post_aggregates::published.desc()),
425 SortType::TopTwelveHour => query
426 .filter(post_aggregates::published.gt(now - 12.hours()))
427 .then_order_by(post_aggregates::score.desc())
428 .then_order_by(post_aggregates::published.desc()),
429 SortType::TopThreeMonths => query
430 .filter(post_aggregates::published.gt(now - 3.months()))
431 .then_order_by(post_aggregates::score.desc())
432 .then_order_by(post_aggregates::published.desc()),
433 SortType::TopSixMonths => query
434 .filter(post_aggregates::published.gt(now - 6.months()))
435 .then_order_by(post_aggregates::score.desc())
436 .then_order_by(post_aggregates::published.desc()),
437 SortType::TopNineMonths => query
438 .filter(post_aggregates::published.gt(now - 9.months()))
439 .then_order_by(post_aggregates::score.desc())
440 .then_order_by(post_aggregates::published.desc()),
443 let (limit, offset) = limit_and_offset(self.page, self.limit)?;
445 query = query.limit(limit).offset(offset);
447 debug!("Post View Query: {:?}", debug_query::<Pg, _>(&query));
449 let res = query.load::<PostViewTuple>(conn).await?;
451 Ok(res.into_iter().map(PostView::from_tuple).collect())
455 impl JoinView for PostView {
456 type JoinTuple = PostViewTuple;
457 fn from_tuple(a: Self::JoinTuple) -> Self {
462 creator_banned_from_community: a.3.is_some(),
464 subscribed: CommunityFollower::to_subscribed_type(&a.5),
465 saved: a.6.is_some(),
467 creator_blocked: a.8.is_some(),
469 unread_comments: a.10,
476 #![allow(clippy::unwrap_used)]
477 #![allow(clippy::indexing_slicing)]
479 use crate::post_view::{PostQuery, PostView};
480 use lemmy_db_schema::{
481 aggregates::structs::PostAggregates,
482 impls::actor_language::UNDETERMINED_ID,
483 newtypes::LanguageId,
485 actor_language::LocalUserLanguage,
486 community::{Community, CommunityInsertForm},
487 community_block::{CommunityBlock, CommunityBlockForm},
490 local_user::{LocalUser, LocalUserInsertForm, LocalUserUpdateForm},
491 person::{Person, PersonInsertForm},
492 person_block::{PersonBlock, PersonBlockForm},
493 post::{Post, PostInsertForm, PostLike, PostLikeForm, PostUpdateForm},
495 traits::{Blockable, Crud, Likeable},
496 utils::{build_db_pool_for_tests, DbPool},
500 use serial_test::serial;
503 inserted_instance: Instance,
504 inserted_person: Person,
505 inserted_local_user: LocalUser,
506 inserted_blocked_person: Person,
507 inserted_bot: Person,
508 inserted_community: Community,
512 async fn init_data(pool: &mut DbPool<'_>) -> Data {
513 let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string())
517 let person_name = "tegan".to_string();
519 let new_person = PersonInsertForm::builder()
520 .name(person_name.clone())
521 .public_key("pubkey".to_string())
522 .instance_id(inserted_instance.id)
525 let inserted_person = Person::create(pool, &new_person).await.unwrap();
527 let local_user_form = LocalUserInsertForm::builder()
528 .person_id(inserted_person.id)
529 .password_encrypted(String::new())
531 let inserted_local_user = LocalUser::create(pool, &local_user_form).await.unwrap();
533 let new_bot = PersonInsertForm::builder()
534 .name("mybot".to_string())
535 .bot_account(Some(true))
536 .public_key("pubkey".to_string())
537 .instance_id(inserted_instance.id)
540 let inserted_bot = Person::create(pool, &new_bot).await.unwrap();
542 let new_community = CommunityInsertForm::builder()
543 .name("test_community_3".to_string())
544 .title("nada".to_owned())
545 .public_key("pubkey".to_string())
546 .instance_id(inserted_instance.id)
549 let inserted_community = Community::create(pool, &new_community).await.unwrap();
551 // Test a person block, make sure the post query doesn't include their post
552 let blocked_person = PersonInsertForm::builder()
554 .public_key("pubkey".to_string())
555 .instance_id(inserted_instance.id)
558 let inserted_blocked_person = Person::create(pool, &blocked_person).await.unwrap();
560 let post_from_blocked_person = PostInsertForm::builder()
561 .name("blocked_person_post".to_string())
562 .creator_id(inserted_blocked_person.id)
563 .community_id(inserted_community.id)
564 .language_id(Some(LanguageId(1)))
567 Post::create(pool, &post_from_blocked_person).await.unwrap();
570 let person_block = PersonBlockForm {
571 person_id: inserted_person.id,
572 target_id: inserted_blocked_person.id,
575 PersonBlock::block(pool, &person_block).await.unwrap();
578 let new_post = PostInsertForm::builder()
579 .name("test post 3".to_string())
580 .creator_id(inserted_person.id)
581 .community_id(inserted_community.id)
582 .language_id(Some(LanguageId(47)))
585 let inserted_post = Post::create(pool, &new_post).await.unwrap();
587 let new_bot_post = PostInsertForm::builder()
588 .name("test bot post".to_string())
589 .creator_id(inserted_bot.id)
590 .community_id(inserted_community.id)
593 let _inserted_bot_post = Post::create(pool, &new_bot_post).await.unwrap();
599 inserted_blocked_person,
608 async fn post_listing_with_person() {
609 let pool = &build_db_pool_for_tests().await;
610 let pool = &mut pool.into();
611 let data = init_data(pool).await;
613 let local_user_form = LocalUserUpdateForm::builder()
614 .show_bot_accounts(Some(false))
616 let inserted_local_user =
617 LocalUser::update(pool, data.inserted_local_user.id, &local_user_form)
621 let read_post_listing = PostQuery {
622 sort: (Some(SortType::New)),
623 community_id: (Some(data.inserted_community.id)),
624 local_user: (Some(&inserted_local_user)),
631 let post_listing_single_with_person = PostView::read(
633 data.inserted_post.id,
634 Some(data.inserted_person.id),
640 let mut expected_post_listing_with_user = expected_post_view(&data, pool).await;
642 // Should be only one person, IE the bot post, and blocked should be missing
643 assert_eq!(1, read_post_listing.len());
645 assert_eq!(expected_post_listing_with_user, read_post_listing[0]);
646 expected_post_listing_with_user.my_vote = Some(0);
648 expected_post_listing_with_user,
649 post_listing_single_with_person
652 let local_user_form = LocalUserUpdateForm::builder()
653 .show_bot_accounts(Some(true))
655 let inserted_local_user =
656 LocalUser::update(pool, data.inserted_local_user.id, &local_user_form)
660 let post_listings_with_bots = PostQuery {
661 sort: (Some(SortType::New)),
662 community_id: (Some(data.inserted_community.id)),
663 local_user: (Some(&inserted_local_user)),
669 // should include bot post which has "undetermined" language
670 assert_eq!(2, post_listings_with_bots.len());
672 cleanup(data, pool).await;
677 async fn post_listing_no_person() {
678 let pool = &build_db_pool_for_tests().await;
679 let pool = &mut pool.into();
680 let data = init_data(pool).await;
682 let read_post_listing_multiple_no_person = PostQuery {
683 sort: (Some(SortType::New)),
684 community_id: (Some(data.inserted_community.id)),
691 let read_post_listing_single_no_person =
692 PostView::read(pool, data.inserted_post.id, None, None)
696 let expected_post_listing_no_person = expected_post_view(&data, pool).await;
698 // Should be 2 posts, with the bot post, and the blocked
699 assert_eq!(3, read_post_listing_multiple_no_person.len());
702 expected_post_listing_no_person,
703 read_post_listing_multiple_no_person[1]
706 expected_post_listing_no_person,
707 read_post_listing_single_no_person
710 cleanup(data, pool).await;
715 async fn post_listing_block_community() {
716 let pool = &build_db_pool_for_tests().await;
717 let pool = &mut pool.into();
718 let data = init_data(pool).await;
720 let community_block = CommunityBlockForm {
721 person_id: data.inserted_person.id,
722 community_id: data.inserted_community.id,
724 CommunityBlock::block(pool, &community_block).await.unwrap();
726 let read_post_listings_with_person_after_block = PostQuery {
727 sort: (Some(SortType::New)),
728 community_id: (Some(data.inserted_community.id)),
729 local_user: (Some(&data.inserted_local_user)),
735 // Should be 0 posts after the community block
736 assert_eq!(0, read_post_listings_with_person_after_block.len());
738 CommunityBlock::unblock(pool, &community_block)
741 cleanup(data, pool).await;
746 async fn post_listing_like() {
747 let pool = &build_db_pool_for_tests().await;
748 let pool = &mut pool.into();
749 let data = init_data(pool).await;
751 let post_like_form = PostLikeForm {
752 post_id: data.inserted_post.id,
753 person_id: data.inserted_person.id,
757 let inserted_post_like = PostLike::like(pool, &post_like_form).await.unwrap();
759 let expected_post_like = PostLike {
760 id: inserted_post_like.id,
761 post_id: data.inserted_post.id,
762 person_id: data.inserted_person.id,
763 published: inserted_post_like.published,
766 assert_eq!(expected_post_like, inserted_post_like);
768 let post_listing_single_with_person = PostView::read(
770 data.inserted_post.id,
771 Some(data.inserted_person.id),
777 let mut expected_post_with_upvote = expected_post_view(&data, pool).await;
778 expected_post_with_upvote.my_vote = Some(1);
779 expected_post_with_upvote.counts.score = 1;
780 expected_post_with_upvote.counts.upvotes = 1;
781 assert_eq!(expected_post_with_upvote, post_listing_single_with_person);
783 let local_user_form = LocalUserUpdateForm::builder()
784 .show_bot_accounts(Some(false))
786 let inserted_local_user =
787 LocalUser::update(pool, data.inserted_local_user.id, &local_user_form)
791 let read_post_listing = PostQuery {
792 sort: (Some(SortType::New)),
793 community_id: (Some(data.inserted_community.id)),
794 local_user: (Some(&inserted_local_user)),
800 assert_eq!(1, read_post_listing.len());
802 assert_eq!(expected_post_with_upvote, read_post_listing[0]);
804 let like_removed = PostLike::remove(pool, data.inserted_person.id, data.inserted_post.id)
807 assert_eq!(1, like_removed);
808 cleanup(data, pool).await;
813 async fn post_listing_person_language() {
814 let pool = &build_db_pool_for_tests().await;
815 let pool = &mut pool.into();
816 let data = init_data(pool).await;
818 let spanish_id = Language::read_id_from_code(pool, Some("es"))
822 let post_spanish = PostInsertForm::builder()
823 .name("asffgdsc".to_string())
824 .creator_id(data.inserted_person.id)
825 .community_id(data.inserted_community.id)
826 .language_id(Some(spanish_id))
829 Post::create(pool, &post_spanish).await.unwrap();
831 let post_listings_all = PostQuery {
832 sort: (Some(SortType::New)),
833 local_user: (Some(&data.inserted_local_user)),
840 // no language filters specified, all posts should be returned
841 assert_eq!(3, post_listings_all.len());
843 let french_id = Language::read_id_from_code(pool, Some("fr"))
847 LocalUserLanguage::update(pool, vec![french_id], data.inserted_local_user.id)
851 let post_listing_french = PostQuery {
852 sort: (Some(SortType::New)),
853 local_user: (Some(&data.inserted_local_user)),
860 // only one post in french and one undetermined should be returned
861 assert_eq!(2, post_listing_french.len());
862 assert!(post_listing_french
864 .any(|p| p.post.language_id == french_id));
866 LocalUserLanguage::update(
868 vec![french_id, UNDETERMINED_ID],
869 data.inserted_local_user.id,
873 let post_listings_french_und = PostQuery {
874 sort: (Some(SortType::New)),
875 local_user: (Some(&data.inserted_local_user)),
882 // french post and undetermined language post should be returned
883 assert_eq!(2, post_listings_french_und.len());
886 post_listings_french_und[0].post.language_id
888 assert_eq!(french_id, post_listings_french_und[1].post.language_id);
890 cleanup(data, pool).await;
895 async fn post_listings_deleted() {
896 let pool = &build_db_pool_for_tests().await;
897 let pool = &mut pool.into();
898 let data = init_data(pool).await;
903 data.inserted_post.id,
904 &PostUpdateForm::builder().deleted(Some(true)).build(),
909 // Make sure you don't see the deleted post in the results
910 let post_listings_no_admin = PostQuery {
911 sort: (Some(SortType::New)),
912 local_user: (Some(&data.inserted_local_user)),
913 is_mod_or_admin: (Some(false)),
920 assert_eq!(1, post_listings_no_admin.len());
922 // Make sure they see both
923 let post_listings_is_admin = PostQuery {
924 sort: (Some(SortType::New)),
925 local_user: (Some(&data.inserted_local_user)),
926 is_mod_or_admin: (Some(true)),
933 assert_eq!(2, post_listings_is_admin.len());
935 cleanup(data, pool).await;
938 async fn cleanup(data: Data, pool: &mut DbPool<'_>) {
939 let num_deleted = Post::delete(pool, data.inserted_post.id).await.unwrap();
940 Community::delete(pool, data.inserted_community.id)
943 Person::delete(pool, data.inserted_person.id).await.unwrap();
944 Person::delete(pool, data.inserted_bot.id).await.unwrap();
945 Person::delete(pool, data.inserted_blocked_person.id)
948 Instance::delete(pool, data.inserted_instance.id)
951 assert_eq!(1, num_deleted);
954 async fn expected_post_view(data: &Data, pool: &mut DbPool<'_>) -> PostView {
955 let (inserted_person, inserted_community, inserted_post) = (
956 &data.inserted_person,
957 &data.inserted_community,
960 let agg = PostAggregates::read(pool, inserted_post.id).await.unwrap();
964 id: inserted_post.id,
965 name: inserted_post.name.clone(),
966 creator_id: inserted_person.id,
969 published: inserted_post.published,
971 community_id: inserted_community.id,
977 embed_description: None,
978 embed_video_url: None,
980 ap_id: inserted_post.ap_id.clone(),
982 language_id: LanguageId(47),
983 featured_community: false,
984 featured_local: false,
989 id: inserted_person.id,
990 name: inserted_person.name.clone(),
992 published: inserted_person.published,
994 actor_id: inserted_person.actor_id.clone(),
1003 inbox_url: inserted_person.inbox_url.clone(),
1004 shared_inbox_url: None,
1005 matrix_user_id: None,
1007 instance_id: data.inserted_instance.id,
1008 private_key: inserted_person.private_key.clone(),
1009 public_key: inserted_person.public_key.clone(),
1010 last_refreshed_at: inserted_person.last_refreshed_at,
1012 creator_banned_from_community: false,
1013 community: Community {
1014 id: inserted_community.id,
1015 name: inserted_community.name.clone(),
1020 actor_id: inserted_community.actor_id.clone(),
1022 title: "nada".to_owned(),
1027 posting_restricted_to_mods: false,
1028 published: inserted_community.published,
1029 instance_id: data.inserted_instance.id,
1030 private_key: inserted_community.private_key.clone(),
1031 public_key: inserted_community.public_key.clone(),
1032 last_refreshed_at: inserted_community.last_refreshed_at,
1033 followers_url: inserted_community.followers_url.clone(),
1034 inbox_url: inserted_community.inbox_url.clone(),
1035 shared_inbox_url: inserted_community.shared_inbox_url.clone(),
1036 moderators_url: inserted_community.moderators_url.clone(),
1037 featured_url: inserted_community.featured_url.clone(),
1039 counts: PostAggregates {
1041 post_id: inserted_post.id,
1046 published: agg.published,
1047 newest_comment_time_necro: inserted_post.published,
1048 newest_comment_time: inserted_post.published,
1049 featured_community: false,
1050 featured_local: false,
1052 hot_rank_active: 1728,
1054 subscribed: SubscribedType::NotSubscribed,
1057 creator_blocked: false,