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},
48 use typed_builder::TypedBuilder;
50 type PostViewTuple = (
54 Option<CommunityPersonBan>,
56 Option<CommunityFollower>,
64 sql_function!(fn coalesce(x: sql_types::Nullable<sql_types::BigInt>, y: sql_types::BigInt) -> sql_types::BigInt);
70 my_person_id: Option<PersonId>,
71 is_mod_or_admin: Option<bool>,
72 ) -> Result<Self, Error> {
73 let conn = &mut get_conn(pool).await?;
75 // The left join below will return None in this case
76 let person_id_join = my_person_id.unwrap_or(PersonId(-1));
77 let mut query = post::table
79 .inner_join(person::table)
80 .inner_join(community::table)
82 community_person_ban::table.on(
84 .eq(community_person_ban::community_id)
85 .and(community_person_ban::person_id.eq(post::creator_id)),
88 .inner_join(post_aggregates::table)
90 community_follower::table.on(
92 .eq(community_follower::community_id)
93 .and(community_follower::person_id.eq(person_id_join)),
99 .eq(post_saved::post_id)
100 .and(post_saved::person_id.eq(person_id_join)),
106 .eq(post_read::post_id)
107 .and(post_read::person_id.eq(person_id_join)),
111 person_block::table.on(
113 .eq(person_block::target_id)
114 .and(person_block::person_id.eq(person_id_join)),
120 .eq(post_like::post_id)
121 .and(post_like::person_id.eq(person_id_join)),
125 person_post_aggregates::table.on(
127 .eq(person_post_aggregates::post_id)
128 .and(person_post_aggregates::person_id.eq(person_id_join)),
134 community::all_columns,
135 community_person_ban::all_columns.nullable(),
136 post_aggregates::all_columns,
137 community_follower::all_columns.nullable(),
138 post_saved::all_columns.nullable(),
139 post_read::all_columns.nullable(),
140 person_block::all_columns.nullable(),
141 post_like::score.nullable(),
143 post_aggregates::comments.nullable() - person_post_aggregates::read_comments.nullable(),
144 post_aggregates::comments,
149 // Hide deleted and removed for non-admins or mods
150 if !is_mod_or_admin.unwrap_or(false) {
152 .filter(community::removed.eq(false))
153 .filter(community::deleted.eq(false))
154 .filter(post::removed.eq(false))
155 .filter(post::deleted.eq(false));
162 creator_banned_from_community,
170 ) = query.first::<PostViewTuple>(conn).await?;
172 // If a person is given, then my_vote, if None, should be 0, not null
173 // Necessary to differentiate between other person's votes
174 let my_vote = if my_person_id.is_some() && post_like.is_none() {
184 creator_banned_from_community: creator_banned_from_community.is_some(),
186 subscribed: CommunityFollower::to_subscribed_type(&follower),
187 saved: saved.is_some(),
188 read: read.is_some(),
189 creator_blocked: creator_blocked.is_some(),
196 #[derive(TypedBuilder)]
197 #[builder(field_defaults(default))]
198 pub struct PostQuery<'a> {
201 listing_type: Option<ListingType>,
202 sort: Option<SortType>,
203 creator_id: Option<PersonId>,
204 community_id: Option<CommunityId>,
205 local_user: Option<&'a LocalUser>,
206 search_term: Option<String>,
207 url_search: Option<String>,
208 saved_only: Option<bool>,
209 /// Used to show deleted or removed posts for admins
210 is_mod_or_admin: Option<bool>,
215 impl<'a> PostQuery<'a> {
216 pub async fn list(self) -> Result<Vec<PostView>, Error> {
217 let conn = &mut get_conn(self.pool).await?;
219 // The left join below will return None in this case
220 let person_id_join = self.local_user.map(|l| l.person_id).unwrap_or(PersonId(-1));
221 let local_user_id_join = self.local_user.map(|l| l.id).unwrap_or(LocalUserId(-1));
223 let mut query = post::table
224 .inner_join(person::table)
225 .inner_join(community::table)
227 community_person_ban::table.on(
229 .eq(community_person_ban::community_id)
230 .and(community_person_ban::person_id.eq(post::creator_id)),
233 .inner_join(post_aggregates::table)
235 community_follower::table.on(
237 .eq(community_follower::community_id)
238 .and(community_follower::person_id.eq(person_id_join)),
242 post_saved::table.on(
244 .eq(post_saved::post_id)
245 .and(post_saved::person_id.eq(person_id_join)),
251 .eq(post_read::post_id)
252 .and(post_read::person_id.eq(person_id_join)),
256 person_block::table.on(
258 .eq(person_block::target_id)
259 .and(person_block::person_id.eq(person_id_join)),
263 community_block::table.on(
265 .eq(community_block::community_id)
266 .and(community_block::person_id.eq(person_id_join)),
272 .eq(post_like::post_id)
273 .and(post_like::person_id.eq(person_id_join)),
277 person_post_aggregates::table.on(
279 .eq(person_post_aggregates::post_id)
280 .and(person_post_aggregates::person_id.eq(person_id_join)),
284 local_user_language::table.on(
286 .eq(local_user_language::language_id)
287 .and(local_user_language::local_user_id.eq(local_user_id_join)),
293 community::all_columns,
294 community_person_ban::all_columns.nullable(),
295 post_aggregates::all_columns,
296 community_follower::all_columns.nullable(),
297 post_saved::all_columns.nullable(),
298 post_read::all_columns.nullable(),
299 person_block::all_columns.nullable(),
300 post_like::score.nullable(),
302 post_aggregates::comments.nullable() - person_post_aggregates::read_comments.nullable(),
303 post_aggregates::comments,
308 // Hide deleted and removed for non-admins or mods
309 // TODO This eventually needs to show posts where you are the creator
310 if !self.is_mod_or_admin.unwrap_or(false) {
312 .filter(community::removed.eq(false))
313 .filter(community::deleted.eq(false))
314 .filter(post::removed.eq(false))
315 .filter(post::deleted.eq(false));
318 if self.community_id.is_none() {
319 query = query.then_order_by(post_aggregates::featured_local.desc());
320 } else if let Some(community_id) = self.community_id {
322 .filter(post::community_id.eq(community_id))
323 .then_order_by(post_aggregates::featured_community.desc());
326 if let Some(creator_id) = self.creator_id {
327 query = query.filter(post::creator_id.eq(creator_id));
330 if let Some(listing_type) = self.listing_type {
332 ListingType::Subscribed => {
333 query = query.filter(community_follower::person_id.is_not_null())
335 ListingType::Local => {
336 query = query.filter(community::local.eq(true)).filter(
339 .or(community_follower::person_id.eq(person_id_join)),
342 ListingType::All => {
343 query = query.filter(
346 .or(community_follower::person_id.eq(person_id_join)),
352 if let Some(url_search) = self.url_search {
353 query = query.filter(post::url.eq(url_search));
356 if let Some(search_term) = self.search_term {
357 let searcher = fuzzy_search(&search_term);
358 query = query.filter(
360 .ilike(searcher.clone())
361 .or(post::body.ilike(searcher)),
365 if !self.local_user.map(|l| l.show_nsfw).unwrap_or(false) {
367 .filter(post::nsfw.eq(false))
368 .filter(community::nsfw.eq(false));
371 if !self.local_user.map(|l| l.show_bot_accounts).unwrap_or(true) {
372 query = query.filter(person::bot_account.eq(false));
375 if self.saved_only.unwrap_or(false) {
376 query = query.filter(post_saved::post_id.is_not_null());
378 // Only hide the read posts, if the saved_only is false. Otherwise ppl with the hide_read
379 // setting wont be able to see saved posts.
380 else if !self.local_user.map(|l| l.show_read_posts).unwrap_or(true) {
381 query = query.filter(post_read::post_id.is_null());
384 if self.local_user.is_some() {
385 // Filter out the rows with missing languages
386 query = query.filter(local_user_language::language_id.is_not_null());
388 // Don't show blocked communities or persons
389 query = query.filter(community_block::person_id.is_null());
390 query = query.filter(person_block::person_id.is_null());
393 query = match self.sort.unwrap_or(SortType::Hot) {
394 SortType::Active => query
395 // Hot ranks fade to zero after a few days, and this filter drastically reduces
396 // the number of rows needed to be joined to.
397 .filter(post_aggregates::hot_rank_active.gt(1))
398 .then_order_by(post_aggregates::hot_rank_active.desc()),
399 SortType::Hot => query
400 .filter(post_aggregates::hot_rank.gt(1))
401 .then_order_by(post_aggregates::hot_rank.desc()),
402 SortType::New => query.then_order_by(post_aggregates::published.desc()),
403 SortType::Old => query.then_order_by(post_aggregates::published.asc()),
404 SortType::NewComments => query.then_order_by(post_aggregates::newest_comment_time.desc()),
405 SortType::MostComments => query
406 .then_order_by(post_aggregates::comments.desc())
407 .then_order_by(post_aggregates::published.desc()),
408 SortType::TopAll => query
409 .then_order_by(post_aggregates::score.desc())
410 .then_order_by(post_aggregates::published.desc()),
411 SortType::TopYear => query
412 .filter(post_aggregates::published.gt(now - 1.years()))
413 .then_order_by(post_aggregates::score.desc())
414 .then_order_by(post_aggregates::published.desc()),
415 SortType::TopMonth => query
416 .filter(post_aggregates::published.gt(now - 1.months()))
417 .then_order_by(post_aggregates::score.desc())
418 .then_order_by(post_aggregates::published.desc()),
419 SortType::TopWeek => query
420 .filter(post_aggregates::published.gt(now - 1.weeks()))
421 .then_order_by(post_aggregates::score.desc())
422 .then_order_by(post_aggregates::published.desc()),
423 SortType::TopDay => query
424 .filter(post_aggregates::published.gt(now - 1.days()))
425 .then_order_by(post_aggregates::score.desc())
426 .then_order_by(post_aggregates::published.desc()),
427 SortType::TopHour => query
428 .filter(post_aggregates::published.gt(now - 1.hours()))
429 .then_order_by(post_aggregates::score.desc())
430 .then_order_by(post_aggregates::published.desc()),
431 SortType::TopSixHour => query
432 .filter(post_aggregates::published.gt(now - 6.hours()))
433 .then_order_by(post_aggregates::score.desc())
434 .then_order_by(post_aggregates::published.desc()),
435 SortType::TopTwelveHour => query
436 .filter(post_aggregates::published.gt(now - 12.hours()))
437 .then_order_by(post_aggregates::score.desc())
438 .then_order_by(post_aggregates::published.desc()),
439 SortType::TopThreeMonths => query
440 .filter(post_aggregates::published.gt(now - 3.months()))
441 .then_order_by(post_aggregates::score.desc())
442 .then_order_by(post_aggregates::published.desc()),
443 SortType::TopSixMonths => query
444 .filter(post_aggregates::published.gt(now - 6.months()))
445 .then_order_by(post_aggregates::score.desc())
446 .then_order_by(post_aggregates::published.desc()),
447 SortType::TopNineMonths => query
448 .filter(post_aggregates::published.gt(now - 9.months()))
449 .then_order_by(post_aggregates::score.desc())
450 .then_order_by(post_aggregates::published.desc()),
453 let (limit, offset) = limit_and_offset(self.page, self.limit)?;
455 query = query.limit(limit).offset(offset);
457 debug!("Post View Query: {:?}", debug_query::<Pg, _>(&query));
459 let res = query.load::<PostViewTuple>(conn).await?;
461 Ok(res.into_iter().map(PostView::from_tuple).collect())
465 impl JoinView for PostView {
466 type JoinTuple = PostViewTuple;
467 fn from_tuple(a: Self::JoinTuple) -> Self {
472 creator_banned_from_community: a.3.is_some(),
474 subscribed: CommunityFollower::to_subscribed_type(&a.5),
475 saved: a.6.is_some(),
477 creator_blocked: a.8.is_some(),
479 unread_comments: a.10,
486 use crate::post_view::{PostQuery, PostView};
487 use lemmy_db_schema::{
488 aggregates::structs::PostAggregates,
489 impls::actor_language::UNDETERMINED_ID,
490 newtypes::LanguageId,
492 actor_language::LocalUserLanguage,
493 community::{Community, CommunityInsertForm},
494 community_block::{CommunityBlock, CommunityBlockForm},
497 local_user::{LocalUser, LocalUserInsertForm, LocalUserUpdateForm},
498 person::{Person, PersonInsertForm},
499 person_block::{PersonBlock, PersonBlockForm},
500 post::{Post, PostInsertForm, PostLike, PostLikeForm, PostUpdateForm},
502 traits::{Blockable, Crud, Likeable},
503 utils::{build_db_pool_for_tests, DbPool},
507 use serial_test::serial;
510 inserted_instance: Instance,
511 inserted_person: Person,
512 inserted_local_user: LocalUser,
513 inserted_blocked_person: Person,
514 inserted_bot: Person,
515 inserted_community: Community,
519 async fn init_data(pool: &DbPool) -> Data {
520 let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string())
524 let person_name = "tegan".to_string();
526 let new_person = PersonInsertForm::builder()
527 .name(person_name.clone())
528 .public_key("pubkey".to_string())
529 .instance_id(inserted_instance.id)
532 let inserted_person = Person::create(pool, &new_person).await.unwrap();
534 let local_user_form = LocalUserInsertForm::builder()
535 .person_id(inserted_person.id)
536 .password_encrypted(String::new())
538 let inserted_local_user = LocalUser::create(pool, &local_user_form).await.unwrap();
540 let new_bot = PersonInsertForm::builder()
541 .name("mybot".to_string())
542 .bot_account(Some(true))
543 .public_key("pubkey".to_string())
544 .instance_id(inserted_instance.id)
547 let inserted_bot = Person::create(pool, &new_bot).await.unwrap();
549 let new_community = CommunityInsertForm::builder()
550 .name("test_community_3".to_string())
551 .title("nada".to_owned())
552 .public_key("pubkey".to_string())
553 .instance_id(inserted_instance.id)
556 let inserted_community = Community::create(pool, &new_community).await.unwrap();
558 // Test a person block, make sure the post query doesn't include their post
559 let blocked_person = PersonInsertForm::builder()
561 .public_key("pubkey".to_string())
562 .instance_id(inserted_instance.id)
565 let inserted_blocked_person = Person::create(pool, &blocked_person).await.unwrap();
567 let post_from_blocked_person = PostInsertForm::builder()
568 .name("blocked_person_post".to_string())
569 .creator_id(inserted_blocked_person.id)
570 .community_id(inserted_community.id)
571 .language_id(Some(LanguageId(1)))
574 Post::create(pool, &post_from_blocked_person).await.unwrap();
577 let person_block = PersonBlockForm {
578 person_id: inserted_person.id,
579 target_id: inserted_blocked_person.id,
582 PersonBlock::block(pool, &person_block).await.unwrap();
585 let new_post = PostInsertForm::builder()
586 .name("test post 3".to_string())
587 .creator_id(inserted_person.id)
588 .community_id(inserted_community.id)
589 .language_id(Some(LanguageId(47)))
592 let inserted_post = Post::create(pool, &new_post).await.unwrap();
594 let new_bot_post = PostInsertForm::builder()
595 .name("test bot post".to_string())
596 .creator_id(inserted_bot.id)
597 .community_id(inserted_community.id)
600 let _inserted_bot_post = Post::create(pool, &new_bot_post).await.unwrap();
606 inserted_blocked_person,
615 async fn post_listing_with_person() {
616 let pool = &build_db_pool_for_tests().await;
617 let data = init_data(pool).await;
619 let local_user_form = LocalUserUpdateForm::builder()
620 .show_bot_accounts(Some(false))
622 let inserted_local_user =
623 LocalUser::update(pool, data.inserted_local_user.id, &local_user_form)
627 let read_post_listing = PostQuery::builder()
629 .sort(Some(SortType::New))
630 .community_id(Some(data.inserted_community.id))
631 .local_user(Some(&inserted_local_user))
637 let post_listing_single_with_person = PostView::read(
639 data.inserted_post.id,
640 Some(data.inserted_person.id),
646 let mut expected_post_listing_with_user = expected_post_view(&data, pool).await;
648 // Should be only one person, IE the bot post, and blocked should be missing
649 assert_eq!(1, read_post_listing.len());
651 assert_eq!(expected_post_listing_with_user, read_post_listing[0]);
652 expected_post_listing_with_user.my_vote = Some(0);
654 expected_post_listing_with_user,
655 post_listing_single_with_person
658 let local_user_form = LocalUserUpdateForm::builder()
659 .show_bot_accounts(Some(true))
661 let inserted_local_user =
662 LocalUser::update(pool, data.inserted_local_user.id, &local_user_form)
666 let post_listings_with_bots = PostQuery::builder()
668 .sort(Some(SortType::New))
669 .community_id(Some(data.inserted_community.id))
670 .local_user(Some(&inserted_local_user))
675 // should include bot post which has "undetermined" language
676 assert_eq!(2, post_listings_with_bots.len());
678 cleanup(data, pool).await;
683 async fn post_listing_no_person() {
684 let pool = &build_db_pool_for_tests().await;
685 let data = init_data(pool).await;
687 let read_post_listing_multiple_no_person = PostQuery::builder()
689 .sort(Some(SortType::New))
690 .community_id(Some(data.inserted_community.id))
696 let read_post_listing_single_no_person =
697 PostView::read(pool, data.inserted_post.id, None, None)
701 let expected_post_listing_no_person = expected_post_view(&data, pool).await;
703 // Should be 2 posts, with the bot post, and the blocked
704 assert_eq!(3, read_post_listing_multiple_no_person.len());
707 expected_post_listing_no_person,
708 read_post_listing_multiple_no_person[1]
711 expected_post_listing_no_person,
712 read_post_listing_single_no_person
715 cleanup(data, pool).await;
720 async fn post_listing_block_community() {
721 let pool = &build_db_pool_for_tests().await;
722 let data = init_data(pool).await;
724 let community_block = CommunityBlockForm {
725 person_id: data.inserted_person.id,
726 community_id: data.inserted_community.id,
728 CommunityBlock::block(pool, &community_block).await.unwrap();
730 let read_post_listings_with_person_after_block = PostQuery::builder()
732 .sort(Some(SortType::New))
733 .community_id(Some(data.inserted_community.id))
734 .local_user(Some(&data.inserted_local_user))
739 // Should be 0 posts after the community block
740 assert_eq!(0, read_post_listings_with_person_after_block.len());
742 CommunityBlock::unblock(pool, &community_block)
745 cleanup(data, pool).await;
750 async fn post_listing_like() {
751 let pool = &build_db_pool_for_tests().await;
752 let data = init_data(pool).await;
754 let post_like_form = PostLikeForm {
755 post_id: data.inserted_post.id,
756 person_id: data.inserted_person.id,
760 let inserted_post_like = PostLike::like(pool, &post_like_form).await.unwrap();
762 let expected_post_like = PostLike {
763 id: inserted_post_like.id,
764 post_id: data.inserted_post.id,
765 person_id: data.inserted_person.id,
766 published: inserted_post_like.published,
769 assert_eq!(expected_post_like, inserted_post_like);
771 let post_listing_single_with_person = PostView::read(
773 data.inserted_post.id,
774 Some(data.inserted_person.id),
780 let mut expected_post_with_upvote = expected_post_view(&data, pool).await;
781 expected_post_with_upvote.my_vote = Some(1);
782 expected_post_with_upvote.counts.score = 1;
783 expected_post_with_upvote.counts.upvotes = 1;
784 assert_eq!(expected_post_with_upvote, post_listing_single_with_person);
786 let local_user_form = LocalUserUpdateForm::builder()
787 .show_bot_accounts(Some(false))
789 let inserted_local_user =
790 LocalUser::update(pool, data.inserted_local_user.id, &local_user_form)
794 let read_post_listing = PostQuery::builder()
796 .sort(Some(SortType::New))
797 .community_id(Some(data.inserted_community.id))
798 .local_user(Some(&inserted_local_user))
803 assert_eq!(1, read_post_listing.len());
805 assert_eq!(expected_post_with_upvote, read_post_listing[0]);
807 let like_removed = PostLike::remove(pool, data.inserted_person.id, data.inserted_post.id)
810 assert_eq!(1, like_removed);
811 cleanup(data, pool).await;
816 async fn post_listing_person_language() {
817 let pool = &build_db_pool_for_tests().await;
818 let data = init_data(pool).await;
820 let spanish_id = Language::read_id_from_code(pool, Some("es"))
824 let post_spanish = PostInsertForm::builder()
825 .name("asffgdsc".to_string())
826 .creator_id(data.inserted_person.id)
827 .community_id(data.inserted_community.id)
828 .language_id(Some(spanish_id))
831 Post::create(pool, &post_spanish).await.unwrap();
833 let post_listings_all = PostQuery::builder()
835 .sort(Some(SortType::New))
836 .local_user(Some(&data.inserted_local_user))
842 // no language filters specified, all posts should be returned
843 assert_eq!(3, post_listings_all.len());
845 let french_id = Language::read_id_from_code(pool, Some("fr"))
849 LocalUserLanguage::update(pool, vec![french_id], data.inserted_local_user.id)
853 let post_listing_french = PostQuery::builder()
855 .sort(Some(SortType::New))
856 .local_user(Some(&data.inserted_local_user))
862 // only one post in french and one undetermined should be returned
863 assert_eq!(2, post_listing_french.len());
864 assert!(post_listing_french
866 .any(|p| p.post.language_id == french_id));
868 LocalUserLanguage::update(
870 vec![french_id, UNDETERMINED_ID],
871 data.inserted_local_user.id,
875 let post_listings_french_und = PostQuery::builder()
877 .sort(Some(SortType::New))
878 .local_user(Some(&data.inserted_local_user))
884 // french post and undetermined language post should be returned
885 assert_eq!(2, post_listings_french_und.len());
888 post_listings_french_und[0].post.language_id
890 assert_eq!(french_id, post_listings_french_und[1].post.language_id);
892 cleanup(data, pool).await;
897 async fn post_listings_deleted() {
898 let pool = &build_db_pool_for_tests().await;
899 let data = init_data(pool).await;
904 data.inserted_post.id,
905 &PostUpdateForm::builder().deleted(Some(true)).build(),
910 // Make sure you don't see the deleted post in the results
911 let post_listings_no_admin = PostQuery::builder()
913 .sort(Some(SortType::New))
914 .local_user(Some(&data.inserted_local_user))
915 .is_mod_or_admin(Some(false))
921 assert_eq!(1, post_listings_no_admin.len());
923 // Make sure they see both
924 let post_listings_is_admin = PostQuery::builder()
926 .sort(Some(SortType::New))
927 .local_user(Some(&data.inserted_local_user))
928 .is_mod_or_admin(Some(true))
934 assert_eq!(2, post_listings_is_admin.len());
936 cleanup(data, pool).await;
939 async fn cleanup(data: Data, pool: &DbPool) {
940 let num_deleted = Post::delete(pool, data.inserted_post.id).await.unwrap();
941 Community::delete(pool, data.inserted_community.id)
944 Person::delete(pool, data.inserted_person.id).await.unwrap();
945 Person::delete(pool, data.inserted_bot.id).await.unwrap();
946 Person::delete(pool, data.inserted_blocked_person.id)
949 Instance::delete(pool, data.inserted_instance.id)
952 assert_eq!(1, num_deleted);
955 async fn expected_post_view(data: &Data, pool: &DbPool) -> PostView {
956 let (inserted_person, inserted_community, inserted_post) = (
957 &data.inserted_person,
958 &data.inserted_community,
961 let agg = PostAggregates::read(pool, inserted_post.id).await.unwrap();
965 id: inserted_post.id,
966 name: inserted_post.name.clone(),
967 creator_id: inserted_person.id,
970 published: inserted_post.published,
972 community_id: inserted_community.id,
978 embed_description: None,
979 embed_video_url: None,
981 ap_id: inserted_post.ap_id.clone(),
983 language_id: LanguageId(47),
984 featured_community: false,
985 featured_local: false,
990 id: inserted_person.id,
991 name: inserted_person.name.clone(),
993 published: inserted_person.published,
995 actor_id: inserted_person.actor_id.clone(),
1004 inbox_url: inserted_person.inbox_url.clone(),
1005 shared_inbox_url: None,
1006 matrix_user_id: None,
1008 instance_id: data.inserted_instance.id,
1009 private_key: inserted_person.private_key.clone(),
1010 public_key: inserted_person.public_key.clone(),
1011 last_refreshed_at: inserted_person.last_refreshed_at,
1013 creator_banned_from_community: false,
1014 community: Community {
1015 id: inserted_community.id,
1016 name: inserted_community.name.clone(),
1021 actor_id: inserted_community.actor_id.clone(),
1023 title: "nada".to_owned(),
1028 posting_restricted_to_mods: false,
1029 published: inserted_community.published,
1030 instance_id: data.inserted_instance.id,
1031 private_key: inserted_community.private_key.clone(),
1032 public_key: inserted_community.public_key.clone(),
1033 last_refreshed_at: inserted_community.last_refreshed_at,
1034 followers_url: inserted_community.followers_url.clone(),
1035 inbox_url: inserted_community.inbox_url.clone(),
1036 shared_inbox_url: inserted_community.shared_inbox_url.clone(),
1037 moderators_url: inserted_community.moderators_url.clone(),
1038 featured_url: inserted_community.featured_url.clone(),
1040 counts: PostAggregates {
1042 post_id: inserted_post.id,
1047 published: agg.published,
1048 newest_comment_time_necro: inserted_post.published,
1049 newest_comment_time: inserted_post.published,
1050 featured_community: false,
1051 featured_local: false,
1053 hot_rank_active: 1728,
1055 subscribed: SubscribedType::NotSubscribed,
1058 creator_blocked: false,