11use super :: feeds_repository:: { self as FeedsRepository , FeedRow } ;
2+ use crate :: service:: proto:: content:: ContentBody ;
23use crate :: service:: proto:: feeds_service_server:: {
34 FeedsService , FeedsServiceServer ,
45} ;
56use crate :: service:: proto:: {
6- EventBundle , EventHint , FeedPageParams , GetExploreFeedRequest ,
7+ Content , EventBundle , EventHint , FeedPageParams , GetExploreFeedRequest ,
78 GetFeedResponse , GetFollowingFeedRequest , GetIdentityFeedRequest ,
89 GetPostThreadRequest , GetPostThreadResponse , SerializedContent ,
910 SignedEvent ,
1011} ;
12+ use prost:: Message ;
1113use tonic:: { Request , Response , Status } ;
1214
1315#[ derive( Debug ) ]
@@ -252,19 +254,25 @@ impl FeedsService for FeedsServiceImpl {
252254}
253255
254256/// Build the `event_hints` for a feed/thread response: collect the
255- /// unique author identities from `rows`, fetch the latest PROFILE
256- /// event for each, and wrap them in `EventHint`s. Returned as a
257- /// `Status` error if the DB lookup fails.
257+ /// unique author identities from `rows` — plus the identities of any
258+ /// reply-parent posts decoded from each row's serialized Content —
259+ /// fetch the latest PROFILE event for each, and wrap them in
260+ /// `EventHint`s. Returned as a `Status` error if the DB lookup fails.
258261async fn build_profile_hints (
259262 db : & sea_orm:: DatabaseConnection ,
260263 rows : & [ FeedRow ] ,
261264) -> Result < Vec < EventHint > , Status > {
262- let identities: Vec < String > = rows
263- . iter ( )
264- . map ( |( event, _) | event. identity . clone ( ) )
265- . collect :: < std:: collections:: HashSet < _ > > ( )
266- . into_iter ( )
267- . collect ( ) ;
265+ let mut identity_set: std:: collections:: HashSet < String > =
266+ std:: collections:: HashSet :: new ( ) ;
267+ for ( event, content) in rows {
268+ identity_set. insert ( event. identity . clone ( ) ) ;
269+ if let Some ( parent_identity) =
270+ content. as_ref ( ) . and_then ( reply_parent_identity)
271+ {
272+ identity_set. insert ( parent_identity) ;
273+ }
274+ }
275+ let identities: Vec < String > = identity_set. into_iter ( ) . collect ( ) ;
268276
269277 let profile_rows =
270278 FeedsRepository :: Query :: list_latest_profiles_for_identities (
@@ -281,6 +289,18 @@ async fn build_profile_hints(
281289 . collect ( ) )
282290}
283291
292+ fn reply_parent_identity (
293+ content : & :: entity:: content_model:: Model ,
294+ ) -> Option < String > {
295+ let decoded = Content :: decode ( content. serialized_bytes . as_slice ( ) ) . ok ( ) ?;
296+ match decoded. content_body ? {
297+ ContentBody :: Post ( post) => {
298+ Some ( post. reply ?. parent ?. identity ) . filter ( |s| !s. is_empty ( ) )
299+ }
300+ _ => None ,
301+ }
302+ }
303+
284304fn rows_to_bundles ( rows : Vec < FeedRow > ) -> Vec < EventBundle > {
285305 rows. into_iter ( )
286306 . map ( |( event, content) | EventBundle {
0 commit comments