Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add url check api for checking for duplicate urls #1097

Merged
merged 4 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion blt/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
LikeIssueApiView,
FlagIssueApiView,
LeaderboardApiViewSet,
StatsApiViewset
StatsApiViewset,
UrlCheckApiViewset
)

from blt import settings
Expand Down Expand Up @@ -353,6 +354,7 @@
re_path(r"^domain_check/$", website.views.domain_check, name="domain_check"),
re_path(r"^api/v1/", include(router.urls)),
re_path(r"^api/v1/stats/$", StatsApiViewset.as_view(), name="get_score"),
re_path(r"^api/v1/urlcheck/$", UrlCheckApiViewset.as_view(), name="url_check"),
re_path(r"^api/v1/userscore/$", website.views.get_score, name="get_score"),
re_path(r"^authenticate/", CustomObtainAuthToken.as_view()),
re_path(r"^api/v1/createwallet/$", website.views.create_wallet, name="create_wallet"),
Expand Down
14 changes: 14 additions & 0 deletions website/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,17 @@ def get(self,request,*args,**kwargs):
"hunts":hunt_count,
"domains":domain_count
})

class UrlCheckApiViewset(APIView):
def post(self, request, *args, **kwargs):
domain_url = request.data["dom_url"]
if "http://" not in domain_url and "https://" not in domain_url:
domain_url = "http://" + domain_url

if Issue.objects.filter(url=domain_url).exists():
matches = Issue.objects.filter(url=domain_url)
data = IssueSerializer(matches[0]).data
return Response({"found": True, "issue": data})

else:
return Response({"found": False})