diff --git a/discovery-provider/src/api/v1/users.py b/discovery-provider/src/api/v1/users.py index 8ba455f916a..77e7e6e20ba 100644 --- a/discovery-provider/src/api/v1/users.py +++ b/discovery-provider/src/api/v1/users.py @@ -29,7 +29,6 @@ success_response, verify_token_parser, ) -from src.api.v1.models.common import favorite from src.api.v1.models.support import ( supporter_response, supporter_response_full, @@ -146,19 +145,14 @@ def get(self, id): return get_single_user(user_id, current_user_id) -@full_ns.route("/handle/") +USER_HANDLE_ROUTE = "/handle/" + + +@full_ns.route(USER_HANDLE_ROUTE) class FullUserHandle(Resource): @record_metrics - @ns.doc( - id="""Get User by Handle""", - description="Gets a single user by their handle", - params={"handle": "A User handle"}, - responses={200: "Success", 400: "Bad request", 500: "Server error"}, - ) - @full_ns.expect(current_user_parser) - @full_ns.marshal_with(full_user_response) @cache(ttl_sec=5) - def get(self, handle): + def _get(self, handle): args = current_user_parser.parse_args() current_user_id = get_current_user_id(args) @@ -169,6 +163,31 @@ def get(self, handle): user = extend_user(users[0]) return success_response(user) + @full_ns.doc( + id="""Get User by Handle""", + description="Gets a single user by their handle", + params={"handle": "A User handle"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @full_ns.expect(current_user_parser) + @full_ns.marshal_with(full_user_response) + def get(self, handle): + return self._get(handle) + + +@ns.route(USER_HANDLE_ROUTE) +class UserHandle(FullUserHandle): + @ns.doc( + id="""Get User by Handle""", + description="Gets a single user by their handle", + params={"handle": "A User handle"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @ns.expect(current_user_parser) + @ns.marshal_with(user_response) + def get(self, handle): + return super()._get(handle) + USER_TRACKS_ROUTE = "//tracks" user_tracks_route_parser = pagination_with_current_user_parser.copy() @@ -271,22 +290,14 @@ def get(self, id, authed_user_id=None): return success_response(tracks) -@full_ns.route("/handle//tracks") +USER_HANDLE_TRACKS = "/handle//tracks" + + +@full_ns.route(USER_HANDLE_TRACKS) class HandleFullTrackList(Resource): @record_metrics - @full_ns.doc( - id="""Get Tracks by User Handle""", - description="""Gets the tracks created by a user using the user's handle""", - params={ - "handle": "A User handle", - }, - responses={200: "Success", 400: "Bad request", 500: "Server error"}, - ) - @full_ns.expect(user_tracks_route_parser) - @full_ns.marshal_with(full_tracks_response) - @auth_middleware() @cache(ttl_sec=5) - def get(self, handle, authed_user_id=None): + def _get(self, handle, authed_user_id=None): args = user_tracks_route_parser.parse_args() current_user_id = get_current_user_id(args) @@ -309,12 +320,46 @@ def get(self, handle, authed_user_id=None): tracks = list(map(extend_track, tracks)) return success_response(tracks) + @auth_middleware() + @full_ns.doc( + id="""Get Tracks by User Handle""", + description="""Gets the tracks created by a user using the user's handle""", + params={ + "handle": "A User handle", + }, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @full_ns.expect(user_tracks_route_parser) + @full_ns.marshal_with(full_tracks_response) + def get(self, handle, authed_user_id=None): + return self._get(handle, authed_user_id) + + +@ns.route(USER_HANDLE_TRACKS) +class HandleTrackList(HandleFullTrackList): + @auth_middleware() + @ns.doc( + id="""Get Tracks by User Handle""", + description="""Gets the tracks created by a user using the user's handle""", + params={ + "handle": "A User handle", + }, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @ns.expect(user_tracks_route_parser) + @ns.marshal_with(tracks_response) + def get(self, handle, authed_user_id): + return super()._get(handle, authed_user_id) + USER_REPOSTS_ROUTE = "//reposts" reposts_response = make_response( "reposts", ns, fields.List(fields.Nested(activity_model)) ) +full_reposts_response = make_full_response( + "full_reposts", full_ns, fields.List(fields.Nested(activity_model_full)) +) @ns.route(USER_REPOSTS_ROUTE) @@ -354,11 +399,6 @@ def get(self, id): return success_response(activities) -full_reposts_response = make_full_response( - "full_reposts", full_ns, fields.List(fields.Nested(activity_model_full)) -) - - @full_ns.route(USER_REPOSTS_ROUTE) class FullRepostList(Resource): @record_metrics @@ -400,21 +440,14 @@ def get(self, id): return success_response(activities) -@full_ns.route("/handle//reposts") +REPOST_LIST_ROUTE = "/handle//reposts" + + +@full_ns.route(REPOST_LIST_ROUTE) class HandleFullRepostList(Resource): @record_metrics - @full_ns.doc( - id="""Get Reposts by Handle""", - description="""Gets the user's reposts by the user handle""", - params={ - "handle": "A User handle", - }, - responses={200: "Success", 400: "Bad request", 500: "Server error"}, - ) - @full_ns.expect(pagination_with_current_user_parser) - @full_ns.marshal_with(full_reposts_response) @cache(ttl_sec=5) - def get(self, handle): + def _get(self, handle): args = pagination_with_current_user_parser.parse_args() current_user_id = get_current_user_id(args) @@ -439,28 +472,34 @@ def get(self, handle): return success_response(activities) - -favorites_response = make_response( - "favorites_response", ns, fields.List(fields.Nested(favorite)) -) + @full_ns.doc( + id="""Get Reposts by Handle""", + description="""Gets the user's reposts by the user handle""", + params={ + "handle": "A User handle", + }, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @full_ns.expect(pagination_with_current_user_parser) + @full_ns.marshal_with(full_reposts_response) + def get(self, handle): + return self._get(handle) -@ns.route("//favorites") -class FavoritedTracks(Resource): - @record_metrics +@ns.route(REPOST_LIST_ROUTE) +class HandleRepostList(HandleFullRepostList): @ns.doc( - id="""Get Favorites""", - description="""Gets a user's favorite tracks""", - params={"id": "A User ID"}, + id="""Get Reposts by Handle""", + description="""Gets the user's reposts by the user handle""", + params={ + "handle": "A User handle", + }, responses={200: "Success", 400: "Bad request", 500: "Server error"}, ) - @ns.marshal_with(favorites_response) - @cache(ttl_sec=5) - def get(self, id): - decoded_id = decode_with_abort(id, ns) - favorites = get_saves("tracks", decoded_id) - favorites = list(map(extend_favorite, favorites)) - return success_response(favorites) + @ns.expect(pagination_with_current_user_parser) + @ns.marshal_with(reposts_response) + def get(self, handle): + return super()._get(handle) tags_route_parser = pagination_with_current_user_parser.copy() @@ -489,24 +528,41 @@ def get(self, id): return success_response(tags) -favorites_response = make_full_response( +favorites_response = make_response( + "favorites_response", ns, fields.List(fields.Nested(activity_model)) +) +favorites_full_response = make_full_response( "favorites_response_full", full_ns, fields.List(fields.Nested(activity_model_full)) ) -@full_ns.route("//favorites/tracks") -class FavoritedTracksFull(Resource): +# different route from //favorites/tracks +@ns.route("//favorites") +class FavoritedTracks(Resource): @record_metrics - @full_ns.doc( + @ns.doc( id="""Get Favorites""", description="""Gets a user's favorite tracks""", params={"id": "A User ID"}, responses={200: "Success", 400: "Bad request", 500: "Server error"}, ) - @full_ns.expect(pagination_with_current_user_parser) - @full_ns.marshal_with(favorites_response) + @ns.marshal_with(favorites_response) @cache(ttl_sec=5) def get(self, id): + decoded_id = decode_with_abort(id, ns) + favorites = get_saves("tracks", decoded_id) + favorites = list(map(extend_favorite, favorites)) + return success_response(favorites) + + +USER_FAVORITED_TRACKS_ROUTE = "//favorites/tracks" + + +@full_ns.route(USER_FAVORITED_TRACKS_ROUTE) +class UserFavoritedTracksFull(Resource): + @record_metrics + @cache(ttl_sec=5) + def _get(self, id): """Fetch favorited tracks for a user.""" args = pagination_with_current_user_parser.parse_args() decoded_id = decode_with_abort(id, ns) @@ -526,25 +582,33 @@ def get(self, id): tracks = list(map(extend_activity, track_saves)) return success_response(tracks) + @full_ns.doc( + id="""Get Favorites""", + description="""Gets a user's favorite tracks""", + params={"id": "A User ID"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @full_ns.expect(pagination_with_current_user_parser) + @full_ns.marshal_with(favorites_full_response) + def get(self, id): + return self._get(id) + history_response = make_full_response( + "history_response", ns, fields.List(fields.Nested(activity_model)) +) +history_response_full = make_full_response( "history_response_full", full_ns, fields.List(fields.Nested(activity_model_full)) ) +USER_HISTORY_TRACKS_ROUTE = "//history/tracks" -@full_ns.route("//history/tracks") + +@full_ns.route(USER_HISTORY_TRACKS_ROUTE) class TrackHistoryFull(Resource): @record_metrics - @full_ns.doc( - id="""Get User's Track History""", - description="""Get the tracks the user recently listened to.""", - params={"id": "A User ID"}, - responses={200: "Success", 400: "Bad request", 500: "Server error"}, - ) - @full_ns.expect(pagination_with_current_user_parser) - @full_ns.marshal_with(history_response) @cache(ttl_sec=5) - def get(self, id): + def _get(self, id): args = pagination_with_current_user_parser.parse_args() decoded_id = decode_with_abort(id, ns) current_user_id = get_current_user_id(args) @@ -560,6 +624,31 @@ def get(self, id): tracks = list(map(extend_activity, track_history)) return success_response(tracks) + @full_ns.doc( + id="""Get User's Track History""", + description="""Get the tracks the user recently listened to.""", + params={"id": "A User ID"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @full_ns.expect(pagination_with_current_user_parser) + @full_ns.marshal_with(history_response_full) + def get(self, id): + return self._get(id) + + +@ns.route(USER_HISTORY_TRACKS_ROUTE) +class TrackHistory(TrackHistoryFull): + @ns.doc( + id="""Get User's Track History""", + description="""Get the tracks the user recently listened to.""", + params={"id": "A User ID"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @ns.expect(pagination_with_current_user_parser) + @ns.marshal_with(history_response) + def get(self, id): + return super()._get(id) + user_search_result = make_response( "user_search", ns, fields.List(fields.Nested(user_model)) @@ -596,23 +685,20 @@ def get(self): followers_response = make_full_response( - "followers_response", full_ns, fields.List(fields.Nested(user_model_full)) + "followers_response", ns, fields.List(fields.Nested(user_model)) +) +full_followers_response = make_full_response( + "full_followers_response", full_ns, fields.List(fields.Nested(user_model_full)) ) +USER_FOLLOWERS_ROUTE = "//followers" + -@full_ns.route("//followers") -class FollowerUsers(Resource): +@full_ns.route(USER_FOLLOWERS_ROUTE) +class FullFollowerUsers(Resource): @record_metrics - @ns.doc( - id="""Get Followers""", - description="""All users that follow the provided user""", - params={"id": "A User ID"}, - responses={200: "Success", 400: "Bad request", 500: "Server error"}, - ) - @ns.expect(pagination_with_current_user_parser) - @full_ns.marshal_with(followers_response) @cache(ttl_sec=5) - def get(self, id): + def _get(self, id): decoded_id = decode_with_abort(id, full_ns) args = pagination_with_current_user_parser.parse_args() limit = get_default_max(args.get("limit"), 10, 100) @@ -628,25 +714,47 @@ def get(self, id): users = list(map(extend_user, users)) return success_response(users) + @full_ns.doc( + id="""Get Followers""", + description="""All users that follow the provided user""", + params={"id": "A User ID"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @full_ns.expect(pagination_with_current_user_parser) + @full_ns.marshal_with(full_followers_response) + def get(self, id): + return self._get(id) + + +@ns.route(USER_FOLLOWERS_ROUTE) +class FollowerUsers(FullFollowerUsers): + @ns.doc( + id="""Get Followers""", + description="""All users that follow the provided user""", + params={"id": "A User ID"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @ns.expect(pagination_with_current_user_parser) + @ns.marshal_with(followers_response) + def get(self, id): + return super()._get(id) + following_response = make_full_response( - "following_response", full_ns, fields.List(fields.Nested(user_model_full)) + "following_response", ns, fields.List(fields.Nested(user_model)) +) +following_response_full = make_full_response( + "following_response_full", full_ns, fields.List(fields.Nested(user_model_full)) ) +FOLLOWING_USERS_ROUTE = "//following" -@full_ns.route("//following") -class FollowingUsers(Resource): + +@full_ns.route(FOLLOWING_USERS_ROUTE) +class FullFollowingUsers(Resource): @record_metrics - @full_ns.doc( - id="""Get Followings""", - description="""All users that the provided user follows""", - params={"id": "A User ID"}, - responses={200: "Success", 400: "Bad request", 500: "Server error"}, - ) - @full_ns.expect(pagination_with_current_user_parser) - @full_ns.marshal_with(following_response) @cache(ttl_sec=5) - def get(self, id): + def _get(self, id): decoded_id = decode_with_abort(id, full_ns) args = pagination_with_current_user_parser.parse_args() limit = get_default_max(args.get("limit"), 10, 100) @@ -662,27 +770,49 @@ def get(self, id): users = list(map(extend_user, users)) return success_response(users) + @full_ns.doc( + id="""Get Followings""", + description="""All users that the provided user follows""", + params={"id": "A User ID"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @full_ns.expect(pagination_with_current_user_parser) + @full_ns.marshal_with(following_response_full) + def get(self, id): + return self._get(id) + + +@ns.route(FOLLOWING_USERS_ROUTE) +class FollowingUsers(FullFollowingUsers): + @ns.doc( + id="""Get Followings""", + description="""All users that the provided user follows""", + params={"id": "A User ID"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @ns.expect(pagination_with_current_user_parser) + @ns.marshal_with(following_response) + def get(self, id): + return super()._get(id) + related_artist_route_parser = pagination_with_current_user_parser.copy() related_artist_route_parser.remove_argument("offset") -related_artist_response = make_full_response( - "related_artist_response", full_ns, fields.List(fields.Nested(user_model_full)) +related_artist_response = make_response( + "related_artist_response", ns, fields.List(fields.Nested(user_model)) +) +related_artist_response_full = make_full_response( + "related_artist_response_full", full_ns, fields.List(fields.Nested(user_model_full)) ) +USER_RELATED_ROUTE = "//related" + -@full_ns.route("//related") -class RelatedUsers(Resource): +@full_ns.route(USER_RELATED_ROUTE) +class FullRelatedUsers(Resource): @record_metrics - @full_ns.doc( - id="""Get Related Users""", - description="""Gets a list of users that might be of interest to followers of this user.""", - params={"id": "A User ID"}, - responses={200: "Success", 400: "Bad request", 500: "Server error"}, - ) - @full_ns.expect(related_artist_route_parser) - @full_ns.marshal_with(related_artist_response) @cache(ttl_sec=5) - def get(self, id): + def _get(self, id): args = related_artist_route_parser.parse_args() limit = get_default_max(args.get("limit"), 10, 100) current_user_id = get_current_user_id(args) @@ -691,27 +821,52 @@ def get(self, id): users = list(map(extend_user, users)) return success_response(users) + @full_ns.doc( + id="""Get Related Users""", + description="""Gets a list of users that might be of interest to followers of this user.""", + params={"id": "A User ID"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @full_ns.expect(related_artist_route_parser) + @full_ns.marshal_with(related_artist_response_full) + def get(self, id): + return self._get(id) + + +@ns.route(USER_RELATED_ROUTE) +class RelatedUsers(FullRelatedUsers): + @ns.doc( + id="""Get Related Users""", + description="""Gets a list of users that might be of interest to followers of this user.""", + params={"id": "A User ID"}, + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @ns.expect(related_artist_route_parser) + @ns.marshal_with(related_artist_response) + def get(self, id): + return super()._get(id) + top_genre_users_route_parser = pagination_parser.copy() top_genre_users_route_parser.add_argument( "genre", required=False, action="append", description="List of Genres" ) -top_genre_users_response = make_full_response( - "top_genre_users_response", full_ns, fields.List(fields.Nested(user_model_full)) +top_genre_users_response = make_response( + "top_genre_users_response", ns, fields.List(fields.Nested(user_model)) +) +top_genre_users_response_full = make_full_response( + "top_genre_users_response_full", + full_ns, + fields.List(fields.Nested(user_model_full)), ) +TOP_GENRE_ROUTE = "/genre/top" -@full_ns.route("/genre/top") + +@full_ns.route(TOP_GENRE_ROUTE) class FullTopGenreUsers(Resource): - @full_ns.doc( - id="""Get Top Users In Genre""", - description="""Get the Top Users for a Given Genre""", - responses={200: "Success", 400: "Bad request", 500: "Server error"}, - ) - @full_ns.expect(top_genre_users_route_parser) - @full_ns.marshal_with(top_genre_users_response) @cache(ttl_sec=60 * 60 * 24) - def get(self): + def _get(self): args = top_genre_users_route_parser.parse_args() limit = get_default_max(args.get("limit"), 10, 100) offset = get_default_max(args.get("offset"), 0) @@ -727,29 +882,73 @@ def get(self): users = list(map(extend_user, top_users["users"])) return success_response(users) + @full_ns.doc( + id="""Get Top Users In Genre""", + description="""Get the Top Users for a Given Genre""", + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @full_ns.expect(top_genre_users_route_parser) + @full_ns.marshal_with(top_genre_users_response_full) + def get(self): + return self._get() + + +@ns.route(TOP_GENRE_ROUTE) +class TopGenreUsers(FullTopGenreUsers): + @ns.doc( + id="""Get Top Users In Genre""", + description="""Get the Top Users for a Given Genre""", + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @ns.expect(top_genre_users_route_parser) + @ns.marshal_with(top_genre_users_response) + def get(self): + return super()._get() + -top_users_response = make_full_response( - "top_users_response", full_ns, fields.List(fields.Nested(user_model_full)) +top_users_response = make_response( + "top_users_response", ns, fields.List(fields.Nested(user_model)) +) +top_users_response_full = make_full_response( + "top_users_response_full", full_ns, fields.List(fields.Nested(user_model_full)) ) +TOP_ROUTE = "/top" -@full_ns.route("/top") + +@full_ns.route(TOP_ROUTE) class FullTopUsers(Resource): + @cache(ttl_sec=60 * 60 * 24) + def _get(self): + args = pagination_with_current_user_parser.parse_args() + current_user_id = get_current_user_id(args) + + top_users = get_top_users(current_user_id) + users = list(map(extend_user, top_users)) + return success_response(users) + @full_ns.doc( id="""Get Top Users""", description="""Get the Top Users having at least one track by follower count""", responses={200: "Success", 400: "Bad request", 500: "Server error"}, ) @full_ns.expect(pagination_with_current_user_parser) - @full_ns.marshal_with(top_users_response) - @cache(ttl_sec=60 * 60 * 24) + @full_ns.marshal_with(top_users_response_full) def get(self): - args = pagination_with_current_user_parser.parse_args() - current_user_id = get_current_user_id(args) + return self._get() - top_users = get_top_users(current_user_id) - users = list(map(extend_user, top_users)) - return success_response(users) + +@ns.route(TOP_ROUTE) +class TopUsers(FullTopUsers): + @ns.doc( + id="""Get Top Users""", + description="""Get the Top Users having at least one track by follower count""", + responses={200: "Success", 400: "Bad request", 500: "Server error"}, + ) + @ns.expect(pagination_with_current_user_parser) + @ns.marshal_with(top_users_response) + def get(self): + return super()._get() associated_wallet_route_parser = reqparse.RequestParser( @@ -945,8 +1144,10 @@ def get(self, id: str): "get_supporters", ns, fields.List(fields.Nested(supporter_response)) ) +USER_SUPPORTERS_ROUTE = "//supporters" + -@ns.route("//supporters") +@ns.route(USER_SUPPORTERS_ROUTE) class GetSupporters(Resource): @record_metrics @ns.doc( @@ -971,7 +1172,7 @@ def get(self, id: str): ) -@full_ns.route("//supporters") +@full_ns.route(USER_SUPPORTERS_ROUTE) class FullGetSupporters(Resource): @record_metrics @full_ns.doc( @@ -993,23 +1194,22 @@ def get(self, id: str): return success_response(support) +get_supporter_response = make_response( + "get_supporter", ns, fields.Nested(supporter_response) +) full_get_supporter_response = make_full_response( "full_get_supporter", full_ns, fields.Nested(supporter_response_full) ) -@full_ns.route("//supporters/") +SUPPORTER_USER_ROUTE = "//supporters/" + + +@full_ns.route(SUPPORTER_USER_ROUTE) class FullGetSupporter(Resource): @record_metrics - @full_ns.doc( - id="""Get Supporter""", - description="""Gets the specified supporter of the given user""", - params={"id": "A User ID", "supporter_user_id": "A User ID of a supporter"}, - ) - @full_ns.expect(current_user_parser) - @full_ns.marshal_with(full_get_supporter_response) @cache(ttl_sec=5) - def get(self, id: str, supporter_user_id: str): + def _get(self, id: str, supporter_user_id: str): args = current_user_parser.parse_args() decoded_id = decode_with_abort(id, full_ns) current_user_id = get_current_user_id(args) @@ -1023,13 +1223,38 @@ def get(self, id: str, supporter_user_id: str): abort_not_found(supporter_user_id, full_ns) return success_response(support[0]) + @full_ns.doc( + id="""Get Supporter""", + description="""Gets the specified supporter of the given user""", + params={"id": "A User ID", "supporter_user_id": "A User ID of a supporter"}, + ) + @full_ns.expect(current_user_parser) + @full_ns.marshal_with(full_get_supporter_response) + def get(self, id: str, supporter_user_id: str): + return self._get(id, supporter_user_id) + + +@ns.route(SUPPORTER_USER_ROUTE) +class GetSupporter(FullGetSupporter): + @ns.doc( + id="""Get Supporter""", + description="""Gets the specified supporter of the given user""", + params={"id": "A User ID", "supporter_user_id": "A User ID of a supporter"}, + ) + @ns.expect(current_user_parser) + @ns.marshal_with(get_supporter_response) + def get(self, id: str, supporter_user_id: str): + return super()._get(id, supporter_user_id) + get_supporting_response = make_response( "get_supporting", ns, fields.List(fields.Nested(supporting_response)) ) +USER_SUPPORTINGS_ROUTE = "//supporting" + -@ns.route("//supporting") +@ns.route(USER_SUPPORTINGS_ROUTE) class GetSupportings(Resource): @record_metrics @ns.doc( @@ -1053,8 +1278,12 @@ def get(self, id: str): "full_get_supporting", full_ns, fields.List(fields.Nested(supporting_response_full)) ) +full_get_supporting_response = make_full_response( + "full_get_supporting", full_ns, fields.List(fields.Nested(supporting_response_full)) +) + -@full_ns.route("//supporting") +@full_ns.route(USER_SUPPORTINGS_ROUTE) class FullGetSupportings(Resource): @record_metrics @full_ns.doc( @@ -1080,22 +1309,14 @@ def get(self, id: str): "full_get_supporting", full_ns, fields.Nested(supporting_response_full) ) +GET_SUPPORTING_ROUTE = "//supporting/" -@full_ns.route("//supporting/") + +@full_ns.route(GET_SUPPORTING_ROUTE) class FullGetSupporting(Resource): @record_metrics - @full_ns.doc( - id="""Get Supporting""", - description="""Gets the support from the given user to the supported user""", - params={ - "id": "A User ID", - "supported_user_id": "A User ID of a supported user", - }, - ) - @full_ns.expect(current_user_parser) - @full_ns.marshal_with(full_get_supporting_response) @cache(ttl_sec=5) - def get(self, id: str, supported_user_id: str): + def _get(self, id: str, supported_user_id: str): args = current_user_parser.parse_args() decoded_id = decode_with_abort(id, full_ns) current_user_id = get_current_user_id(args) @@ -1109,6 +1330,35 @@ def get(self, id: str, supported_user_id: str): abort_not_found(decoded_id, full_ns) return success_response(support[0]) + @full_ns.doc( + id="""Get Supporting""", + description="""Gets the support from the given user to the supported user""", + params={ + "id": "A User ID", + "supported_user_id": "A User ID of a supported user", + }, + ) + @full_ns.expect(current_user_parser) + @full_ns.marshal_with(full_get_supporting_response) + def get(self, id: str, supported_user_id: str): + return self._get(id, supported_user_id) + + +@ns.route(GET_SUPPORTING_ROUTE) +class GetSupporting(FullGetSupporting): + @ns.doc( + id="""Get Supporting""", + description="""Gets the support from the given user to the supported user""", + params={ + "id": "A User ID", + "supported_user_id": "A User ID of a supported user", + }, + ) + @ns.expect(current_user_parser) + @ns.marshal_with(get_supporting_response) + def get(self, id: str, supported_user_id: str): + return super()._get(id, supported_user_id) + verify_token_response = make_response( "verify_token", ns, fields.Nested(decoded_user_token) @@ -1119,7 +1369,7 @@ def get(self, id: str, supported_user_id: str): class GetTokenVerification(Resource): @record_metrics @ns.doc( - id="""Verify ID token""", + id="""Verify ID Token""", description="""Verify if the given jwt ID token was signed by the subject (user) in the payload""", responses={ 200: "Success",