Disable follow/unfollow for the time being

This commit is contained in:
0xboobface 2018-10-29 13:49:04 +01:00
parent 8fd09fd521
commit dc6b514d8f
3 changed files with 31 additions and 21 deletions

View File

@ -54,7 +54,11 @@ public class CamsodaFollowedTab extends ThumbOverviewTab implements FollowedTab
@Override @Override
protected void onFail(WorkerStateEvent event) { protected void onFail(WorkerStateEvent event) {
status.setText("Login failed"); String msg = "";
if (event.getSource().getException() != null) {
msg = ": " + event.getSource().getException().getMessage();
}
status.setText("Login failed" + msg);
super.onFail(event); super.onFail(event);
} }

View File

@ -42,7 +42,7 @@ public class CamsodaFollowedUpdateService extends PaginatedScheduledService {
JSONObject m = following.getJSONObject(i); JSONObject m = following.getJSONObject(i);
CamsodaModel model = (CamsodaModel) camsoda.createModel(m.getString("followname")); CamsodaModel model = (CamsodaModel) camsoda.createModel(m.getString("followname"));
boolean online = m.getInt("online") == 1; boolean online = m.getInt("online") == 1;
model.setOnlineState(online ? "offline" : "online"); model.setOnlineState(online ? "online" : "offline");
model.setPreview("https://md.camsoda.com/thumbs/" + model.getName() + ".jpg"); model.setPreview("https://md.camsoda.com/thumbs/" + model.getName() + ".jpg");
models.add(model); models.add(model);
} }

View File

@ -25,7 +25,6 @@ import ctbrec.AbstractModel;
import ctbrec.recorder.download.StreamSource; import ctbrec.recorder.download.StreamSource;
import ctbrec.sites.Site; import ctbrec.sites.Site;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
public class CamsodaModel extends AbstractModel { public class CamsodaModel extends AbstractModel {
@ -171,29 +170,36 @@ public class CamsodaModel extends AbstractModel {
@Override @Override
public boolean follow() throws IOException { public boolean follow() throws IOException {
String url = Camsoda.BASE_URI + "/api/v1/follow/" + getName(); // FIXME follow and unfollow don't work yet, because the HTTP requests need to have
//RequestBody body = new FormBody.Builder().build(); // the cross-site scripting prevention header (e.g. X-CSRF-Token: YDixu6rFg3ovqos9C1YuYpsVd7bxuXlpNnZnelKG),
LOG.debug("Sending follow request {}", url); // but i didn't find out yet, how to get the token (cookie, hmac calc, ?!?)
Request request = new Request.Builder() throw new RuntimeException("Not implemented, yet");
.url(url)
.post(RequestBody.create(null, "")) // String url = Camsoda.BASE_URI + "/api/v1/follow/" + getName();
.addHeader("Content-Lentgh", "0") // //RequestBody body = new FormBody.Builder().build();
.addHeader("Referer", Camsoda.BASE_URI + '/' + getName()) // LOG.debug("Sending follow request {}", url);
.build(); // Request request = new Request.Builder()
Response resp = site.getHttpClient().execute(request, true); // .url(url)
if (resp.isSuccessful()) { // .post(RequestBody.create(null, ""))
System.out.println(resp.body().string()); // .addHeader("Referer", Camsoda.BASE_URI + '/' + getName())
return true; // .addHeader("User-Agent", " Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0")
} else { // .addHeader("Accept", " application/json, text/plain, */*")
resp.close(); // .addHeader("Accept-Language", " de,en-US;q=0.7,en;q=0.3")
throw new IOException("HTTP status " + resp.code() + " " + resp.message()); // .build();
} // Response resp = site.getHttpClient().execute(request, false);
// if (resp.isSuccessful()) {
// System.out.println(resp.body().string());
// return true;
// } else {
// resp.close();
// throw new IOException("HTTP status " + resp.code() + " " + resp.message());
// }
} }
@Override @Override
public boolean unfollow() throws IOException { public boolean unfollow() throws IOException {
// TODO /api/v1/unfollow/" + n.slug // TODO /api/v1/unfollow/" + n.slug
return false; throw new RuntimeException("Not implemented, yet");
} }
@Override @Override