From 456f96d574055651297b5de36d44a903a845dd41 Mon Sep 17 00:00:00 2001 From: Felipe Mateus Date: Mon, 24 Mar 2025 08:55:43 -0300 Subject: [PATCH] add remove follow --- app/Http/Controllers/Api/ApiV1Controller.php | 37 +++++++++++++++++++ resources/lang/en/settings.php | 31 ++++++++-------- resources/lang/pt/settings.php | 1 + .../settings/relationships/home.blade.php | 13 ++++++- routes/api.php | 1 + routes/web-api.php | 1 + 6 files changed, 68 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 2c6fba91b..df2cc5831 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -4435,4 +4435,41 @@ class ApiV1Controller extends Controller }) ); } + + public function accountRemoveFollowById(Request $request, $target_id) + { + abort_if(! $request->user(), 403); + + $pid = $request->user()->profile_id; + + if (intval($pid) === intval($target_id)) { + return $this->json(['error' => 'Request invalid! Targed is same user id.'], 500); + } + + Follower::whereProfileId($target_id) + ->whereFollowingId($pid) + ->delete(); + + RelationshipService::refresh($pid, $target_id); + + UnfollowPipeline::dispatch($pid, $pid)->onQueue('high'); + + RelationshipService::refresh($pid, $target_id); + Cache::forget('profile:following:'.$target_id); + Cache::forget('profile:followers:'.$target_id); + Cache::forget('profile:following:'.$pid); + Cache::forget('profile:followers:'.$pid); + Cache::forget('api:local:exp:rec:'.$pid); + Cache::forget('user:account:id:'.$target_id); + Cache::forget('user:account:id:'.$pid); + Cache::forget('profile:follower_count:'.$target_id); + Cache::forget('profile:follower_count:'.$pid); + Cache::forget('profile:following_count:'.$target_id); + Cache::forget('profile:following_count:'.$pid); + AccountService::del($pid); + AccountService::del($target_id); + + + return $this->json([]); + } } diff --git a/resources/lang/en/settings.php b/resources/lang/en/settings.php index b084799be..7900fd56a 100644 --- a/resources/lang/en/settings.php +++ b/resources/lang/en/settings.php @@ -18,13 +18,13 @@ return [ 'export' => 'Export', 'labs' => 'Labs', 'parental_controls' => 'Parental Controls', - + 'submit' => 'Submit', 'error' => 'Error', 'cancel' => 'Cancel', 'save' => 'Save', 'download' => 'Download', - + 'home.account_settings' => 'Account Settings', 'home.change_profile_photo' => 'Change Profile Photo', 'home.select_a_profile_photo' => 'Select a profile photo', @@ -50,21 +50,21 @@ return [ 'home.storage_used' => 'Storage Used', 'home.are_you_sure_you_want_to_delete_your_profile_photo' => 'Are you sure you want to delete your profile photo?', 'home.an_error_occured_please_try_again_later' => 'An error occured, please try again later', - + 'accessibility.reduce_motion' => 'Reduce Motion', 'accessibility.prevent_animation_effects' => 'Prevent animation effects.', 'accessibility.high_contrast_mode' => 'High Contrast Mode', 'accessibility.high_contrast_mode_for_the_visually_impaired' => 'High contrast mode for the visually impaired.', 'accessibility.disable_video_autoplay' => 'Disable video autoplay', 'accessibility.prevent_videos_from_autoplaying' => 'Prevent videos from autoplaying.', - + 'email.email_settings' => 'Email Settings', 'email.email_address' => 'Email Address', 'email.verified' => 'Verified', 'email.unverified' => 'Unverified', 'email.you_need_to' => 'You need to', 'email.verify_your_email' => 'verify your email', - + 'media.default_license' => 'Default License', 'media.set_a_default_license_for_new_posts' => 'Set a default license for new posts.', 'media.sync_licenses' => 'Sync Licenses', @@ -73,7 +73,7 @@ return [ 'media.require_media_descriptions' => 'Require Media Descriptions', 'media.briefly_describe_your_media_to_improve_etc' => 'Briefly describe your media to improve accessibility for vision impaired people.', 'media.not_available_for_mobile_or_3rd_party_apps_etc' => 'Not available for mobile or 3rd party apps at this time.', - + 'password.update_password' => 'Update Password', 'password.current' => 'Current', 'password.your_current_password' => 'Your current password', @@ -81,7 +81,7 @@ return [ 'password.enter_new_password_here' => 'Enter new password here', 'password.confirm' => 'Confirm', 'password.confirm_new_password' => 'Confirm new password', - + 'privacy.privacy_settings' => 'Privacy Settings', 'privacy.private_account' => 'Private Account', 'privacy.when_your_account_is_private_only_people_you_etc' => 'When your account is private, only people you approve can see your photos and videos on pixelfed. Your existing followers won\'t be affected.', @@ -123,7 +123,7 @@ return [ 'privacy.allow_new_follow_requests' => 'Allow new follow requests', 'privacy.block_notifications_from_accounts_i_dont_follow' => 'Block notifications from accounts I don\'t follow', 'privacy.an_error_occured_please_try_again' => 'An error occured. Please try again.', - + 'relationships' => 'Relationships', 'relationships.followers' => 'Followers', 'relationships.following' => 'Following', @@ -134,6 +134,7 @@ return [ 'relationships.unfollow' => 'Unfollow', 'relationships.mute' => 'Mute', 'relationships.block' => 'Block', + 'relationships.removeFollow' => 'Remove Follow', 'relationships.mute_successful' => 'Mute Successful', 'relationships.you_have_successfully_muted_that_user' => 'You have successfully muted that user', 'relationships.block_successful' => 'Block Successful', @@ -142,7 +143,7 @@ return [ 'relationships.you_have_successfully_unfollowed_that_user' => 'You have successfully unfollowed that user', 'relationships.an_error_occured_when_attempting_to_unfollow_this_user' => 'An error occured when attempting to unfollow this user', 'relationships.you_have_successfully_unfollowed_that_hashtag' => 'You have successfully unfollowed that hashtag', - + 'security.two_factor_authentication' => 'Two-factor authentication', 'security.enabled' => 'Enabled', 'security.danger_zone' => 'Danger Zone', @@ -173,23 +174,23 @@ return [ 'security.see_reblogs_from_accounts_you_follow_in_your_home_etc' => 'See reblogs from accounts you follow in your home feed. (Home timeline only)', 'security.photo_reblogs_only' => 'Photo reblogs only', 'security.only_see_reblogs_of_photos_or_photo_albums_home_etc' => 'Only see reblogs of photos or photo albums. (Home timeline only)', - + // incomplete - // the oauth panel is loaded from elsewhere + // the oauth panel is loaded from elsewhere 'developers.oauth_has_not_been_enabled_on_this_instance' => 'OAuth has not been enabled on this instance.', - + // incomplete // import/ig.blade.php seems not in use anymore 'import.import_from_instagram' => 'Import from Instagram', - + 'export.data_export' => 'Data Export', 'export.we_generate_data_exports_once_per_hour_and_they_may_etc' => 'We generate data exports once per hour, and they may not contain the latest data if you\'ve requested them recently.', 'export.statuses' => 'Statuses', 'export.mute_block_lists' => 'Mute/Block List', - + // incomplete // some language outside the blades (in app/Http/Controllers/Settings/LabsSettings.php) 'labs' => 'Labs', 'labs.experimental_features' => 'Experimental features', 'labs.use_dark_mode_theme' => 'Use dark mode theme.', -]; \ No newline at end of file +]; diff --git a/resources/lang/pt/settings.php b/resources/lang/pt/settings.php index 8320fe1e8..f0d810946 100644 --- a/resources/lang/pt/settings.php +++ b/resources/lang/pt/settings.php @@ -134,6 +134,7 @@ return [ 'relationships.unfollow' => 'Deixar de seguir', 'relationships.mute' => 'Silenciar', 'relationships.block' => 'Bloquear', + 'relationships.removeFollow' => 'Remover Seguidor', 'relationships.mute_successful' => 'Silenciamento bem-sucedido', 'relationships.you_have_successfully_muted_that_user' => 'Você silenciou com sucesso esse usuário', 'relationships.block_successful' => 'Bloqueio bem-sucedido', diff --git a/resources/views/settings/relationships/home.blade.php b/resources/views/settings/relationships/home.blade.php index efee38e2e..10c1af825 100644 --- a/resources/views/settings/relationships/home.blade.php +++ b/resources/views/settings/relationships/home.blade.php @@ -71,6 +71,7 @@ {{__('settings.relationships.mute')}} {{__('settings.relationships.block')}} + {{__('settings.relationships.removeFollow')}} @endif @@ -90,7 +91,7 @@ background-color: #F7FAFC; } -@endpush +@endpush @push('scripts')