From 99a6e5107bb21a0cf2a2395a43d314a29c7971db Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 6 Jun 2025 17:25:04 -0400 Subject: [PATCH] [scrobbles] Add orgparse and start of emacs webhook --- poetry.lock | 15 ++++++++++++++- pyproject.toml | 1 + vrobbler/apps/scrobbles/urls.py | 5 +++++ vrobbler/apps/scrobbles/views.py | 28 ++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index cc5531a..8bf5f17 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2228,6 +2228,7 @@ python-versions = "*" groups = ["main"] files = [ {file = "jusText-3.0.1-py2.py3-none-any.whl", hash = "sha256:e0fb882dd7285415709f4b7466aed23d6b98b7b89404c36e8a2e730facfed02b"}, + {file = "justext-3.0.1-py2.py3-none-any.whl", hash = "sha256:0a5225c5cd7c5a124fec7bfa9a55110a73135e8b58ce784470af67d051ac9fd3"}, {file = "justext-3.0.1.tar.gz", hash = "sha256:b6ed2fb6c5d21618e2e34b2295c4edfc0bcece3bd549ed5c8ef5a8d20f0b3451"}, ] @@ -2891,6 +2892,18 @@ rsa = ["cryptography (>=3.0.0)"] signals = ["blinker (>=1.4.0)"] signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"] +[[package]] +name = "orgparse" +version = "0.4.20250520" +description = "orgparse - Emacs org-mode parser in Python" +optional = false +python-versions = ">=3.9" +groups = ["main"] +files = [ + {file = "orgparse-0.4.20250520-py3-none-any.whl", hash = "sha256:24d454432385016ae91c3518c8357a3a31fdd4cebfbb0c5926cf31247bf4c7e3"}, + {file = "orgparse-0.4.20250520.tar.gz", hash = "sha256:6472fd16ddcabb523918505c865263abfa05ac80b593e668a089cda291b1a2de"}, +] + [[package]] name = "packaging" version = "24.2" @@ -5439,4 +5452,4 @@ cffi = ["cffi (>=1.11)"] [metadata] lock-version = "2.1" python-versions = ">=3.9,<3.12" -content-hash = "17358679b06dd15b7f119307013ed578ef81dbf31c592bc2ca11d13787a81215" +content-hash = "cdd7f577fe3a4c5c8cc960e0070d93b7ddbb2a7968fab63d72bb039afaa05bbe" diff --git a/pyproject.toml b/pyproject.toml index 7c26b8f..319b93b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,7 @@ django-oauth-toolkit = "^3.0.1" meta-yt = "^0.1.9" berserk = "^0.13.2" poetry-bumpversion = "^0.3.3" +orgparse = "^0.4.20250520" [tool.poetry.group.test] optional = true diff --git a/vrobbler/apps/scrobbles/urls.py b/vrobbler/apps/scrobbles/urls.py index 1f9f5c0..d8c162e 100644 --- a/vrobbler/apps/scrobbles/urls.py +++ b/vrobbler/apps/scrobbles/urls.py @@ -36,6 +36,11 @@ urlpatterns = [ views.web_scrobbler_webhook, name="web-scrobbler-webhook", ), + path( + "webhook/emacs/", + views.emacs_webhook, + name="emacs-webhook", + ), path( "webhook/gps/", views.gps_webhook, diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index 4854ca2..be54607 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -453,6 +453,34 @@ def gps_webhook(request): return Response({"scrobble_id": scrobble.id}, status=status.HTTP_200_OK) +@csrf_exempt +@api_view(["POST"]) +def emacs_webhook(request): + try: + data_dict = json.loads(request.data) + except TypeError: + data_dict = request.data + + logger.info( + "[emacs_webhook] called", + extra={ + "post_data": data_dict, + "user_id": 1, + }, + ) + + # TODO Fix this so we have to authenticate! + user_id = 1 + if request.user.id: + user_id = request.user.id + + #scrobble = gpslogger_scrobble_location(data_dict, user_id) + + #if not scrobble: + # return Response({}, status=status.HTTP_200_OK) + + return Response({"post_data": post_data}, status=status.HTTP_200_OK) + @csrf_exempt @permission_classes([IsAuthenticated])