Add CTBREC_DEV mode for all token related requests
If the env virable CTBREC_DEV is set to 1 all token related requests are simulated and not actually send to chaturbate.
This commit is contained in:
parent
7e5360033b
commit
5adb980da6
|
@ -220,6 +220,7 @@ public class Model {
|
|||
}
|
||||
|
||||
public void sendTip(String name, int tokens) throws IOException {
|
||||
if (!Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||
RequestBody body = new FormBody.Builder()
|
||||
.add("csrfmiddlewaretoken", client.getToken())
|
||||
.add("tip_amount", Integer.toString(tokens))
|
||||
|
@ -237,6 +238,7 @@ public class Model {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private StreamInfo getStreamInfo(String modelName) throws IOException, ExecutionException {
|
||||
return streamInfoCache.get(modelName);
|
||||
|
|
|
@ -194,6 +194,7 @@ public class CtbrecApplication extends Application {
|
|||
Task<Integer> task = new Task<Integer>() {
|
||||
@Override
|
||||
protected Integer call() throws Exception {
|
||||
if (!Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||
String username = Config.getInstance().getSettings().username;
|
||||
if (username == null || username.trim().isEmpty()) {
|
||||
throw new IOException("Not logged in");
|
||||
|
@ -211,6 +212,9 @@ public class CtbrecApplication extends Application {
|
|||
} else {
|
||||
throw new IOException("HTTP response: " + resp.code() + " - " + resp.message());
|
||||
}
|
||||
} else {
|
||||
return 1_000_000;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package ctbrec.ui;
|
|||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -36,6 +37,7 @@ public class TipDialog extends TextInputDialog {
|
|||
Task<Integer> task = new Task<Integer>() {
|
||||
@Override
|
||||
protected Integer call() throws Exception {
|
||||
if (!Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||
String username = Config.getInstance().getSettings().username;
|
||||
if (username == null || username.trim().isEmpty()) {
|
||||
throw new IOException("Not logged in");
|
||||
|
@ -57,6 +59,9 @@ public class TipDialog extends TextInputDialog {
|
|||
} else {
|
||||
throw new IOException("HTTP response: " + resp.code() + " - " + resp.message());
|
||||
}
|
||||
} else {
|
||||
return 1_000_000;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue