Skip to content

Commit

Permalink
feat(Notification): add remove from followers action
Browse files Browse the repository at this point in the history
  • Loading branch information
FineFindus committed Jun 19, 2024
1 parent 25e654f commit 1814e8d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
}
Expand Down Expand Up @@ -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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class RemoveFromFollowers extends MastodonAPIRequest<Relationship>{
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public enum NotificationAction {
UNBOOST,
BOOKMARK,
REPLY,
FOLLOW_BACK
FOLLOW_BACK,
REMOVE_FOLLOWER
}
2 changes: 2 additions & 0 deletions mastodon/src/main/res/values/strings_mo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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_copy_error_details">Copy details</string>
<string name="mo_trending_link_read">Read</string>

<string name="mo_notification_action_remove_follower">Remove from Followers</string>
</resources>

0 comments on commit 1814e8d

Please sign in to comment.