Skip to content

Commit

Permalink
bucket notifications - allow empty notifications content to facilitat…
Browse files Browse the repository at this point in the history
…e notification conf removal (#8692)

Signed-off-by: Amit Prinz Setter <[email protected]>
  • Loading branch information
alphaprinz committed Jan 16, 2025
1 parent a57121f commit f031db7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/endpoint/s3/ops/s3_put_bucket_notification.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
/* Copyright (C) 2016 NooBaa */
'use strict';

const S3Error = require('../s3_errors').S3Error;

/**
* http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTnotification.html
*/
async function put_bucket_notification(req) {

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

//adapt to db shcema
for (const conf of topic_configuration) {
conf.id = conf.Id;
conf.event = conf.Event;
conf.topic = conf.Topic;
delete conf.Id;
delete conf.Event;
delete conf.Topic;
if (topic_configuration) {
for (const conf of topic_configuration) {
conf.id = conf.Id;
conf.event = conf.Event;
conf.topic = conf.Topic;
delete conf.Id;
delete conf.Event;
delete conf.Topic;
}
}

const reply = await req.object_sdk.put_bucket_notification({
Expand Down
3 changes: 3 additions & 0 deletions src/util/notifications_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ function get_connection(connect) {


async function test_notifications(bucket, connect_files_dir) {
if (!bucket.notifications) {
return;
}
const notificator = new Notificator({connect_files_dir});
for (const notif of bucket.notifications) {
const connect = await notificator.parse_connect_file(notif.connect);
Expand Down

0 comments on commit f031db7

Please sign in to comment.