File tree Expand file tree Collapse file tree 1 file changed +16
-29
lines changed Expand file tree Collapse file tree 1 file changed +16
-29
lines changed Original file line number Diff line number Diff line change @@ -8,38 +8,25 @@ const _ = require('lodash');
8
8
*/
9
9
async function get_bucket_notification ( req ) {
10
10
11
- let result = await req . object_sdk . get_bucket_notification ( {
11
+ const result = await req . object_sdk . get_bucket_notification ( {
12
12
bucket_name : req . params . bucket ,
13
13
} ) ;
14
14
15
- result = _ . cloneDeep ( result ) ;
16
-
17
- const TopicConfiguration = [ ] ;
18
-
19
- //adapt to aws cli structure
20
- if ( result && result . length > 0 ) {
21
- for ( const conf of result ) {
22
- conf . Event = conf . event ;
23
- conf . Topic = conf . topic ;
24
- conf . Id = conf . id ;
25
- delete conf . event ;
26
- delete conf . topic ;
27
- delete conf . id ;
28
-
29
- TopicConfiguration . push ( { TopicConfiguration : conf } ) ;
30
- }
31
- }
32
-
33
- const reply = result && result . length > 0 ?
34
- {
35
- //return result inside TopicConfiguration tag
36
- NotificationConfiguration :
37
- TopicConfiguration
38
- } :
39
- //if there's no notification, return empty NotificationConfiguration tag
40
- { NotificationConfiguration : { } } ;
41
-
42
- return reply ;
15
+ //adapt to structure that xml_utils.encode_xml() will then
16
+ //encode into aws compliant reply
17
+ return {
18
+ NotificationConfiguration : [ _ . map ( result , t => ( {
19
+ TopicConfiguration : [
20
+ {
21
+ Id : t . id ,
22
+ Topic : t . topic ,
23
+ } ,
24
+ _ . map ( t . event , e => ( {
25
+ Event : e
26
+ } ) )
27
+ ]
28
+ } ) ) ]
29
+ } ;
43
30
}
44
31
45
32
module . exports = {
You can’t perform that action at this time.
0 commit comments