From 50770441c68a02c95634de64e609682718f72dd6 Mon Sep 17 00:00:00 2001 From: Kaye Ena Crayzhel Misay Date: Sat, 2 Dec 2023 00:49:15 -0700 Subject: [PATCH 1/3] attempt fix: add path for non-uuid ids in FollowerView - already confirmed on prod, just need it on main --- server/socialdistribution/urls.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/socialdistribution/urls.py b/server/socialdistribution/urls.py index 6de44ec3..515bec35 100644 --- a/server/socialdistribution/urls.py +++ b/server/socialdistribution/urls.py @@ -20,6 +20,8 @@ # additional API endpoints path(f"{SERVICE}authors//follows//", FollowView.as_view(), name="follow"), + # adding this because one of the teams doesn't use uuid, so we have to receive str + path(f"{SERVICE}authors//followers//", FollowerView.as_view(), name="follower_id"), # login and signup endpoints path(f"{SERVICE}login/", LoginView.as_view(), name="login"), From 5c1f102a88e127c0a7609ada511e28fc92a5176b Mon Sep 17 00:00:00 2001 From: Kaye Ena Crayzhel Misay Date: Sat, 2 Dec 2023 00:49:29 -0700 Subject: [PATCH 2/3] cleanup --- client/src/components/post/GitHubEventList.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/client/src/components/post/GitHubEventList.tsx b/client/src/components/post/GitHubEventList.tsx index 477b065d..c6d74353 100644 --- a/client/src/components/post/GitHubEventList.tsx +++ b/client/src/components/post/GitHubEventList.tsx @@ -105,7 +105,6 @@ const GitHubEventsList = ({ githubUrl }: { githubUrl: string }) => { const renderEventContent = (event: GitHubEvent) => { switch (event.type) { case "PushEvent": - console.log(event.payload.size); return ( <> From 00afa60aa3607588c2cccc7a91ec6f5bf733e223 Mon Sep 17 00:00:00 2001 From: Kaye Ena Crayzhel Misay Date: Sat, 2 Dec 2023 00:49:44 -0700 Subject: [PATCH 3/3] conditional slash as requested --- server/socialdistribution/utils/constants.py | 4 ++- .../utils/serializers_utils.py | 30 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/server/socialdistribution/utils/constants.py b/server/socialdistribution/utils/constants.py index 8b1d8f04..2125a9ee 100644 --- a/server/socialdistribution/utils/constants.py +++ b/server/socialdistribution/utils/constants.py @@ -13,4 +13,6 @@ "http://localhost:3000/", "https://distributed-network-37d054f03cf4.herokuapp.com/", "http://127.0.0.1:8000/" -] \ No newline at end of file +] + +TRIET = "https://fakebook-frontend-f922a5dc4574.herokuapp.com/" diff --git a/server/socialdistribution/utils/serializers_utils.py b/server/socialdistribution/utils/serializers_utils.py index 9c2651d7..18b4273f 100644 --- a/server/socialdistribution/utils/serializers_utils.py +++ b/server/socialdistribution/utils/serializers_utils.py @@ -1,26 +1,46 @@ -from .constants import SERVICE +from .constants import SERVICE, TRIET from rest_framework import serializers def build_default_author_uri(obj, request, source): uri = request.build_absolute_uri("/") author_id = obj.id if source == "author" else obj.author.id - return f"{uri}{SERVICE}authors/{author_id}" + referer = request.META.get("HTTP_REFERER") + if referer and referer.startswith(TRIET): + return f"{uri}{SERVICE}authors/{author_id}/" + else: + return f"{uri}{SERVICE}authors/{author_id}" def build_default_post_uri(obj, request): uri = request.build_absolute_uri("/") - return f"{uri}{SERVICE}authors/{obj.author.id}/posts/{obj.id}" + referer = request.META.get("HTTP_REFERER") + + if referer and referer.startswith(TRIET): + return f"{uri}{SERVICE}authors/{obj.author.id}/posts/{obj.id}/" + else: + return f"{uri}{SERVICE}authors/{obj.author.id}/posts/{obj.id}" def build_default_comment_uri(obj, request): uri = request.build_absolute_uri("/") - return f"{uri}{SERVICE}authors/{obj.post.author.id}/posts/{obj.post.id}/comments/{obj.id}" + referer = request.META.get("HTTP_REFERER") + + if referer and referer.startswith(TRIET): + return f"{uri}{SERVICE}authors/{obj.post.author.id}/posts/{obj.post.id}/comments/{obj.id}/" + else: + return f"{uri}{SERVICE}authors/{obj.post.author.id}/posts/{obj.post.id}/comments/{obj.id}" def build_default_comments_uri(obj, request): uri = request.build_absolute_uri("/") - return f"{uri}{SERVICE}authors/{obj.author.id}/posts/{obj.id}/comments" + + referer = request.META.get("HTTP_REFERER") + + if referer and referer.startswith(TRIET): + return f"{uri}{SERVICE}authors/{obj.author.id}/posts/{obj.id}/comments/" + else: + return f"{uri}{SERVICE}authors/{obj.author.id}/posts/{obj.id}/comments" def customize_like_representation(serializer_instance, instance):