From 3353b7205b8ebdefc1e6d409a970b24bd7dbd37c Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 22 Oct 2020 08:57:51 +0200 Subject: [PATCH] Fix issue #10 --- .../fedilabtube/client/PeertubeService.java | 14 +++++++------- .../client/RetrofitPeertubeAPI.java | 18 +++++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeService.java b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeService.java index da6ae82..c4eaac3 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeService.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/PeertubeService.java @@ -121,23 +121,23 @@ public interface PeertubeService { //Overview videos @GET("overviews/videos") - Call getOverviewVideos(@Query("page") String page, @Query("languageOneOf") List languageOneOf); + Call getOverviewVideos(@Header("Authorization") String credentials, @Query("page") String page, @Query("languageOneOf") List languageOneOf); //Most liked videos @GET("videos?sort=-likes") - Call getMostLikedVideos(@Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List languageOneOf); + Call getMostLikedVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List languageOneOf); - //Most liked videos + //Trending videos @GET("videos?sort=-trending") - Call getTrendingVideos(@Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List languageOneOf); + Call getTrendingVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List languageOneOf); //Recently added videos @GET("videos?sort=-publishedAt") - Call getRecentlyAddedVideos(@Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List languageOneOf); + Call getRecentlyAddedVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List languageOneOf); //Local videos @GET("videos?sort=-publishedAt&filter=local") - Call getLocalVideos(@Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List languageOneOf); + Call getLocalVideos(@Header("Authorization") String credentials, @Query("start") String maxId, @Query("count") String count, @Query("languageOneOf") List languageOneOf); //History @GET("users/me/history/videos") @@ -145,7 +145,7 @@ public interface PeertubeService { //Search @GET("search/videos") - Call searchVideos(@Query("search") String search, @Query("start") String maxId, @Query("count") String count); + Call searchVideos(@Header("Authorization") String credentials, @Query("search") String search, @Query("start") String maxId, @Query("count") String count); //Get notifications @GET("users/me/notifications") diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/RetrofitPeertubeAPI.java b/app/src/main/java/app/fedilab/fedilabtube/client/RetrofitPeertubeAPI.java index d404849..d6be7c0 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/RetrofitPeertubeAPI.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/RetrofitPeertubeAPI.java @@ -161,7 +161,11 @@ public class RetrofitPeertubeAPI { } private String getToken() { - return "Bearer " + token; + if( token != null) { + return "Bearer " + token; + }else{ + return null; + } } private PeertubeService init() { @@ -331,19 +335,19 @@ public class RetrofitPeertubeAPI { } break; case MOST_LIKED: - videoCall = peertubeService.getMostLikedVideos(max_id, count, filter); + videoCall = peertubeService.getMostLikedVideos(getToken(), max_id, count, filter); break; case LOCAL: - videoCall = peertubeService.getLocalVideos(max_id, count, filter); + videoCall = peertubeService.getLocalVideos(getToken(), max_id, count, filter); break; case TRENDING: - videoCall = peertubeService.getTrendingVideos(max_id, count, filter); + videoCall = peertubeService.getTrendingVideos(getToken(), max_id, count, filter); break; case HISTORY: videoCall = peertubeService.getHistory(getToken(), max_id, count); break; case RECENT: - videoCall = peertubeService.getRecentlyAddedVideos(max_id, count, filter); + videoCall = peertubeService.getRecentlyAddedVideos(getToken(), max_id, count, filter); break; } if (videoCall != null) { @@ -374,7 +378,7 @@ public class RetrofitPeertubeAPI { APIResponse apiResponse = new APIResponse(); PeertubeService peertubeService = init(); ArrayList filter = selection != null ? new ArrayList<>(selection) : null; - Call overviewVideoCall = peertubeService.getOverviewVideos(page, filter); + Call overviewVideoCall = peertubeService.getOverviewVideos(getToken(), page, filter); try { Response response = overviewVideoCall.execute(); if (response.isSuccessful() && response.body() != null) { @@ -647,7 +651,7 @@ public class RetrofitPeertubeAPI { */ public APIResponse searchPeertube(String query, String max_id) { PeertubeService peertubeService = init(); - Call searchVideosCall = peertubeService.searchVideos(query, max_id, count); + Call searchVideosCall = peertubeService.searchVideos(getToken(), query, max_id, count); APIResponse apiResponse = new APIResponse(); try { Response response = searchVideosCall.execute();