@@ -17,10 +17,13 @@ function getParent (path) {
17
17
return parent === '/' ? '/' : `${ parent } /`
18
18
}
19
19
20
- function getActivity ( method ) {
20
+ function getActivity ( method , path ) {
21
21
if ( method === 'DELETE' ) {
22
22
return 'Delete'
23
23
}
24
+ if ( method === 'POST' && path . endsWith ( '/' ) ) {
25
+ return 'Add'
26
+ }
24
27
return 'Update'
25
28
}
26
29
@@ -37,10 +40,10 @@ function getParentActivity (method, status) {
37
40
function handler ( req , res , next ) {
38
41
const { trigger, defaultNotification } = res . events . prep
39
42
40
- const { method } = req
43
+ const { method, path } = req
41
44
const { statusCode } = res
42
45
const eventID = res . getHeader ( 'event-id' )
43
- const fullUrl = new URL ( req . path , `${ req . protocol } ://${ req . hostname } /` )
46
+ const fullUrl = new URL ( path , `${ req . protocol } ://${ req . hostname } /` )
44
47
45
48
// Date is a hack since node does not seem to provide access to send date.
46
49
// Date needs to be shared with parent notification
@@ -56,10 +59,10 @@ function handler (req, res, next) {
56
59
negotiatedFields
57
60
) {
58
61
const mediaType = negotiatedFields [ 'content-type' ]
59
-
62
+ const activity = getActivity ( method , path )
60
63
if ( ALLOWED_RDF_MIME_TYPES . includes ( mediaType ?. [ 0 ] ) ) {
61
64
return `${ headerTemplate ( negotiatedFields ) } \r\n${ solidRDFTemplate ( {
62
- activity : getActivity ( method ) ,
65
+ activity,
63
66
eventID,
64
67
object : String ( fullUrl ) ,
65
68
date : eventDate ,
@@ -81,7 +84,7 @@ function handler (req, res, next) {
81
84
82
85
// Write a notification to parent container
83
86
// POST in Solid creates a child resource
84
- const parent = getParent ( req . path )
87
+ const parent = getParent ( path )
85
88
if ( parent && method !== 'POST' ) {
86
89
try {
87
90
const parentID = res . setEventID ( parent )
0 commit comments