feat(Notification): add remove from followers action

This commit is contained in:
FineFindus 2024-06-19 16:31:17 +02:00
parent 25e654fbab
commit 1814e8dd2a
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
4 changed files with 8 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import org.joinmastodon.android.api.MastodonAPIController; 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.accounts.SetAccountFollowed;
import org.joinmastodon.android.api.requests.notifications.GetNotificationByID; import org.joinmastodon.android.api.requests.notifications.GetNotificationByID;
import org.joinmastodon.android.api.requests.statuses.CreateStatus; import org.joinmastodon.android.api.requests.statuses.CreateStatus;
@ -153,6 +154,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{
case UNBOOST -> new SetStatusReblogged(statusID, false, preferences.postingDefaultVisibility).exec(accountID); case UNBOOST -> new SetStatusReblogged(statusID, false, preferences.postingDefaultVisibility).exec(accountID);
case REPLY -> handleReplyAction(context, accountID, intent, notification, notificationId, preferences); case REPLY -> handleReplyAction(context, accountID, intent, notification, notificationId, preferences);
case FOLLOW_BACK -> new SetAccountFollowed(notification.account.id, true, true, false).exec(accountID); 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"); default -> Log.w(TAG, "onReceive: Failed to get NotificationAction");
} }
} }
@ -283,6 +285,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{
} }
case FOLLOW -> { 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.follow_back), NotificationAction.FOLLOW_BACK));
builder.addAction(buildNotificationAction(context, id, accountID, notification, context.getString(R.string.mo_notification_action_remove_follower), NotificationAction.REMOVE_FOLLOWER));
} }
} }
} }

View File

@ -5,7 +5,7 @@ import org.joinmastodon.android.model.Relationship;
public class RemoveFromFollowers extends MastodonAPIRequest<Relationship>{ public class RemoveFromFollowers extends MastodonAPIRequest<Relationship>{
public RemoveFromFollowers(String id){ 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()); setRequestBody(new Object());
} }
} }

View File

@ -6,5 +6,6 @@ public enum NotificationAction {
UNBOOST, UNBOOST,
BOOKMARK, BOOKMARK,
REPLY, REPLY,
FOLLOW_BACK FOLLOW_BACK,
REMOVE_FOLLOWER
} }

View File

@ -139,4 +139,6 @@
<string name="mo_error_display_text">Something went wrong while loading this post. If the problem persists, please report it on our Issues page along with the error details.</string> <string name="mo_error_display_text">Something went wrong while loading this post. If the problem persists, please report it on our Issues page along with the error details.</string>
<string name="mo_error_display_copy_error_details">Copy details</string> <string name="mo_error_display_copy_error_details">Copy details</string>
<string name="mo_trending_link_read">Read</string> <string name="mo_trending_link_read">Read</string>
<string name="mo_notification_action_remove_follower">Remove from Followers</string>
</resources> </resources>