Skip to content

Commit 7ea078b

Browse files
committed
Support remove subreddit from multireddit api method
1 parent c67e0e3 commit 7ea078b

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/main/java/org/quantumbadger/redreader/common/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public static final class Reddit {
149149
public static final String PATH_MULTIREDDITS_MINE = "/api/multi/mine.json";
150150
public static final String PATH_COMMENTS = "/comments/";
151151
public static final String PATH_ME = "/api/v1/me";
152+
public static final String PATH_MULTIREDDIT = "/api/multi";
152153

153154
public static String getScheme() {
154155
return SCHEME_HTTPS;

src/main/java/org/quantumbadger/redreader/reddit/RedditAPI.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,47 @@ public void onFailure(@NonNull final RRError error) {
959959
));
960960
}
961961

962+
public static void removeSubredditFromMultireddit(
963+
final CacheManager cm,
964+
final APIResponseHandler.ActionResponseHandler handler,
965+
final RedditAccount user,
966+
final String multiredditName,
967+
final String subredditName,
968+
final Context context) {
969+
970+
final Uri.Builder builder = Constants.Reddit.getUriBuilder(
971+
Constants.Reddit.PATH_MULTIREDDIT)
972+
.appendPath("user")
973+
.appendPath(user.username)
974+
.appendPath("m")
975+
.appendPath(multiredditName)
976+
.appendPath("r")
977+
.appendPath(subredditName);
978+
979+
cm.makeRequest(createDeleteRequest(
980+
UriString.from(builder.build()),
981+
user,
982+
context,
983+
new CacheRequestCallbacks() {
984+
@Override
985+
public void onDataStreamAvailable(
986+
@NonNull final GenericFactory<SeekableInputStream, IOException>
987+
streamFactory,
988+
final TimestampUTC timestamp,
989+
@NonNull final UUID session,
990+
final boolean fromCache,
991+
@Nullable final String mimetype) {
992+
handler.notifySuccess();
993+
}
994+
995+
@Override
996+
public void onFailure(@NonNull final RRError error) {
997+
handler.notifyFailure(error);
998+
}
999+
}));
1000+
1001+
}
1002+
9621003
@Nullable
9631004
private static APIResponseHandler.APIFailureType findFailureType(final JsonValue response) {
9641005

0 commit comments

Comments
 (0)