mirror of
				https://framagit.org/tom79/fedilab-tube
				synced 2025-06-05 21:09:11 +02:00 
			
		
		
		
	Don't use token when not necessary
This commit is contained in:
		| @@ -1253,7 +1253,7 @@ public class PeertubeAPI { | |||||||
|      */ |      */ | ||||||
|     public APIResponse getSubscriptionsTL(String max_id) { |     public APIResponse getSubscriptionsTL(String max_id) { | ||||||
|         try { |         try { | ||||||
|             return getTL("/users/me/subscriptions/videos", "-publishedAt", null, max_id, null, null); |             return getTL(true, "/users/me/subscriptions/videos", "-publishedAt", null, max_id, null, null); | ||||||
|         } catch (HttpsConnection.HttpsConnectionException e) { |         } catch (HttpsConnection.HttpsConnectionException e) { | ||||||
|             setError(e.getStatusCode(), e); |             setError(e.getStatusCode(), e); | ||||||
|             return apiResponse; |             return apiResponse; | ||||||
| @@ -1322,7 +1322,7 @@ public class PeertubeAPI { | |||||||
|      */ |      */ | ||||||
|     public APIResponse getOverviewTL(String max_id) { |     public APIResponse getOverviewTL(String max_id) { | ||||||
|         try { |         try { | ||||||
|             return getTL("/overviews/videos", null, null, max_id, null, null); |             return getTL(false, "/overviews/videos", null, null, max_id, null, null); | ||||||
|         } catch (HttpsConnection.HttpsConnectionException e) { |         } catch (HttpsConnection.HttpsConnectionException e) { | ||||||
|             setError(e.getStatusCode(), e); |             setError(e.getStatusCode(), e); | ||||||
|             return apiResponse; |             return apiResponse; | ||||||
| @@ -1337,7 +1337,7 @@ public class PeertubeAPI { | |||||||
|      */ |      */ | ||||||
|     public APIResponse getLikedTL(String max_id) { |     public APIResponse getLikedTL(String max_id) { | ||||||
|         try { |         try { | ||||||
|             return getTL("/videos/", "-likes", null, max_id, null, null); |             return getTL(false, "/videos/", "-likes", null, max_id, null, null); | ||||||
|         } catch (HttpsConnection.HttpsConnectionException e) { |         } catch (HttpsConnection.HttpsConnectionException e) { | ||||||
|             setError(e.getStatusCode(), e); |             setError(e.getStatusCode(), e); | ||||||
|             return apiResponse; |             return apiResponse; | ||||||
| @@ -1352,7 +1352,7 @@ public class PeertubeAPI { | |||||||
|      */ |      */ | ||||||
|     public APIResponse getTrendingTL(String max_id) { |     public APIResponse getTrendingTL(String max_id) { | ||||||
|         try { |         try { | ||||||
|             return getTL("/videos/", "-trending", null, max_id, null, null); |             return getTL(false, "/videos/", "-trending", null, max_id, null, null); | ||||||
|         } catch (HttpsConnection.HttpsConnectionException e) { |         } catch (HttpsConnection.HttpsConnectionException e) { | ||||||
|             setError(e.getStatusCode(), e); |             setError(e.getStatusCode(), e); | ||||||
|             return apiResponse; |             return apiResponse; | ||||||
| @@ -1367,7 +1367,7 @@ public class PeertubeAPI { | |||||||
|      */ |      */ | ||||||
|     public APIResponse getRecentlyAddedTL(String max_id) { |     public APIResponse getRecentlyAddedTL(String max_id) { | ||||||
|         try { |         try { | ||||||
|             return getTL("/videos/", "-publishedAt", null, max_id, null, null); |             return getTL(false, "/videos/", "-publishedAt", null, max_id, null, null); | ||||||
|         } catch (HttpsConnection.HttpsConnectionException e) { |         } catch (HttpsConnection.HttpsConnectionException e) { | ||||||
|             setError(e.getStatusCode(), e); |             setError(e.getStatusCode(), e); | ||||||
|             return apiResponse; |             return apiResponse; | ||||||
| @@ -1382,7 +1382,7 @@ public class PeertubeAPI { | |||||||
|      */ |      */ | ||||||
|     public APIResponse getLocalTL(String max_id) { |     public APIResponse getLocalTL(String max_id) { | ||||||
|         try { |         try { | ||||||
|             return getTL("/videos/", "-publishedAt", "local", max_id, null, null); |             return getTL(true, "/videos/", "-publishedAt", "local", max_id, null, null); | ||||||
|         } catch (HttpsConnection.HttpsConnectionException e) { |         } catch (HttpsConnection.HttpsConnectionException e) { | ||||||
|             setError(e.getStatusCode(), e); |             setError(e.getStatusCode(), e); | ||||||
|             return apiResponse; |             return apiResponse; | ||||||
| @@ -1397,7 +1397,7 @@ public class PeertubeAPI { | |||||||
|      */ |      */ | ||||||
|     public APIResponse getPublicTL(String max_id) { |     public APIResponse getPublicTL(String max_id) { | ||||||
|         try { |         try { | ||||||
|             return getTL("/videos/", "-publishedAt", null, max_id, null, null); |             return getTL(false, "/videos/", "-publishedAt", null, max_id, null, null); | ||||||
|         } catch (HttpsConnection.HttpsConnectionException e) { |         } catch (HttpsConnection.HttpsConnectionException e) { | ||||||
|             setError(e.getStatusCode(), e); |             setError(e.getStatusCode(), e); | ||||||
|             return apiResponse; |             return apiResponse; | ||||||
| @@ -1412,7 +1412,7 @@ public class PeertubeAPI { | |||||||
|      * @return APIResponse |      * @return APIResponse | ||||||
|      */ |      */ | ||||||
|     @SuppressWarnings("SameParameterValue") |     @SuppressWarnings("SameParameterValue") | ||||||
|     private APIResponse getTL(String action, String sort, String filter, String max_id, String since_id, String min_id) throws HttpsConnection.HttpsConnectionException { |     private APIResponse getTL(boolean needToken, String action, String sort, String filter, String max_id, String since_id, String min_id) throws HttpsConnection.HttpsConnectionException { | ||||||
|  |  | ||||||
|         HashMap<String, String> params = new HashMap<>(); |         HashMap<String, String> params = new HashMap<>(); | ||||||
|         if (max_id != null) |         if (max_id != null) | ||||||
| @@ -1434,7 +1434,7 @@ public class PeertubeAPI { | |||||||
|         List<Peertube> peertubes = new ArrayList<>(); |         List<Peertube> peertubes = new ArrayList<>(); | ||||||
|         try { |         try { | ||||||
|             HttpsConnection httpsConnection = new HttpsConnection(context); |             HttpsConnection httpsConnection = new HttpsConnection(context); | ||||||
|             String response = httpsConnection.get(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT); |             String response = httpsConnection.get(getAbsoluteUrl(action), 60, params, needToken ? prefKeyOauthTokenT : null); | ||||||
|             if (!action.equals("/overviews/videos")) { |             if (!action.equals("/overviews/videos")) { | ||||||
|                 JSONArray values = new JSONObject(response).getJSONArray("data"); |                 JSONArray values = new JSONObject(response).getJSONArray("data"); | ||||||
|                 peertubes = parsePeertube(values); |                 peertubes = parsePeertube(values); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user