Skip to content

Commit

Permalink
Add url check api for checking for duplicate urls (#1097)
Browse files Browse the repository at this point in the history
* Add url check api for checking for duplicate urls

* remove redundancy
  • Loading branch information
letsintegreat committed Mar 4, 2023
1 parent 4ab5e5d commit 18380cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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})

0 comments on commit 18380cf

Please sign in to comment.