Skip to content

Commit

Permalink
Merge pull request rairprotocol#99 from rairprotocol/98-delete-multip…
Browse files Browse the repository at this point in the history
…le-notifications

Update
  • Loading branch information
sarora180673 authored Jul 9, 2024
2 parents 10261cf + 89dbc77 commit e5beb92
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
4 changes: 2 additions & 2 deletions rair-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ The benefits of using the Dockerfile are that it uses the latest OFAC list.
* [x] /notifications
* [x] / - GET - List of notifications ([details](readme/current/notifications/get_list.md))
* [x] /:id - GET - Get a single notification ([details](readme/current/notifications/get_single.md))
* [x] / - PUT - Mark notifications as read ([details](readme/current/notifications/mark_read.md))
* [x] /:id - DELETE - Delete a notification ([details](readme/current/notifications/delete.md))
* [x] / - PUT - Mark a notification as read ([details](readme/current/notifications/mark_read.md))
* [x] / - DELETE - Delete a notification ([details](readme/current/notifications/delete.md))

# Contributors
Valerii Kovalov \
Expand Down
4 changes: 2 additions & 2 deletions rair-node/bin/api/notifications/notifications.Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ router.put(
markNotificationAsRead,
);
router.delete(
'/:id',
'/',
requireUserSession,
validation(['dbId'], 'params'),
validation(['dbIdArray'], 'params'),
deleteNotification,
);

Expand Down
9 changes: 3 additions & 6 deletions rair-node/bin/api/notifications/notifications.Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,11 @@ module.exports = {
},
deleteNotification: async (req, res, next) => {
try {
const { id } = req.params;
const notification = await Notification.findByIdAndDelete(id);
if (!notification) {
return next(new AppError('Notification not found', 404));
}
const { ids } = req.body;
const result = await Notification.deleteMany({ _id: { $in: ids } });
return res.json({
success: true,
notification,
deleted: result.deletedCount,
});
} catch (err) {
logger.error(err);
Expand Down
15 changes: 4 additions & 11 deletions rair-node/readme/current/notifications/delete.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Delete single notification

**URL** : `/api/notifications/:id`
**URL** : `/api/notifications/`
**Method** : `DELETE`

**Parameters**
**Body Parameters**
```json
{
"id": { "required": false, "content": { "type": "string" } },
"ids": { "required": true, "content": { "type": "string[]" } },
}
```

Expand All @@ -17,13 +17,6 @@
```json
{
"success": true,
"notification": {
"_id": "6657edb4d1f06c7b91e39089",
"user": "0xec30759d0a3f3ce0a730111dc29d74e441f492c3",
"type": "message",
"message": "Logged in as 0xec30759d0a3f3ce0a730111dc29d74e441f492c3",
"data": [],
"read": true
},
"deleted": 1
}
```
2 changes: 1 addition & 1 deletion rair-node/readme/current/notifications/mark_read.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
**Body Parameters**
```json
{
"ids": { "required": false, "content": { "type": "string[]" } },
"ids": { "required": true, "content": { "type": "string[]" } },
}
```

Expand Down

0 comments on commit e5beb92

Please sign in to comment.