Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Commit

Permalink
Don't auto add new sfw boards, mark some boards as nsfw
Browse files Browse the repository at this point in the history
Also keep /f/ out
  • Loading branch information
floens committed Jan 26, 2016
1 parent 3916188 commit 39d3113
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ private void setBoardsFromServer(List<Board> serverList) {
}

if (!has) {
Logger.d(TAG, "Adding unknown board: " + serverBoard.value);
/*Logger.d(TAG, "Adding unknown board: " + serverBoard.value);
if (serverBoard.workSafe) {
serverBoard.saved = true;
serverBoard.order = allBoards.size();
}
}*/

allBoards.add(serverBoard);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.floens.chan.core.model;

import android.text.TextUtils;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

Expand Down Expand Up @@ -126,12 +128,12 @@ public Board(String key, String value, boolean saved, boolean workSafe) {
public String description;

public boolean finish() {
if (key == null || value == null || perPage < 0 || pages < 0)
if (TextUtils.isEmpty(key) || TextUtils.isEmpty(value) || perPage < 0 || pages < 0)
return false;

// Also filters out /f/, it can't be viewed anyway
if (cooldownThreads < 0 || cooldownReplies < 0 || cooldownImages < 0 || cooldownRepliesIntra < 0 || cooldownImagesIntra < 0)
if (cooldownThreads < 0 || cooldownReplies < 0 || cooldownImages < 0 || cooldownRepliesIntra < 0 || cooldownImagesIntra < 0) {
return false;
}

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,19 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class BoardsRequest extends JsonReaderRequest<List<Board>> {
public static List<String> BLOCKED = Collections.singletonList(
"f"
);

public static List<String> TREAT_AS_NOT_WORKSAFE = Arrays.asList(
"a", "c", "w", "cm", "jp", "mlp", "lgbt"
);

public BoardsRequest(String url, Listener<List<Board>> listener, ErrorListener errorListener) {
super(url, listener, errorListener);
}
Expand Down Expand Up @@ -169,6 +179,14 @@ private Board readBoardEntry(JsonReader reader) throws IOException {
return null;
}

if (BLOCKED.contains(board.value)) {
return null;
}

if (TREAT_AS_NOT_WORKSAFE.contains(board.value)) {
board.workSafe = false;
}

return board;
}
}

0 comments on commit 39d3113

Please sign in to comment.