2020-09-25 18:58:04 +02:00
|
|
|
package app.fedilab.fedilabtube.client;
|
|
|
|
/* Copyright 2020 Thomas Schneider
|
|
|
|
*
|
|
|
|
* This file is a part of TubeLab
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
|
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
|
|
* Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
|
|
|
* see <http://www.gnu.org/licenses>. */
|
|
|
|
|
2020-09-26 16:46:51 +02:00
|
|
|
import android.app.Activity;
|
2020-09-25 18:58:04 +02:00
|
|
|
import android.content.Context;
|
2020-09-26 16:46:51 +02:00
|
|
|
import android.content.Intent;
|
2020-09-25 18:58:04 +02:00
|
|
|
import android.content.SharedPreferences;
|
2020-09-26 16:46:51 +02:00
|
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Looper;
|
2020-11-01 18:34:53 +01:00
|
|
|
import android.webkit.MimeTypeMap;
|
2020-09-25 18:58:04 +02:00
|
|
|
|
2020-11-01 18:34:53 +01:00
|
|
|
import java.io.ByteArrayOutputStream;
|
2020-09-25 18:58:04 +02:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
2020-11-01 18:34:53 +01:00
|
|
|
import java.io.InputStream;
|
2020-09-26 16:46:51 +02:00
|
|
|
import java.io.UnsupportedEncodingException;
|
2020-10-09 19:14:20 +02:00
|
|
|
import java.net.URL;
|
2020-09-26 16:46:51 +02:00
|
|
|
import java.net.URLDecoder;
|
2020-09-25 18:58:04 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2020-09-27 16:33:43 +02:00
|
|
|
import app.fedilab.fedilabtube.BuildConfig;
|
2020-09-26 16:46:51 +02:00
|
|
|
import app.fedilab.fedilabtube.MainActivity;
|
2020-09-25 18:58:04 +02:00
|
|
|
import app.fedilab.fedilabtube.R;
|
|
|
|
import app.fedilab.fedilabtube.client.data.AccountData;
|
2020-09-29 17:42:15 +02:00
|
|
|
import app.fedilab.fedilabtube.client.data.BlockData;
|
2020-09-25 18:58:04 +02:00
|
|
|
import app.fedilab.fedilabtube.client.data.CaptionData;
|
|
|
|
import app.fedilab.fedilabtube.client.data.ChannelData;
|
|
|
|
import app.fedilab.fedilabtube.client.data.CommentData;
|
|
|
|
import app.fedilab.fedilabtube.client.data.InstanceData;
|
|
|
|
import app.fedilab.fedilabtube.client.data.NotificationData;
|
|
|
|
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
|
|
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
2020-09-29 17:42:15 +02:00
|
|
|
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
|
2020-09-25 18:58:04 +02:00
|
|
|
import app.fedilab.fedilabtube.client.entities.AccountCreation;
|
|
|
|
import app.fedilab.fedilabtube.client.entities.ChannelParams;
|
|
|
|
import app.fedilab.fedilabtube.client.entities.Error;
|
|
|
|
import app.fedilab.fedilabtube.client.entities.InstanceParams;
|
2020-09-26 16:46:51 +02:00
|
|
|
import app.fedilab.fedilabtube.client.entities.Oauth;
|
|
|
|
import app.fedilab.fedilabtube.client.entities.OauthParams;
|
2020-09-27 16:33:43 +02:00
|
|
|
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
2020-09-25 18:58:04 +02:00
|
|
|
import app.fedilab.fedilabtube.client.entities.PeertubeInformation;
|
2020-10-03 16:22:19 +02:00
|
|
|
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
2020-09-25 18:58:04 +02:00
|
|
|
import app.fedilab.fedilabtube.client.entities.PlaylistParams;
|
|
|
|
import app.fedilab.fedilabtube.client.entities.Rating;
|
|
|
|
import app.fedilab.fedilabtube.client.entities.Report;
|
2020-09-27 16:33:43 +02:00
|
|
|
import app.fedilab.fedilabtube.client.entities.Token;
|
2020-10-01 17:42:03 +02:00
|
|
|
import app.fedilab.fedilabtube.client.entities.UserMe;
|
2020-10-30 14:45:37 +01:00
|
|
|
import app.fedilab.fedilabtube.client.entities.UserSettings;
|
2020-09-26 10:22:11 +02:00
|
|
|
import app.fedilab.fedilabtube.client.entities.VideoParams;
|
2020-09-26 16:46:51 +02:00
|
|
|
import app.fedilab.fedilabtube.client.entities.WellKnownNodeinfo;
|
2020-09-25 18:58:04 +02:00
|
|
|
import app.fedilab.fedilabtube.helper.Helper;
|
2020-09-26 16:46:51 +02:00
|
|
|
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
|
|
|
import app.fedilab.fedilabtube.sqlite.Sqlite;
|
2020-09-25 18:58:04 +02:00
|
|
|
import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
|
|
|
|
import app.fedilab.fedilabtube.viewmodel.CommentVM;
|
|
|
|
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
2020-09-26 10:22:11 +02:00
|
|
|
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
|
2020-09-25 18:58:04 +02:00
|
|
|
import okhttp3.MediaType;
|
|
|
|
import okhttp3.MultipartBody;
|
|
|
|
import okhttp3.RequestBody;
|
2020-09-29 17:42:15 +02:00
|
|
|
import okhttp3.ResponseBody;
|
2020-09-25 18:58:04 +02:00
|
|
|
import retrofit2.Call;
|
|
|
|
import retrofit2.Response;
|
|
|
|
import retrofit2.Retrofit;
|
|
|
|
import retrofit2.converter.gson.GsonConverterFactory;
|
|
|
|
|
2020-10-04 17:51:09 +02:00
|
|
|
@SuppressWarnings({"unused", "RedundantSuppression"})
|
2020-09-25 18:58:04 +02:00
|
|
|
public class RetrofitPeertubeAPI {
|
|
|
|
|
2020-10-14 16:06:17 +02:00
|
|
|
private final String finalUrl;
|
|
|
|
private final Context _context;
|
|
|
|
private final String instance;
|
2020-10-17 18:50:20 +02:00
|
|
|
private final String count;
|
2020-09-25 18:58:04 +02:00
|
|
|
private String token;
|
|
|
|
private Set<String> selection;
|
|
|
|
|
|
|
|
public RetrofitPeertubeAPI(Context context) {
|
|
|
|
_context = context;
|
|
|
|
instance = Helper.getLiveInstance(context);
|
|
|
|
finalUrl = "https://" + Helper.getLiveInstance(context) + "/api/v1/";
|
2020-10-08 18:46:18 +02:00
|
|
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
|
|
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public RetrofitPeertubeAPI(Context context, String instance, String token) {
|
|
|
|
_context = context;
|
|
|
|
this.instance = instance;
|
|
|
|
this.token = token;
|
|
|
|
finalUrl = "https://" + instance + "/api/v1/";
|
2020-10-08 18:13:04 +02:00
|
|
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
|
|
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
|
2020-10-30 14:45:37 +01:00
|
|
|
|
2020-09-27 16:33:43 +02:00
|
|
|
public static void updateCredential(Activity activity, String token, String client_id, String client_secret, String refresh_token, String host) {
|
|
|
|
new Thread(() -> {
|
2020-09-29 17:42:15 +02:00
|
|
|
AccountData.Account account;
|
2020-09-27 16:33:43 +02:00
|
|
|
String instance;
|
|
|
|
if (host.startsWith("tube") || BuildConfig.full_instances) {
|
|
|
|
instance = host;
|
|
|
|
} else {
|
|
|
|
instance = Helper.getPeertubeUrl(host);
|
|
|
|
}
|
|
|
|
try {
|
2020-10-01 17:42:03 +02:00
|
|
|
UserMe userMe = new RetrofitPeertubeAPI(activity, instance, token).verifyCredentials();
|
|
|
|
account = userMe.getAccount();
|
2020-09-27 16:33:43 +02:00
|
|
|
} catch (Error error) {
|
|
|
|
Error.displayError(activity, error);
|
|
|
|
error.printStackTrace();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
//At the state the instance can be encoded
|
|
|
|
instance = URLDecoder.decode(instance, "utf-8");
|
|
|
|
} catch (UnsupportedEncodingException ignored) {
|
|
|
|
}
|
|
|
|
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
|
|
account.setToken(token);
|
|
|
|
account.setClient_id(client_id);
|
|
|
|
account.setClient_secret(client_secret);
|
|
|
|
account.setRefresh_token(refresh_token);
|
|
|
|
account.setHost(instance);
|
|
|
|
SQLiteDatabase db = Sqlite.getInstance(activity.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
|
|
|
boolean userExists = new AccountDAO(activity, db).userExist(account);
|
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
2020-10-01 17:42:03 +02:00
|
|
|
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
|
2020-09-27 16:33:43 +02:00
|
|
|
if (!host.startsWith("tube")) {
|
|
|
|
editor.putString(Helper.PREF_INSTANCE, host);
|
|
|
|
}
|
|
|
|
editor.apply();
|
|
|
|
if (userExists)
|
|
|
|
new AccountDAO(activity, db).updateAccountCredential(account);
|
|
|
|
else {
|
|
|
|
if (account.getUsername() != null && account.getCreatedAt() != null)
|
|
|
|
new AccountDAO(activity, db).insertAccount(account);
|
|
|
|
}
|
|
|
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
|
|
Runnable myRunnable = () -> {
|
|
|
|
Intent mainActivity = new Intent(activity, MainActivity.class);
|
|
|
|
mainActivity.putExtra(Helper.INTENT_ACTION, Helper.ADD_USER_INTENT);
|
|
|
|
activity.startActivity(mainActivity);
|
|
|
|
activity.finish();
|
|
|
|
};
|
|
|
|
mainHandler.post(myRunnable);
|
|
|
|
}).start();
|
|
|
|
}
|
|
|
|
|
2020-09-29 17:42:15 +02:00
|
|
|
private String getToken() {
|
2020-10-22 08:57:51 +02:00
|
|
|
if( token != null) {
|
|
|
|
return "Bearer " + token;
|
|
|
|
}else{
|
|
|
|
return null;
|
|
|
|
}
|
2020-09-29 17:42:15 +02:00
|
|
|
}
|
|
|
|
|
2020-09-25 18:58:04 +02:00
|
|
|
private PeertubeService init() {
|
|
|
|
Retrofit retrofit = new Retrofit.Builder()
|
|
|
|
.baseUrl(finalUrl)
|
|
|
|
.addConverterFactory(GsonConverterFactory.create())
|
|
|
|
.build();
|
|
|
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
2020-09-27 16:33:43 +02:00
|
|
|
if (token == null) {
|
|
|
|
token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
|
|
|
}
|
2020-09-25 18:58:04 +02:00
|
|
|
selection = sharedpreferences.getStringSet(_context.getString(R.string.set_video_language_choice), null);
|
|
|
|
return retrofit.create(PeertubeService.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
private PeertubeService initTranslation() {
|
|
|
|
Retrofit retrofit = new Retrofit.Builder()
|
|
|
|
.baseUrl("https://" + instance)
|
|
|
|
.addConverterFactory(GsonConverterFactory.create())
|
|
|
|
.build();
|
|
|
|
return retrofit.create(PeertubeService.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* Verifiy credential of the authenticated user *synchronously*
|
|
|
|
* @return Account
|
|
|
|
*/
|
2020-09-27 16:33:43 +02:00
|
|
|
public Token manageToken(OauthParams oauthParams) throws Error {
|
2020-09-25 18:58:04 +02:00
|
|
|
PeertubeService peertubeService = init();
|
2020-09-27 16:33:43 +02:00
|
|
|
Call<Token> refreshTokenCall = null;
|
|
|
|
if (oauthParams.getGrant_type().compareTo("password") == 0) {
|
|
|
|
refreshTokenCall = peertubeService.createToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getGrant_type(), oauthParams.getUsername(), oauthParams.getPassword());
|
2020-09-29 17:42:15 +02:00
|
|
|
} else if (oauthParams.getGrant_type().compareTo("refresh_token") == 0) {
|
2020-09-27 18:33:51 +02:00
|
|
|
refreshTokenCall = peertubeService.refreshToken(oauthParams.getClient_id(), oauthParams.getClient_secret(), oauthParams.getRefresh_token(), oauthParams.getGrant_type());
|
2020-09-27 16:33:43 +02:00
|
|
|
}
|
|
|
|
if (refreshTokenCall != null) {
|
|
|
|
try {
|
|
|
|
Response<Token> response = refreshTokenCall.execute();
|
|
|
|
if (response.isSuccessful()) {
|
2020-09-27 18:33:51 +02:00
|
|
|
Token tokenReply = response.body();
|
|
|
|
if (oauthParams.getGrant_type().compareTo("refresh_token") == 0 && tokenReply != null) {
|
|
|
|
SharedPreferences sharedpreferences = _context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, tokenReply.getAccess_token());
|
|
|
|
editor.apply();
|
|
|
|
SQLiteDatabase db = Sqlite.getInstance(_context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
2020-09-29 17:42:15 +02:00
|
|
|
new AccountDAO(_context, db).updateAccountToken(tokenReply);
|
2020-09-27 18:33:51 +02:00
|
|
|
}
|
|
|
|
return tokenReply;
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-27 16:33:43 +02:00
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
|
|
|
error.setError(response.errorBody().string());
|
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
throw error;
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
2020-09-27 16:33:43 +02:00
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve notifications
|
|
|
|
*
|
|
|
|
* @param max_id String pagination
|
|
|
|
* @param since_id String pagination
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse getNotifications(String max_id, String since_id) {
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
PeertubeService peertubeService = init();
|
2020-10-08 18:13:04 +02:00
|
|
|
|
2020-10-08 18:46:18 +02:00
|
|
|
Call<NotificationData> notificationsCall = peertubeService.getNotifications("Bearer " + token, max_id, "20", since_id);
|
2020-09-25 18:58:04 +02:00
|
|
|
try {
|
2020-09-29 17:42:15 +02:00
|
|
|
Response<NotificationData> response = notificationsCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setPeertubeNotifications(response.body().data);
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-09-26 16:46:51 +02:00
|
|
|
/**
|
|
|
|
* Get caption content
|
2020-09-27 16:33:43 +02:00
|
|
|
*
|
2020-09-26 16:46:51 +02:00
|
|
|
* @param path String path to caption
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse getCaptionContent(String path) {
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
Call<String> captionContentCall = peertubeService.getCaptionContent(path);
|
|
|
|
try {
|
|
|
|
Response<String> response = captionContentCall.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setCaptionText(response.body());
|
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-26 16:46:51 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get videos in a channel
|
2020-09-27 16:33:43 +02:00
|
|
|
*
|
2020-09-26 16:46:51 +02:00
|
|
|
* @param channelId String id of the channel
|
2020-09-27 16:33:43 +02:00
|
|
|
* @param max_id String pagination
|
2020-09-26 16:46:51 +02:00
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse getVideosForChannel(String channelId, String max_id) {
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
PeertubeService peertubeService = init();
|
2020-10-08 18:13:04 +02:00
|
|
|
Call<VideoData> videoCall = peertubeService.getChannelVideos(channelId, max_id, count);
|
2020-09-26 16:46:51 +02:00
|
|
|
if (videoCall != null) {
|
|
|
|
try {
|
2020-09-27 14:12:06 +02:00
|
|
|
Response<VideoData> response = videoCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setPeertubes(response.body().data);
|
2020-09-26 16:46:51 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-26 16:46:51 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-10-10 09:25:00 +02:00
|
|
|
public APIResponse getTL(TimelineVM.TimelineType timelineType, String max_id, String forAccount) {
|
2020-09-25 18:58:04 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
PeertubeService peertubeService = init();
|
2020-09-26 19:31:38 +02:00
|
|
|
Call<VideoData> videoCall = null;
|
2020-09-27 16:33:43 +02:00
|
|
|
ArrayList<String> filter = selection != null ? new ArrayList<>(selection) : null;
|
2020-09-25 18:58:04 +02:00
|
|
|
switch (timelineType) {
|
2020-09-26 10:22:11 +02:00
|
|
|
case MY_VIDEOS:
|
2020-10-08 18:13:04 +02:00
|
|
|
videoCall = peertubeService.getMyVideos(getToken(), max_id, count);
|
2020-09-26 10:22:11 +02:00
|
|
|
break;
|
2020-10-16 17:03:07 +02:00
|
|
|
case ACCOUNT_VIDEOS:
|
|
|
|
videoCall = peertubeService.getVideosForAccount(forAccount, max_id, count);
|
|
|
|
break;
|
2020-09-25 18:58:04 +02:00
|
|
|
case SUBSCRIBTIONS:
|
2020-10-10 09:25:00 +02:00
|
|
|
if (forAccount == null) {
|
|
|
|
videoCall = peertubeService.getSubscriptionVideos(getToken(), max_id, count, filter);
|
|
|
|
} else {
|
|
|
|
videoCall = peertubeService.getChannelVideos(forAccount, max_id, count);
|
|
|
|
}
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
case MOST_LIKED:
|
2020-10-22 08:57:51 +02:00
|
|
|
videoCall = peertubeService.getMostLikedVideos(getToken(), max_id, count, filter);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
case LOCAL:
|
2020-10-22 08:57:51 +02:00
|
|
|
videoCall = peertubeService.getLocalVideos(getToken(), max_id, count, filter);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
case TRENDING:
|
2020-10-22 08:57:51 +02:00
|
|
|
videoCall = peertubeService.getTrendingVideos(getToken(), max_id, count, filter);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
case HISTORY:
|
2020-10-08 18:13:04 +02:00
|
|
|
videoCall = peertubeService.getHistory(getToken(), max_id, count);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
case RECENT:
|
2020-10-22 08:57:51 +02:00
|
|
|
videoCall = peertubeService.getRecentlyAddedVideos(getToken(), max_id, count, filter);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (videoCall != null) {
|
|
|
|
try {
|
2020-09-26 19:31:38 +02:00
|
|
|
Response<VideoData> response = videoCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setPeertubes(response.body().data);
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-27 11:11:39 +02:00
|
|
|
* Retrieves overview videos *synchronously*
|
2020-09-25 18:58:04 +02:00
|
|
|
*
|
2020-09-27 11:11:39 +02:00
|
|
|
* @param page String id pagination
|
2020-09-25 18:58:04 +02:00
|
|
|
* @return APIResponse
|
|
|
|
*/
|
2020-09-27 11:11:39 +02:00
|
|
|
public APIResponse getOverviewVideo(String page) {
|
2020-09-25 18:58:04 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
PeertubeService peertubeService = init();
|
2020-09-27 16:33:43 +02:00
|
|
|
ArrayList<String> filter = selection != null ? new ArrayList<>(selection) : null;
|
2020-10-22 08:57:51 +02:00
|
|
|
Call<OverviewVideo> overviewVideoCall = peertubeService.getOverviewVideos(getToken(), page, filter);
|
2020-09-25 18:58:04 +02:00
|
|
|
try {
|
2020-09-27 11:37:48 +02:00
|
|
|
Response<OverviewVideo> response = overviewVideoCall.execute();
|
2020-09-26 19:31:38 +02:00
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
2020-09-27 11:37:48 +02:00
|
|
|
apiResponse.setOverviewVideo(response.body());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-09-29 17:42:15 +02:00
|
|
|
|
|
|
|
/**
|
2020-10-07 17:46:15 +02:00
|
|
|
* Retrieves playlists for a video *synchronously*
|
2020-09-29 17:42:15 +02:00
|
|
|
*
|
2020-10-07 17:46:15 +02:00
|
|
|
* @param videoIds List<String> ids of videos
|
2020-09-29 17:42:15 +02:00
|
|
|
* @return APIResponse
|
|
|
|
*/
|
2020-10-07 17:46:15 +02:00
|
|
|
public APIResponse getVideosExist(List<String> videoIds) {
|
2020-09-29 17:42:15 +02:00
|
|
|
PeertubeService peertubeService = init();
|
2020-10-07 17:46:15 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
2020-09-29 17:42:15 +02:00
|
|
|
try {
|
2020-10-07 17:46:15 +02:00
|
|
|
Call<Map<String, List<PlaylistExist>>> videoExistsInPlaylist = peertubeService.getVideoExistsInPlaylist(getToken(), videoIds);
|
|
|
|
Response<Map<String, List<PlaylistExist>>> response = videoExistsInPlaylist.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setVideoExistPlaylist(response.body());
|
2020-09-29 17:42:15 +02:00
|
|
|
} else {
|
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-10-30 16:21:56 +01:00
|
|
|
/**
|
|
|
|
* Update history
|
|
|
|
*
|
|
|
|
* @param videoId String
|
|
|
|
* @param currentTime int
|
|
|
|
*/
|
|
|
|
public void updateHistory(String videoId, long currentTime) {
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
Call<String> updateUser = peertubeService.addToHistory(getToken(),
|
|
|
|
videoId,
|
|
|
|
currentTime
|
|
|
|
);
|
|
|
|
try {
|
|
|
|
Response<String> response = updateUser.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setActionReturn(response.body());
|
|
|
|
} else {
|
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
2020-10-07 17:46:15 +02:00
|
|
|
|
2020-10-30 14:45:37 +01:00
|
|
|
/**
|
|
|
|
* Update account information
|
|
|
|
*
|
|
|
|
* @param userSettings UserSettings
|
|
|
|
*/
|
2020-11-01 18:34:53 +01:00
|
|
|
public UserMe.AvatarResponse updateUser(UserSettings userSettings) throws IOException, Error {
|
2020-10-30 14:45:37 +01:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
2020-11-01 18:34:53 +01:00
|
|
|
UserMe.AvatarResponse avatarResponse = null;
|
2020-10-30 14:45:37 +01:00
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
Call<String> updateUser = peertubeService.updateUser(getToken(),
|
|
|
|
userSettings.isVideosHistoryEnabled(),
|
|
|
|
userSettings.isAutoPlayVideo(),
|
2020-10-31 18:24:52 +01:00
|
|
|
userSettings.isAutoPlayNextVideo(),
|
2020-10-30 14:45:37 +01:00
|
|
|
userSettings.isWebTorrentEnabled(),
|
|
|
|
userSettings.getVideoLanguages(),
|
|
|
|
userSettings.getDescription(),
|
|
|
|
userSettings.getDisplayName()
|
|
|
|
);
|
2020-10-31 18:24:52 +01:00
|
|
|
Response<String> response = updateUser.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setActionReturn(response.body());
|
|
|
|
} else {
|
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
|
|
|
error.setError(response.errorBody().string());
|
2020-10-30 14:45:37 +01:00
|
|
|
} else {
|
2020-11-01 18:34:53 +01:00
|
|
|
|
2020-10-31 18:24:52 +01:00
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
2020-10-30 14:45:37 +01:00
|
|
|
}
|
2020-10-31 18:24:52 +01:00
|
|
|
throw error;
|
2020-10-30 14:45:37 +01:00
|
|
|
}
|
|
|
|
if (userSettings.getAvatarfile() != null) {
|
2020-11-01 18:34:53 +01:00
|
|
|
InputStream inputStream = _context.getContentResolver().openInputStream(userSettings.getAvatarfile());
|
|
|
|
ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
|
|
|
|
int bufferSize = 1024;
|
|
|
|
byte[] buffer = new byte[bufferSize];
|
|
|
|
|
|
|
|
int len;
|
|
|
|
while ((len = inputStream.read(buffer)) != -1) {
|
|
|
|
byteBuffer.write(buffer, 0, len);
|
|
|
|
}
|
|
|
|
byte[] imageBytes = byteBuffer.toByteArray();
|
|
|
|
String mime = MimeTypeMap.getFileExtensionFromUrl(userSettings.getAvatarfile().toString());
|
|
|
|
if( mime == null || mime.trim().length() == 0) {
|
|
|
|
mime = "png";
|
|
|
|
}
|
|
|
|
RequestBody requestFile = RequestBody.create(MediaType.parse("image/"+mime), imageBytes);
|
|
|
|
MultipartBody.Part bodyThumbnail = MultipartBody.Part.createFormData("avatarfile", userSettings.getFileName(), requestFile);
|
|
|
|
Call<UserMe.AvatarResponse> updateProfilePicture = peertubeService.updateProfilePicture(getToken(), bodyThumbnail);
|
|
|
|
Response<UserMe.AvatarResponse> responseAvatar = updateProfilePicture.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
avatarResponse = responseAvatar.body();
|
|
|
|
} else {
|
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
|
|
|
error.setError(response.errorBody().string());
|
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
throw error;
|
|
|
|
}
|
2020-10-30 14:45:37 +01:00
|
|
|
}
|
2020-11-01 18:34:53 +01:00
|
|
|
return avatarResponse;
|
2020-10-30 14:45:37 +01:00
|
|
|
}
|
|
|
|
|
2020-09-25 18:58:04 +02:00
|
|
|
/**
|
|
|
|
* Check if users via their uris are following the authenticated user
|
|
|
|
*
|
|
|
|
* @param uris List<String>
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
2020-09-29 17:42:15 +02:00
|
|
|
public APIResponse areFollowing(List<String> uris) {
|
2020-09-25 18:58:04 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
PeertubeService peertubeService = init();
|
2020-10-07 17:46:15 +02:00
|
|
|
Call<Map<String, Boolean>> followingCall = peertubeService.getSubscriptionsExist(getToken(), uris);
|
2020-09-25 18:58:04 +02:00
|
|
|
try {
|
2020-10-07 17:46:15 +02:00
|
|
|
Response<Map<String, Boolean>> response = followingCall.execute();
|
2020-09-25 18:58:04 +02:00
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setRelationships(response.body());
|
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find captions for a video
|
|
|
|
*
|
|
|
|
* @param videoId String id of the video
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse getCaptions(String videoId) {
|
|
|
|
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
PeertubeService peertubeService = init();
|
2020-09-27 14:12:06 +02:00
|
|
|
Call<CaptionData> captions = peertubeService.getCaptions(videoId);
|
2020-09-25 18:58:04 +02:00
|
|
|
try {
|
2020-09-27 14:12:06 +02:00
|
|
|
Response<CaptionData> response = captions.execute();
|
2020-09-27 16:33:43 +02:00
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
2020-09-27 14:12:06 +02:00
|
|
|
apiResponse.setCaptions(response.body().data);
|
2020-10-01 17:42:03 +02:00
|
|
|
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns informations about Peertube such privacies, licenses, etc.
|
|
|
|
*
|
|
|
|
* @return PeertubeInformation information about peertube
|
|
|
|
*/
|
|
|
|
public PeertubeInformation getPeertubeInformation() {
|
|
|
|
PeertubeInformation peertubeInformation = new PeertubeInformation();
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
Call<Map<Integer, String>> categories = peertubeService.getCategories();
|
|
|
|
try {
|
|
|
|
Response<Map<Integer, String>> response = categories.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
peertubeInformation.setCategories(response.body());
|
|
|
|
} else {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
2020-09-29 17:42:15 +02:00
|
|
|
error.setError(response.errorBody().string());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
Call<Map<String, String>> languages = peertubeService.getLanguages();
|
|
|
|
try {
|
|
|
|
Response<Map<String, String>> response = languages.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
peertubeInformation.setLanguages(response.body());
|
|
|
|
} else {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
2020-09-29 17:42:15 +02:00
|
|
|
error.setError(response.errorBody().string());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
Call<Map<Integer, String>> privacies = peertubeService.getPrivacies();
|
|
|
|
try {
|
|
|
|
Response<Map<Integer, String>> response = privacies.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
peertubeInformation.setPrivacies(response.body());
|
|
|
|
} else {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
2020-09-29 17:42:15 +02:00
|
|
|
error.setError(response.errorBody().string());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
Call<Map<Integer, String>> playlistsPrivacies = peertubeService.getPlaylistsPrivacies();
|
|
|
|
try {
|
|
|
|
Response<Map<Integer, String>> response = playlistsPrivacies.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
peertubeInformation.setPlaylistPrivacies(response.body());
|
|
|
|
} else {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
2020-09-29 17:42:15 +02:00
|
|
|
error.setError(response.errorBody().string());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
Call<Map<Integer, String>> licenses = peertubeService.getLicences();
|
|
|
|
try {
|
|
|
|
Response<Map<Integer, String>> response = licenses.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
peertubeInformation.setLicences(response.body());
|
|
|
|
} else {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
2020-09-29 17:42:15 +02:00
|
|
|
error.setError(response.errorBody().string());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2020-10-05 14:34:01 +02:00
|
|
|
String lang = Locale.getDefault().getLanguage();
|
2020-10-06 18:49:15 +02:00
|
|
|
if (lang.contains("-")) {
|
|
|
|
if (!lang.split("-")[0].trim().toLowerCase().startsWith("zh")) {
|
2020-10-05 14:34:01 +02:00
|
|
|
lang = lang.split("-")[0];
|
2020-10-06 18:49:15 +02:00
|
|
|
} else {
|
2020-10-05 14:34:01 +02:00
|
|
|
lang = lang.split("-")[0] + "-" + lang.split("-")[1].toUpperCase();
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 18:50:20 +02:00
|
|
|
if (lang == null || lang.trim().length() == 0) {
|
2020-10-14 16:39:27 +02:00
|
|
|
lang = "en";
|
|
|
|
}
|
2020-09-25 18:58:04 +02:00
|
|
|
Call<Map<String, String>> translations = initTranslation().getTranslations(lang);
|
|
|
|
try {
|
|
|
|
Response<Map<String, String>> response = translations.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
peertubeInformation.setTranslations(response.body());
|
|
|
|
} else {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
2020-10-05 14:34:01 +02:00
|
|
|
translations = initTranslation().getTranslations("en");
|
|
|
|
try {
|
|
|
|
response = translations.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
peertubeInformation.setTranslations(response.body());
|
|
|
|
} else {
|
|
|
|
error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
|
|
|
error.setError(response.errorBody().string());
|
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return peertubeInformation;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get instances
|
|
|
|
*
|
|
|
|
* @param instanceParams InstanceParams
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse getInstances(InstanceParams instanceParams) {
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
LinkedHashMap<String, String> params = new LinkedHashMap<>();
|
|
|
|
params.put("start", "0");
|
|
|
|
params.put("count", "250");
|
|
|
|
params.put("healthy", "true");
|
|
|
|
params.put("signup", "true");
|
|
|
|
params.put("minUserQuota", instanceParams.getMinUserQuota());
|
|
|
|
Call<InstanceData> instancesCall = peertubeService.getInstances(params, instanceParams.getNsfwPolicy(), instanceParams.getCategoriesOr(), instanceParams.getLanguagesOr());
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
|
|
|
Response<InstanceData> response = instancesCall.execute();
|
|
|
|
if (!response.isSuccessful()) {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
InstanceData instanceData = response.body();
|
|
|
|
if (instanceData != null) {
|
|
|
|
apiResponse.setInstances(instanceData.data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-10-31 10:37:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves next peertube videos *synchronously*
|
|
|
|
*
|
|
|
|
* @param tags List<String> search
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse searchNextVideos(List<String> tags) {
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
Call<VideoData> searchVideosCall = peertubeService.searchNextVideo(getToken(), tags, "0" , "20");
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
|
|
|
Response<VideoData> response = searchVideosCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setPeertubes(response.body().data);
|
|
|
|
} else {
|
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-09-25 18:58:04 +02:00
|
|
|
/**
|
|
|
|
* Retrieves peertube search *synchronously*
|
|
|
|
*
|
|
|
|
* @param query String search
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse searchPeertube(String query, String max_id) {
|
|
|
|
PeertubeService peertubeService = init();
|
2020-10-22 08:57:51 +02:00
|
|
|
Call<VideoData> searchVideosCall = peertubeService.searchVideos(getToken(), query, max_id, count);
|
2020-09-25 18:58:04 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
2020-09-27 16:33:43 +02:00
|
|
|
Response<VideoData> response = searchVideosCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setPeertubes(response.body().data);
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* Verifiy credential of the authenticated user *synchronously*
|
|
|
|
* @return Account
|
|
|
|
*/
|
2020-10-01 17:42:03 +02:00
|
|
|
public UserMe verifyCredentials() throws Error {
|
2020-09-25 18:58:04 +02:00
|
|
|
PeertubeService peertubeService = init();
|
2020-10-01 17:42:03 +02:00
|
|
|
Call<UserMe> accountCall = peertubeService.verifyCredentials("Bearer " + token);
|
2020-09-25 18:58:04 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
2020-10-01 17:42:03 +02:00
|
|
|
Response<UserMe> response = accountCall.execute();
|
2020-09-27 16:33:43 +02:00
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
2020-09-25 18:58:04 +02:00
|
|
|
return response.body();
|
|
|
|
} else {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
2020-09-29 17:42:15 +02:00
|
|
|
error.setError(response.errorBody().string());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
2020-09-27 16:33:43 +02:00
|
|
|
throw error;
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public APIResponse report(Report report) {
|
|
|
|
PeertubeService peertubeService = init();
|
2020-10-13 17:50:52 +02:00
|
|
|
Call<Report.ReportReturn> report1 = peertubeService.report(getToken(), report);
|
2020-09-25 18:58:04 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
2020-10-13 17:50:52 +02:00
|
|
|
Response<Report.ReportReturn> response = report1.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setActionReturn(response.body().getItemStr().getLabel());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-09-26 10:22:11 +02:00
|
|
|
/***
|
|
|
|
* Update a video
|
|
|
|
* @param videoId String id of the video
|
|
|
|
* @param videoParams VideoParams params for the video
|
|
|
|
* @param thumbnail File thumbnail
|
|
|
|
* @param previewfile File preview
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse updateVideo(String videoId, VideoParams videoParams, File thumbnail, File previewfile) {
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
MultipartBody.Part bodyThumbnail = null;
|
2020-09-27 16:33:43 +02:00
|
|
|
MultipartBody.Part bodyPreviewfile = null;
|
2020-09-26 10:22:11 +02:00
|
|
|
if (thumbnail != null) {
|
|
|
|
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), thumbnail);
|
|
|
|
bodyThumbnail = MultipartBody.Part.createFormData("image", thumbnail.getName(), requestFile);
|
|
|
|
}
|
|
|
|
if (previewfile != null) {
|
|
|
|
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), previewfile);
|
|
|
|
bodyPreviewfile = MultipartBody.Part.createFormData("image", previewfile.getName(), requestFile);
|
|
|
|
}
|
2020-09-29 17:42:15 +02:00
|
|
|
RequestBody channelId = RequestBody.create(MediaType.parse("text/plain"), videoParams.getChannelId());
|
|
|
|
RequestBody description = RequestBody.create(MediaType.parse("text/plain"), videoParams.getDescription());
|
|
|
|
RequestBody language = RequestBody.create(MediaType.parse("text/plain"), videoParams.getLanguage());
|
|
|
|
RequestBody license = RequestBody.create(MediaType.parse("text/plain"), videoParams.getLicence());
|
|
|
|
RequestBody name = RequestBody.create(MediaType.parse("text/plain"), videoParams.getName());
|
|
|
|
|
|
|
|
List<RequestBody> tags = null;
|
2020-10-01 17:42:03 +02:00
|
|
|
if (videoParams.getTags() != null && videoParams.getTags().size() > 0) {
|
2020-09-29 17:42:15 +02:00
|
|
|
tags = new ArrayList<>();
|
|
|
|
for (String tag : videoParams.getTags()) {
|
|
|
|
tags.add(RequestBody.create(MediaType.parse("text/plain"), tag));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RequestBody support = null;
|
|
|
|
if (videoParams.getSupport() != null) {
|
|
|
|
support = RequestBody.create(MediaType.parse("text/plain"), videoParams.getSupport());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Call<String> upload = peertubeService.updateVideo(getToken(), videoId,
|
|
|
|
channelId, name, videoParams.getCategory(), videoParams.isCommentsEnabled(), description, videoParams.isDownloadEnabled(), language, license, videoParams.isNsfw(),
|
|
|
|
videoParams.getPrivacy(), support, tags, videoParams.isWaitTranscoding()
|
|
|
|
, bodyThumbnail, bodyPreviewfile);
|
2020-09-26 10:22:11 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
|
|
|
Response<String> response = upload.execute();
|
|
|
|
if (response.isSuccessful()) {
|
2020-09-29 17:42:15 +02:00
|
|
|
apiResponse.setActionReturn("ok");
|
2020-09-26 10:22:11 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-26 10:22:11 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-09-25 18:58:04 +02:00
|
|
|
public APIResponse createAccount(AccountCreation accountCreation) {
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
Call<String> report1 = peertubeService.register(accountCreation.getEmail(), accountCreation.getPassword(), accountCreation.getUsername(), accountCreation.getDisplayName());
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
|
|
|
Response<String> response = report1.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setActionReturn(accountCreation.getEmail());
|
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
public APIResponse post(ActionType actionType, String id, String element) {
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
Call<String> postCall = null;
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
switch (actionType) {
|
|
|
|
case FOLLOW:
|
2020-09-29 17:42:15 +02:00
|
|
|
postCall = peertubeService.follow(getToken(), id);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
case UNFOLLOW:
|
2020-09-29 17:42:15 +02:00
|
|
|
postCall = peertubeService.unfollow(getToken(), id);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
case MUTE:
|
2020-09-29 17:42:15 +02:00
|
|
|
postCall = peertubeService.mute(getToken(), id);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
case UNMUTE:
|
2020-09-29 17:42:15 +02:00
|
|
|
postCall = peertubeService.unmute(getToken(), id);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
case RATEVIDEO:
|
2020-09-29 17:42:15 +02:00
|
|
|
postCall = peertubeService.rate(getToken(), id, element);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
case PEERTUBEDELETEVIDEO:
|
2020-09-29 17:42:15 +02:00
|
|
|
postCall = peertubeService.deleteVideo(getToken(), id);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
2020-10-01 17:42:03 +02:00
|
|
|
case PEERTUBEDELETECOMMENT:
|
|
|
|
postCall = peertubeService.deleteComment(getToken(), id, element);
|
|
|
|
break;
|
2020-10-13 17:50:52 +02:00
|
|
|
case PEERTUBE_DELETE_ALL_COMMENT_FOR_ACCOUNT:
|
|
|
|
postCall = peertubeService.deleteAllCommentForAccount(getToken(), id, element);
|
|
|
|
break;
|
2020-09-25 18:58:04 +02:00
|
|
|
case DELETE_CHANNEL:
|
2020-09-29 17:42:15 +02:00
|
|
|
postCall = peertubeService.deleteChannel(getToken(), id);
|
2020-09-25 18:58:04 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (postCall != null) {
|
|
|
|
try {
|
|
|
|
Response<String> response = postCall.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setActionReturn(response.body());
|
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-10-16 17:03:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get single account by its handle
|
|
|
|
*
|
|
|
|
* @param accountHandle String
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse getAccount(String accountHandle) {
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
Call<AccountData.Account> accountDataCall = peertubeService.getAccount(accountHandle);
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
if (accountDataCall != null) {
|
|
|
|
try {
|
|
|
|
Response<AccountData.Account> response = accountDataCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
List<AccountData.Account> accountList = new ArrayList<>();
|
|
|
|
accountList.add(response.body());
|
|
|
|
apiResponse.setAccounts(accountList);
|
|
|
|
} else {
|
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-25 18:58:04 +02:00
|
|
|
/**
|
2020-09-29 17:42:15 +02:00
|
|
|
* Get muted accounts
|
2020-09-25 18:58:04 +02:00
|
|
|
*
|
2020-09-29 17:42:15 +02:00
|
|
|
* @param maxId String (pagination)
|
2020-09-25 18:58:04 +02:00
|
|
|
* @return APIResponse
|
|
|
|
*/
|
2020-09-29 17:42:15 +02:00
|
|
|
public APIResponse getMuted(String maxId) {
|
2020-09-25 18:58:04 +02:00
|
|
|
PeertubeService peertubeService = init();
|
2020-10-08 18:13:04 +02:00
|
|
|
Call<BlockData> accountDataCall = peertubeService.getMuted("Bearer " + token, maxId, count);
|
2020-09-29 17:42:15 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
if (accountDataCall != null) {
|
|
|
|
try {
|
|
|
|
Response<BlockData> response = accountDataCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setMuted(response.body().getData());
|
|
|
|
} else {
|
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
2020-09-29 17:42:15 +02:00
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get subscriptions data
|
|
|
|
*
|
|
|
|
* @param maxId String (pagination)
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse getSubscribtions(String maxId) {
|
|
|
|
PeertubeService peertubeService = init();
|
2020-10-10 09:25:00 +02:00
|
|
|
Call<ChannelData> channelDataCall = peertubeService.getSubscription("Bearer " + token, maxId, count);
|
2020-09-25 18:58:04 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
2020-10-10 09:25:00 +02:00
|
|
|
if (channelDataCall != null) {
|
2020-09-25 18:58:04 +02:00
|
|
|
try {
|
2020-10-10 09:25:00 +02:00
|
|
|
Response<ChannelData> response = channelDataCall.execute();
|
2020-09-29 17:42:15 +02:00
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
2020-10-10 09:25:00 +02:00
|
|
|
apiResponse.setChannels(response.body().data);
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create or update a channel
|
|
|
|
*
|
|
|
|
* @param apiAction ChannelsVM.action
|
|
|
|
* @param channelId String
|
|
|
|
* @param channelParams PlaylistParams
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
2020-09-26 19:31:38 +02:00
|
|
|
public APIResponse createOrUpdateChannel(ChannelsVM.action apiAction, String channelId, ChannelParams channelParams) {
|
2020-09-25 18:58:04 +02:00
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
|
|
|
if (apiAction == ChannelsVM.action.CREATE_CHANNEL) {
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<ChannelData.ChannelCreation> stringCall = peertubeService.addChannel(getToken(), channelParams);
|
|
|
|
Response<ChannelData.ChannelCreation> response = stringCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setActionReturn(response.body().getVideoChannel().getId());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (apiAction == ChannelsVM.action.UPDATE_CHANNEL) {
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<String> stringCall = peertubeService.updateChannel(getToken(), channelId, channelParams);
|
2020-09-25 18:58:04 +02:00
|
|
|
Response<String> response = stringCall.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setActionReturn(response.body());
|
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-09-26 16:46:51 +02:00
|
|
|
/**
|
|
|
|
* Get Oauth
|
2020-09-27 16:33:43 +02:00
|
|
|
*
|
2020-09-26 16:46:51 +02:00
|
|
|
* @return APIResponse
|
|
|
|
*/
|
2020-09-27 16:33:43 +02:00
|
|
|
public Oauth oauthClient(String client_name, String redirect_uris, String scopes, String website) {
|
2020-09-26 16:46:51 +02:00
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
try {
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<Oauth> oauth;
|
|
|
|
if (BuildConfig.full_instances) {
|
|
|
|
oauth = peertubeService.getOauth(client_name, redirect_uris, scopes, website);
|
|
|
|
} else {
|
|
|
|
oauth = peertubeService.getOauthAcad();
|
|
|
|
}
|
2020-09-26 16:46:51 +02:00
|
|
|
Response<Oauth> response = oauth.execute();
|
2020-09-27 16:33:43 +02:00
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
2020-09-26 16:46:51 +02:00
|
|
|
return response.body();
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get NodeInfo
|
2020-09-27 16:33:43 +02:00
|
|
|
*
|
2020-09-26 16:46:51 +02:00
|
|
|
* @return APIResponse
|
|
|
|
*/
|
2020-09-29 17:42:15 +02:00
|
|
|
public WellKnownNodeinfo.NodeInfo getNodeInfo() {
|
2020-10-09 19:14:20 +02:00
|
|
|
PeertubeService peertubeService = initTranslation();
|
2020-09-26 16:46:51 +02:00
|
|
|
try {
|
|
|
|
Call<WellKnownNodeinfo> wellKnownNodeinfoCall = peertubeService.getWellKnownNodeinfo();
|
|
|
|
Response<WellKnownNodeinfo> response = wellKnownNodeinfoCall.execute();
|
2020-09-27 16:33:43 +02:00
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
2020-10-09 19:14:20 +02:00
|
|
|
int size = response.body().getLinks().size();
|
|
|
|
String url = response.body().getLinks().get(size - 1).getHref();
|
|
|
|
if (size > 0 && url != null) {
|
|
|
|
peertubeService = initTranslation();
|
|
|
|
String path = new URL(url).getPath();
|
|
|
|
path = path.replaceFirst("/", "").trim();
|
|
|
|
Call<WellKnownNodeinfo.NodeInfo> nodeinfo = peertubeService.getNodeinfo(path);
|
2020-09-26 16:46:51 +02:00
|
|
|
Response<WellKnownNodeinfo.NodeInfo> responseNodeInfo = nodeinfo.execute();
|
|
|
|
return responseNodeInfo.body();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-09-25 18:58:04 +02:00
|
|
|
/**
|
|
|
|
* Get channel data
|
|
|
|
*
|
|
|
|
* @param accountDataType AccountDataType (type of requested data)
|
|
|
|
* @param element String (pagination or name for the channel)
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse getChannelData(DataType accountDataType, String element) {
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
switch (accountDataType) {
|
2020-09-26 10:22:11 +02:00
|
|
|
case MY_CHANNELS:
|
2020-09-25 18:58:04 +02:00
|
|
|
case CHANNELS_FOR_ACCOUNT:
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<ChannelData> channelDataCall = peertubeService.getChannelsForAccount(element);
|
2020-09-25 18:58:04 +02:00
|
|
|
try {
|
2020-09-29 17:42:15 +02:00
|
|
|
Response<ChannelData> response = channelDataCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setChannels(response.body().data);
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CHANNEL:
|
|
|
|
Call<ChannelData.Channel> channelCall = peertubeService.getChannel(element);
|
|
|
|
try {
|
|
|
|
Response<ChannelData.Channel> response = channelCall.execute();
|
|
|
|
if (!response.isSuccessful()) {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
ChannelData.Channel channelData = response.body();
|
|
|
|
if (channelData != null) {
|
|
|
|
List<ChannelData.Channel> channelList = new ArrayList<>();
|
|
|
|
channelList.add(channelData);
|
|
|
|
apiResponse.setChannels(channelList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create or update a playlist
|
|
|
|
*
|
|
|
|
* @param apiAction PlaylistsVM.action
|
|
|
|
* @param playlistId String
|
|
|
|
* @param playlistParams PlaylistParams
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse createOrUpdatePlaylist(PlaylistsVM.action apiAction, String playlistId, PlaylistParams playlistParams, File thumbnail) {
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
MultipartBody.Part body = null;
|
|
|
|
if (thumbnail != null) {
|
|
|
|
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), thumbnail);
|
|
|
|
body = MultipartBody.Part.createFormData("image", thumbnail.getName(), requestFile);
|
|
|
|
}
|
|
|
|
try {
|
2020-09-29 17:42:15 +02:00
|
|
|
RequestBody displayName = RequestBody.create(MediaType.parse("text/plain"), playlistParams.getDisplayName());
|
|
|
|
RequestBody description = RequestBody.create(MediaType.parse("text/plain"), playlistParams.getDescription());
|
|
|
|
RequestBody channelId = RequestBody.create(MediaType.parse("text/plain"), playlistParams.getVideoChannelId());
|
2020-09-25 18:58:04 +02:00
|
|
|
if (apiAction == PlaylistsVM.action.CREATE_PLAYLIST) {
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<VideoPlaylistData.VideoPlaylistCreation> stringCall = peertubeService.addPlaylist(getToken(), displayName, description, playlistParams.getPrivacy(), channelId, body);
|
|
|
|
Response<VideoPlaylistData.VideoPlaylistCreation> response = stringCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setActionReturn(response.body().getVideoPlaylist().getId());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (apiAction == PlaylistsVM.action.UPDATE_PLAYLIST) {
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<String> stringCall = peertubeService.updatePlaylist(getToken(), playlistId, displayName, description, playlistParams.getPrivacy(), channelId, body);
|
2020-09-25 18:58:04 +02:00
|
|
|
Response<String> response = stringCall.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setActionReturn(response.body());
|
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
2020-10-03 16:22:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-25 18:58:04 +02:00
|
|
|
/**
|
|
|
|
* Retrieves playlist *synchronously*
|
|
|
|
*
|
|
|
|
* @param type PlaylistsVM.action
|
|
|
|
* @param playlistId String id of the playlist
|
|
|
|
* @param videoId String id of the video
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
2020-10-08 18:13:04 +02:00
|
|
|
public APIResponse playlistAction(PlaylistsVM.action type, String playlistId, String videoId, String acct, String max_id) {
|
2020-09-25 18:58:04 +02:00
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
|
|
|
if (type == PlaylistsVM.action.GET_PLAYLIST_INFO) {
|
|
|
|
Call<PlaylistData.Playlist> playlistCall = peertubeService.getPlaylist(playlistId);
|
|
|
|
Response<PlaylistData.Playlist> response = playlistCall.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
List<PlaylistData.Playlist> playlists = new ArrayList<>();
|
|
|
|
playlists.add(response.body());
|
|
|
|
apiResponse.setPlaylists(playlists);
|
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (type == PlaylistsVM.action.GET_PLAYLISTS) {
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<PlaylistData> playlistsCall = peertubeService.getPlaylistsForAccount(getToken(), acct);
|
2020-09-27 18:33:51 +02:00
|
|
|
Response<PlaylistData> response = playlistsCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setPlaylists(response.body().data);
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-10-08 18:13:04 +02:00
|
|
|
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
2020-10-03 18:37:34 +02:00
|
|
|
} else if (type == PlaylistsVM.action.GET_LIST_VIDEOS) {
|
2020-10-08 18:13:04 +02:00
|
|
|
Call<VideoPlaylistData> videosPlayList = peertubeService.getVideosPlayList(getToken(), playlistId, max_id, count);
|
2020-09-29 17:42:15 +02:00
|
|
|
Response<VideoPlaylistData> response = videosPlayList.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setVideoPlaylist(response.body().data);
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} else if (type == PlaylistsVM.action.DELETE_PLAYLIST) {
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<String> stringCall = peertubeService.deletePlaylist(getToken(), playlistId);
|
2020-09-25 18:58:04 +02:00
|
|
|
Response<String> response = stringCall.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setActionReturn(response.body());
|
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} else if (type == PlaylistsVM.action.ADD_VIDEOS) {
|
2020-10-03 18:37:34 +02:00
|
|
|
Call<VideoPlaylistData.PlaylistElement> stringCall = peertubeService.addVideoInPlaylist(getToken(), playlistId, videoId);
|
|
|
|
Response<VideoPlaylistData.PlaylistElement> response = stringCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setActionReturn(response.body().getVideoPlaylistElement().getId());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} else if (type == PlaylistsVM.action.DELETE_VIDEOS) {
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<String> stringCall = peertubeService.deleteVideoInPlaylist(getToken(), playlistId, videoId);
|
2020-09-25 18:58:04 +02:00
|
|
|
Response<String> response = stringCall.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setActionReturn(response.body());
|
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
2020-09-29 17:42:15 +02:00
|
|
|
private void setError(APIResponse apiResponse, int responseCode, ResponseBody errorBody) {
|
|
|
|
Error error;
|
|
|
|
if (errorBody != null) {
|
|
|
|
try {
|
|
|
|
error = generateError(responseCode, errorBody.string());
|
|
|
|
} catch (IOException e) {
|
|
|
|
error = new Error();
|
|
|
|
error.setStatusCode(responseCode);
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error = new Error();
|
|
|
|
error.setStatusCode(responseCode);
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
apiResponse.setError(error);
|
|
|
|
}
|
|
|
|
|
2020-10-02 18:22:19 +02:00
|
|
|
public APIResponse getComments(CommentVM.action type, String videoId, String forCommentId, String max_id) {
|
2020-09-25 18:58:04 +02:00
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
|
|
|
if (type == CommentVM.action.GET_THREAD) {
|
2020-10-08 18:13:04 +02:00
|
|
|
Call<CommentData> commentsCall = peertubeService.getComments(videoId, max_id, count);
|
2020-09-27 14:12:06 +02:00
|
|
|
Response<CommentData> response = commentsCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
apiResponse.setComments(response.body().data);
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} else if (type == CommentVM.action.GET_REPLIES) {
|
2020-10-15 15:16:41 +02:00
|
|
|
Call<CommentData.CommentThreadData> commentsCall = peertubeService.getReplies(videoId, forCommentId);
|
|
|
|
Response<CommentData.CommentThreadData> response = commentsCall.execute();
|
2020-09-27 14:12:06 +02:00
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
2020-10-15 15:16:41 +02:00
|
|
|
apiResponse.setCommentThreadData(response.body());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manage comments *synchronously*
|
|
|
|
*
|
|
|
|
* @param type (CommentVM.action
|
|
|
|
* @param videoId String id of the video
|
|
|
|
* @param toCommentId String id of the comment for replies
|
|
|
|
* @param text String text
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
2020-09-26 16:46:51 +02:00
|
|
|
public APIResponse commentAction(RetrofitPeertubeAPI.ActionType type, String videoId, String toCommentId, String text) {
|
2020-09-25 18:58:04 +02:00
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
2020-09-26 16:46:51 +02:00
|
|
|
if (type == ActionType.ADD_COMMENT) {
|
2020-10-14 16:06:17 +02:00
|
|
|
Call<CommentData.CommentPosted> commentPostedCall = peertubeService.postComment(getToken(), videoId, text);
|
|
|
|
Response<CommentData.CommentPosted> response = commentPostedCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
List<CommentData.Comment> comments = new ArrayList<>();
|
|
|
|
comments.add(response.body().getComment());
|
|
|
|
apiResponse.setComments(comments);
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
2020-09-26 16:46:51 +02:00
|
|
|
} else if (type == ActionType.REPLY) {
|
2020-10-14 16:06:17 +02:00
|
|
|
Call<CommentData.CommentPosted> commentPostedCall = peertubeService.postReply(getToken(), videoId, toCommentId, text);
|
|
|
|
Response<CommentData.CommentPosted> response = commentPostedCall.execute();
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
List<CommentData.Comment> comments = new ArrayList<>();
|
|
|
|
comments.add(response.body().getComment());
|
|
|
|
apiResponse.setComments(comments);
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves playlist *synchronously*
|
|
|
|
*
|
|
|
|
* @param id String id
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse getPlayist(String id) {
|
|
|
|
PeertubeService peertubeService = init();
|
|
|
|
Call<PlaylistData.Playlist> playlistCall;
|
|
|
|
playlistCall = peertubeService.getPlaylist(id);
|
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
|
|
|
Response<PlaylistData.Playlist> response = playlistCall.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
List<PlaylistData.Playlist> playlists = new ArrayList<>();
|
|
|
|
playlists.add(response.body());
|
|
|
|
apiResponse.setPlaylists(playlists);
|
|
|
|
} else {
|
2020-09-29 17:42:15 +02:00
|
|
|
setError(apiResponse, response.code(), response.errorBody());
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
private Error generateError(int responseCode, String message) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(responseCode);
|
|
|
|
if (message != null) {
|
|
|
|
error.setError(message);
|
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves rating of user on a video *synchronously*
|
|
|
|
*
|
|
|
|
* @param id String id
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
|
|
|
public APIResponse getRating(String id) {
|
|
|
|
PeertubeService peertubeService = init();
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<Rating> rating = peertubeService.getRating(getToken(), id);
|
2020-09-25 18:58:04 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
|
|
|
Response<Rating> response = rating.execute();
|
|
|
|
if (response.isSuccessful()) {
|
|
|
|
apiResponse.setRating(response.body());
|
|
|
|
} else {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
2020-09-29 17:42:15 +02:00
|
|
|
error.setError(response.errorBody().string());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves videos *synchronously*
|
|
|
|
*
|
|
|
|
* @param id String id
|
|
|
|
* @return APIResponse
|
|
|
|
*/
|
2020-09-29 17:42:15 +02:00
|
|
|
public APIResponse getVideos(String id, boolean myVideo) {
|
2020-09-25 18:58:04 +02:00
|
|
|
PeertubeService peertubeService = init();
|
2020-09-29 17:42:15 +02:00
|
|
|
Call<VideoData.Video> video;
|
|
|
|
if (myVideo) {
|
|
|
|
video = peertubeService.getMyVideo(getToken(), id);
|
|
|
|
} else {
|
|
|
|
video = peertubeService.getVideo(id);
|
|
|
|
}
|
2020-09-25 18:58:04 +02:00
|
|
|
APIResponse apiResponse = new APIResponse();
|
|
|
|
try {
|
|
|
|
Response<VideoData.Video> response = video.execute();
|
2020-10-09 18:22:05 +02:00
|
|
|
|
2020-09-25 18:58:04 +02:00
|
|
|
if (response.isSuccessful()) {
|
|
|
|
List<VideoData.Video> videos = new ArrayList<>();
|
|
|
|
videos.add(response.body());
|
|
|
|
apiResponse.setPeertubes(videos);
|
|
|
|
} else {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setStatusCode(response.code());
|
|
|
|
if (response.errorBody() != null) {
|
2020-09-29 17:42:15 +02:00
|
|
|
error.setError(response.errorBody().string());
|
2020-09-25 18:58:04 +02:00
|
|
|
} else {
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
Error error = new Error();
|
|
|
|
error.setError(_context.getString(R.string.toast_error));
|
|
|
|
apiResponse.setError(error);
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return apiResponse;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum DataType {
|
|
|
|
SUBSCRIBER,
|
|
|
|
MUTED,
|
|
|
|
CHANNELS_FOR_ACCOUNT,
|
2020-09-26 10:22:11 +02:00
|
|
|
CHANNEL,
|
|
|
|
MY_CHANNELS
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum ActionType {
|
|
|
|
FOLLOW,
|
|
|
|
UNFOLLOW,
|
|
|
|
MUTE,
|
|
|
|
UNMUTE,
|
|
|
|
RATEVIDEO,
|
|
|
|
PEERTUBEDELETECOMMENT,
|
2020-10-13 17:50:52 +02:00
|
|
|
PEERTUBE_DELETE_ALL_COMMENT_FOR_ACCOUNT,
|
2020-09-25 18:58:04 +02:00
|
|
|
PEERTUBEDELETEVIDEO,
|
|
|
|
REPORT_VIDEO,
|
2020-09-26 10:22:11 +02:00
|
|
|
REPORT_ACCOUNT,
|
2020-10-01 17:42:03 +02:00
|
|
|
REPORT_COMMENT,
|
2020-09-26 16:46:51 +02:00
|
|
|
DELETE_CHANNEL,
|
|
|
|
ADD_COMMENT,
|
|
|
|
REPLY,
|
2020-09-25 18:58:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|