Skip to content

Commit f72907e

Browse files
authored
bucket notifications - allow empty notifications content to facilitate notification conf removal (#8692)
Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
1 parent 460592e commit f72907e

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/endpoint/s3/ops/s3_put_bucket_notification.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
/* Copyright (C) 2016 NooBaa */
22
'use strict';
33

4-
const S3Error = require('../s3_errors').S3Error;
5-
64
/**
75
* http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTnotification.html
86
*/
97
async function put_bucket_notification(req) {
108

119
const topic_configuration = req.body.NotificationConfiguration?.TopicConfiguration;
12-
if (!topic_configuration ||
13-
typeof topic_configuration !== 'object') throw new S3Error(S3Error.MalformedXML);
1410

1511
//adapt to db shcema
16-
for (const conf of topic_configuration) {
17-
conf.id = conf.Id;
18-
conf.event = conf.Event;
19-
conf.topic = conf.Topic;
20-
delete conf.Id;
21-
delete conf.Event;
22-
delete conf.Topic;
12+
if (topic_configuration) {
13+
for (const conf of topic_configuration) {
14+
conf.id = conf.Id;
15+
conf.event = conf.Event;
16+
conf.topic = conf.Topic;
17+
delete conf.Id;
18+
delete conf.Event;
19+
delete conf.Topic;
20+
}
2321
}
2422

2523
const reply = await req.object_sdk.put_bucket_notification({

src/util/notifications_util.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ function get_connection(connect) {
306306

307307

308308
async function test_notifications(bucket, connect_files_dir) {
309+
if (!bucket.notifications) {
310+
return;
311+
}
309312
const notificator = new Notificator({connect_files_dir});
310313
for (const notif of bucket.notifications) {
311314
const connect = await notificator.parse_connect_file(notif.connect);

0 commit comments

Comments
 (0)