From fcada1521156f245b9a3ee56d88c9b41a793d2e8 Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Tue, 12 Aug 2025 21:58:25 +0800 Subject: [PATCH] BLOG-128 Fix logic for determining published post access based on user login status (#129) ### Description The relationship between `is_published_only` and `has_logged_in`: | is_published_only | has_logged_in | result | | ----------------- | ------------- | ------ | | T | T | T | | T | F | T | | F | T | F | | F | F | T | ### Package Changes _No response_ ### Screenshots _No response_ ### Reference Resolves #128 ### Checklist - [x] A milestone is set - [x] The related issuse has been linked to this branch Reviewed-on: https://git.squidspirit.com/squid/blog/pulls/129 Co-authored-by: SquidSpirit Co-committed-by: SquidSpirit --- .../application/use_case/get_all_post_info_use_case.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/feature/post/src/application/use_case/get_all_post_info_use_case.rs b/backend/feature/post/src/application/use_case/get_all_post_info_use_case.rs index 3a7eefa..580dc4d 100644 --- a/backend/feature/post/src/application/use_case/get_all_post_info_use_case.rs +++ b/backend/feature/post/src/application/use_case/get_all_post_info_use_case.rs @@ -33,7 +33,15 @@ impl GetAllPostInfoUseCase for GetAllPostInfoUseCaseImpl { is_published_only: bool, user_id: Option, ) -> Result, PostError> { - let is_published_only = is_published_only && user_id.is_some(); + let has_logged_in = user_id.is_some(); + + // | is_published_only | has_logged_in | result | + // | ----------------- | ------------- | ------ | + // | T | T | T | + // | T | F | T | + // | F | T | F | + // | F | F | T | + let is_published_only = is_published_only || !has_logged_in; self.post_repository .get_all_post_info(is_published_only)