@@ -17,11 +17,11 @@ interface BaseGetProfileDataResultRow {
1717 post_image_url : string | null ;
1818 post_published_at : Date ;
1919 post_like_count : number ;
20- post_liked_by_user : 0 | 1 ;
20+ post_liked_by_current_user : 0 | 1 ;
2121 post_reply_count : number ;
2222 post_reading_time_minutes : number ;
2323 post_repost_count : number ;
24- post_reposted_by_user : 0 | 1 ;
24+ post_reposted_by_current_user : 0 | 1 ;
2525 post_ap_id : string ;
2626 post_attachments : {
2727 type : string | null ;
@@ -90,7 +90,7 @@ export class PostService {
9090 featureImageUrl : result . post_image_url ?? null ,
9191 publishedAt : result . post_published_at ,
9292 likeCount : result . post_like_count ,
93- likedByMe : result . post_liked_by_user === 1 ,
93+ likedByMe : result . post_liked_by_current_user === 1 ,
9494 replyCount : result . post_reply_count ,
9595 readingTimeMinutes : result . post_reading_time_minutes ,
9696 attachments : result . post_attachments
@@ -113,7 +113,7 @@ export class PostService {
113113 } ,
114114 authoredByMe : result . author_id === accountId ,
115115 repostCount : result . post_repost_count ,
116- repostedByMe : result . post_reposted_by_user === 1 ,
116+ repostedByMe : result . post_reposted_by_current_user === 1 ,
117117 repostedBy : result . reposter_id
118118 ? {
119119 id : result . reposter_id . toString ( ) ,
@@ -235,6 +235,7 @@ export class PostService {
235235 */
236236 async getPostsByAccount (
237237 accountId : number ,
238+ defaultAccountId : number ,
238239 limit : number ,
239240 cursor : string | null ,
240241 ) : Promise < GetProfileDataResult > {
@@ -252,19 +253,19 @@ export class PostService {
252253 'posts_with_source.like_count as post_like_count' ,
253254 this . db . raw (
254255 `CASE
255- WHEN likes .post_id IS NOT NULL THEN 1
256+ WHEN current_user_likes .post_id IS NOT NULL THEN 1
256257 ELSE 0
257- END AS post_liked_by_user ` ,
258+ END AS post_liked_by_current_user ` ,
258259 ) ,
259260 'posts_with_source.reply_count as post_reply_count' ,
260261 'posts_with_source.reading_time_minutes as post_reading_time_minutes' ,
261262 'posts_with_source.attachments as post_attachments' ,
262263 'posts_with_source.repost_count as post_repost_count' ,
263264 this . db . raw (
264265 `CASE
265- WHEN user_reposts .post_id IS NOT NULL THEN 1
266+ WHEN current_user_reposts .post_id IS NOT NULL THEN 1
266267 ELSE 0
267- END AS post_reposted_by_user ` ,
268+ END AS post_reposted_by_current_user ` ,
268269 ) ,
269270 'posts_with_source.ap_id as post_ap_id' ,
270271 // Author fields (Who originally created the post)
@@ -355,21 +356,24 @@ export class PostService {
355356 'reposter_account.id' ,
356357 'posts_with_source.reposter_id' ,
357358 )
358- . leftJoin ( 'likes' , function ( ) {
359- this . on ( 'likes.post_id' , 'posts_with_source.id' ) . andOnVal (
360- 'likes.account_id' ,
359+ . leftJoin ( 'likes as current_user_likes' , function ( ) {
360+ this . on (
361+ 'current_user_likes.post_id' ,
362+ 'posts_with_source.id' ,
363+ ) . andOnVal (
364+ 'current_user_likes.account_id' ,
361365 '=' ,
362- accountId . toString ( ) ,
366+ defaultAccountId . toString ( ) ,
363367 ) ;
364368 } )
365- . leftJoin ( 'reposts as user_reposts ' , function ( ) {
369+ . leftJoin ( 'reposts as current_user_reposts ' , function ( ) {
366370 this . on (
367- 'user_reposts .post_id' ,
371+ 'current_user_reposts .post_id' ,
368372 'posts_with_source.id' ,
369373 ) . andOnVal (
370- 'user_reposts .account_id' ,
374+ 'current_user_reposts .account_id' ,
371375 '=' ,
372- accountId . toString ( ) ,
376+ defaultAccountId . toString ( ) ,
373377 ) ;
374378 } )
375379 . modify ( ( query ) => {
@@ -425,7 +429,7 @@ export class PostService {
425429 'posts.image_url as post_image_url' ,
426430 'posts.published_at as post_published_at' ,
427431 'posts.like_count as post_like_count' ,
428- this . db . raw ( '1 AS post_liked_by_user ' ) , // Since we are selecting from `likes`, this is always 1
432+ this . db . raw ( '1 AS post_liked_by_current_user ' ) , // Since we are selecting from `likes`, this is always 1
429433 'posts.reply_count as post_reply_count' ,
430434 'posts.reading_time_minutes as post_reading_time_minutes' ,
431435 'posts.attachments as post_attachments' ,
@@ -434,7 +438,7 @@ export class PostService {
434438 `CASE
435439 WHEN reposts.post_id IS NOT NULL THEN 1
436440 ELSE 0
437- END AS post_reposted_by_user ` ,
441+ END AS post_reposted_by_current_user ` ,
438442 ) ,
439443 'posts.ap_id as post_ap_id' ,
440444 // Author fields
0 commit comments