add notification api endpoint
This commit is contained in:
parent
20f8a5a501
commit
259008df50
|
@ -8,6 +8,7 @@ from api.views import (
|
||||||
DownloadApiListView,
|
DownloadApiListView,
|
||||||
DownloadApiView,
|
DownloadApiView,
|
||||||
LoginApiView,
|
LoginApiView,
|
||||||
|
NotificationView,
|
||||||
PingView,
|
PingView,
|
||||||
PlaylistApiListView,
|
PlaylistApiListView,
|
||||||
PlaylistApiVideoView,
|
PlaylistApiVideoView,
|
||||||
|
@ -135,4 +136,9 @@ urlpatterns = [
|
||||||
SearchView.as_view(),
|
SearchView.as_view(),
|
||||||
name="api-search",
|
name="api-search",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"notification/",
|
||||||
|
NotificationView.as_view(),
|
||||||
|
name="api-notification",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -761,3 +761,21 @@ class SearchView(ApiBaseView):
|
||||||
|
|
||||||
search_results = SearchForm().multi_search(search_query)
|
search_results = SearchForm().multi_search(search_query)
|
||||||
return Response(search_results)
|
return Response(search_results)
|
||||||
|
|
||||||
|
|
||||||
|
class NotificationView(ApiBaseView):
|
||||||
|
"""resolves to /api/notification/
|
||||||
|
GET: returns a list of notifications
|
||||||
|
filter query to filter messages by group
|
||||||
|
"""
|
||||||
|
|
||||||
|
valid_filters = ["download", "settings", "channel"]
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
"""get all notifications"""
|
||||||
|
query = "message"
|
||||||
|
filter_by = request.GET.get("filter", None)
|
||||||
|
if filter_by in self.valid_filters:
|
||||||
|
query = f"{query}:{filter_by}"
|
||||||
|
|
||||||
|
return Response(RedisArchivist().list_items(query))
|
||||||
|
|
Loading…
Reference in New Issue