From 1814e8dd2a7dbddcc2924665b4c9c9497863ba4e Mon Sep 17 00:00:00 2001 From: FineFindus Date: Wed, 19 Jun 2024 16:31:17 +0200 Subject: [PATCH] feat(Notification): add remove from followers action --- .../org/joinmastodon/android/PushNotificationReceiver.java | 3 +++ .../android/api/requests/accounts/RemoveFromFollowers.java | 2 +- .../org/joinmastodon/android/model/NotificationAction.java | 3 ++- mastodon/src/main/res/values/strings_mo.xml | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index 317bda2f31..12d795b033 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java +++ b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java @@ -21,6 +21,7 @@ import android.util.Log; import org.joinmastodon.android.api.MastodonAPIController; +import org.joinmastodon.android.api.requests.accounts.RemoveFromFollowers; import org.joinmastodon.android.api.requests.accounts.SetAccountFollowed; import org.joinmastodon.android.api.requests.notifications.GetNotificationByID; import org.joinmastodon.android.api.requests.statuses.CreateStatus; @@ -153,6 +154,7 @@ public void onError(ErrorResponse error){ case UNBOOST -> new SetStatusReblogged(statusID, false, preferences.postingDefaultVisibility).exec(accountID); case REPLY -> handleReplyAction(context, accountID, intent, notification, notificationId, preferences); case FOLLOW_BACK -> new SetAccountFollowed(notification.account.id, true, true, false).exec(accountID); + case REMOVE_FOLLOWER -> new RemoveFromFollowers(notification.account.id).exec(accountID); default -> Log.w(TAG, "onReceive: Failed to get NotificationAction"); } } @@ -283,6 +285,7 @@ private void notify(Context context, PushNotification pn, String accountID, org. } case FOLLOW -> { builder.addAction(buildNotificationAction(context, id, accountID, notification, context.getString(R.string.follow_back), NotificationAction.FOLLOW_BACK)); + builder.addAction(buildNotificationAction(context, id, accountID, notification, context.getString(R.string.mo_notification_action_remove_follower), NotificationAction.REMOVE_FOLLOWER)); } } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/RemoveFromFollowers.java b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/RemoveFromFollowers.java index f6b61333e8..7e165a781a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/RemoveFromFollowers.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/requests/accounts/RemoveFromFollowers.java @@ -5,7 +5,7 @@ public class RemoveFromFollowers extends MastodonAPIRequest{ public RemoveFromFollowers(String id){ - super(HttpMethod.POST, "/follow_requests/"+id+"/reject", Relationship.class); + super(HttpMethod.POST, "/accounts/"+id+"/remove_from_followers", Relationship.class); setRequestBody(new Object()); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/NotificationAction.java b/mastodon/src/main/java/org/joinmastodon/android/model/NotificationAction.java index 52b9362439..4b1e2da6cf 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/NotificationAction.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/NotificationAction.java @@ -6,5 +6,6 @@ public enum NotificationAction { UNBOOST, BOOKMARK, REPLY, - FOLLOW_BACK + FOLLOW_BACK, + REMOVE_FOLLOWER } diff --git a/mastodon/src/main/res/values/strings_mo.xml b/mastodon/src/main/res/values/strings_mo.xml index 3276df793d..1482800b32 100644 --- a/mastodon/src/main/res/values/strings_mo.xml +++ b/mastodon/src/main/res/values/strings_mo.xml @@ -139,4 +139,6 @@ Something went wrong while loading this post. If the problem persists, please report it on our Issues page along with the error details. Copy details Read + + Remove from Followers \ No newline at end of file