Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp-notification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp-notification
Commits
26b23fd3
Commit
26b23fd3
authored
3 years ago
by
Calum Mackervoy
Browse files
Options
Downloads
Patches
Plain Diff
feature: filters are applied to local inboxes
parent
fd5b9f5f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!47
feature: serialization of notifications into objects and their filtering
Pipeline
#11956
passed
3 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
djangoldp_notification/models.py
+14
-6
14 additions, 6 deletions
djangoldp_notification/models.py
djangoldp_notification/views.py
+8
-7
8 additions, 7 deletions
djangoldp_notification/views.py
with
22 additions
and
13 deletions
djangoldp_notification/models.py
+
14
−
6
View file @
26b23fd3
...
@@ -225,18 +225,26 @@ def send_request(target, object_iri, instance, created, serialize_object=False):
...
@@ -225,18 +225,26 @@ def send_request(target, object_iri, instance, created, serialize_object=False):
else
:
else
:
request_type
=
"
deletion
"
request_type
=
"
deletion
"
json
=
{
"
@context
"
:
settings
.
LDP_RDF_CONTEXT
,
"
object
"
:
object_iri
if
not
serialize_object
else
serialize_instance
(),
"
author
"
:
author
,
"
type
"
:
request_type
}
# local inbox
# local inbox
if
target
.
startswith
(
settings
.
SITE_URL
):
if
target
.
startswith
(
settings
.
SITE_URL
):
user
=
Model
.
resolve_parent
(
target
.
replace
(
settings
.
SITE_URL
,
''
))
user
=
Model
.
resolve_parent
(
target
.
replace
(
settings
.
SITE_URL
,
''
))
# render the filters now, the resource is local
from
djangoldp_notification.views
import
filter_object_is_permitted
if
not
filter_object_is_permitted
(
user
,
json
):
return
Notification
.
objects
.
create
(
user
=
user
,
object
=
object_iri
,
type
=
request_type
,
author
=
author
)
Notification
.
objects
.
create
(
user
=
user
,
object
=
object_iri
,
type
=
request_type
,
author
=
author
)
# external inbox
# external inbox
else
:
else
:
json
=
{
"
@context
"
:
settings
.
LDP_RDF_CONTEXT
,
"
object
"
:
object_iri
if
not
serialize_object
else
serialize_instance
(),
"
author
"
:
author
,
"
type
"
:
request_type
}
ActivityQueueService
.
send_activity
(
target
,
json
)
ActivityQueueService
.
send_activity
(
target
,
json
)
...
...
This diff is collapsed.
Click to expand it.
djangoldp_notification/views.py
+
8
−
7
View file @
26b23fd3
...
@@ -18,12 +18,7 @@ class LDPNotificationsPagination(LDPPagination):
...
@@ -18,12 +18,7 @@ class LDPNotificationsPagination(LDPPagination):
default_limit
=
80
default_limit
=
80
class
LDPNotificationsViewSet
(
LDPViewSet
):
def
filter_object_is_permitted
(
recipient
,
data
):
'''
overridden LDPViewSet to force pagination
'''
pagination_class
=
LDPNotificationsPagination
depth
=
0
def
_filter_object_is_permitted
(
self
,
recipient
,
data
):
'''
'''
applies filter on passed object data
applies filter on passed object data
returns True if the object is permitted, False if not
returns True if the object is permitted, False if not
...
@@ -51,6 +46,12 @@ class LDPNotificationsViewSet(LDPViewSet):
...
@@ -51,6 +46,12 @@ class LDPNotificationsViewSet(LDPViewSet):
return
object_model
.
permit_notification
(
recipient
,
data
)
return
object_model
.
permit_notification
(
recipient
,
data
)
class
LDPNotificationsViewSet
(
LDPViewSet
):
'''
overridden LDPViewSet to force pagination
'''
pagination_class
=
LDPNotificationsPagination
depth
=
0
def
_resolve_user_recipient
(
self
,
request
):
def
_resolve_user_recipient
(
self
,
request
):
# TODO: extend to work on views other than the nested inbox
# TODO: extend to work on views other than the nested inbox
# https://git.startinblox.com/djangoldp-packages/djangoldp-notification/issues/41
# https://git.startinblox.com/djangoldp-packages/djangoldp-notification/issues/41
...
@@ -71,7 +72,7 @@ class LDPNotificationsViewSet(LDPViewSet):
...
@@ -71,7 +72,7 @@ class LDPNotificationsViewSet(LDPViewSet):
data
=
request
.
data
data
=
request
.
data
if
'
object
'
in
data
:
if
'
object
'
in
data
:
if
not
self
.
_
filter_object_is_permitted
(
recipient
,
data
):
if
not
filter_object_is_permitted
(
recipient
,
data
):
# if the notification should not be sent, accept the request but do nothing
# if the notification should not be sent, accept the request but do nothing
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment