mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #15350 from overleaf/csh-issue-11625-mongo-ug-5-notifications
Use mongodb-legacy in notifications for callback support GitOrigin-RevId: 90f05f747e221c1bd61564e2e28e505d0b125467
This commit is contained in:
parent
6a118d9439
commit
e86ef1139e
6 changed files with 208 additions and 78 deletions
245
package-lock.json
generated
245
package-lock.json
generated
|
@ -28048,6 +28048,84 @@
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/mongodb-legacy": {
|
||||||
|
"version": "6.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/mongodb-legacy/-/mongodb-legacy-6.0.1.tgz",
|
||||||
|
"integrity": "sha512-cbm3UOqAYo6yElNk9CHNp5tQwRl1PCpBpcSkVvlvyg7S+gG6vSt1zrFiEniNaWOwwWnIr/IsAeSo48Nm701B/A==",
|
||||||
|
"dependencies": {
|
||||||
|
"mongodb": "^6.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.20.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mongodb-legacy/node_modules/bson": {
|
||||||
|
"version": "6.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz",
|
||||||
|
"integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.20.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mongodb-legacy/node_modules/gcp-metadata": {
|
||||||
|
"version": "5.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz",
|
||||||
|
"integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==",
|
||||||
|
"optional": true,
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"gaxios": "^5.0.0",
|
||||||
|
"json-bigint": "^1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mongodb-legacy/node_modules/mongodb": {
|
||||||
|
"version": "6.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz",
|
||||||
|
"integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@mongodb-js/saslprep": "^1.1.0",
|
||||||
|
"bson": "^6.1.0",
|
||||||
|
"mongodb-connection-string-url": "^2.6.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.20.1"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@aws-sdk/credential-providers": "^3.188.0",
|
||||||
|
"@mongodb-js/zstd": "^1.1.0",
|
||||||
|
"gcp-metadata": "^5.2.0",
|
||||||
|
"kerberos": "^2.0.1",
|
||||||
|
"mongodb-client-encryption": ">=6.0.0 <7",
|
||||||
|
"snappy": "^7.2.2",
|
||||||
|
"socks": "^2.7.1"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@aws-sdk/credential-providers": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@mongodb-js/zstd": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"gcp-metadata": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"kerberos": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"mongodb-client-encryption": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"snappy": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"socks": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mongoose": {
|
"node_modules/mongoose": {
|
||||||
"version": "5.13.20",
|
"version": "5.13.20",
|
||||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.20.tgz",
|
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.20.tgz",
|
||||||
|
@ -38509,7 +38587,8 @@
|
||||||
"bunyan": "^1.8.15",
|
"bunyan": "^1.8.15",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"method-override": "^3.0.0",
|
"method-override": "^3.0.0",
|
||||||
"mongodb": "^4.11.0",
|
"mongodb": "^6.1.0",
|
||||||
|
"mongodb-legacy": "^6.0.1",
|
||||||
"request": "^2.88.2"
|
"request": "^2.88.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -38521,54 +38600,70 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"services/notifications/node_modules/bson": {
|
"services/notifications/node_modules/bson": {
|
||||||
"version": "4.7.2",
|
"version": "6.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz",
|
||||||
"integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==",
|
"integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==",
|
||||||
"dependencies": {
|
|
||||||
"buffer": "^5.6.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0"
|
"node": ">=16.20.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"services/notifications/node_modules/buffer": {
|
"services/notifications/node_modules/gcp-metadata": {
|
||||||
"version": "5.7.1",
|
"version": "5.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz",
|
||||||
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
"integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==",
|
||||||
"funding": [
|
"optional": true,
|
||||||
{
|
"peer": true,
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/feross"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "patreon",
|
|
||||||
"url": "https://www.patreon.com/feross"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "consulting",
|
|
||||||
"url": "https://feross.org/support"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"base64-js": "^1.3.1",
|
"gaxios": "^5.0.0",
|
||||||
"ieee754": "^1.1.13"
|
"json-bigint": "^1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"services/notifications/node_modules/mongodb": {
|
"services/notifications/node_modules/mongodb": {
|
||||||
"version": "4.17.1",
|
"version": "6.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.17.1.tgz",
|
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz",
|
||||||
"integrity": "sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==",
|
"integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bson": "^4.7.2",
|
"@mongodb-js/saslprep": "^1.1.0",
|
||||||
"mongodb-connection-string-url": "^2.6.0",
|
"bson": "^6.1.0",
|
||||||
"socks": "^2.7.1"
|
"mongodb-connection-string-url": "^2.6.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.9.0"
|
"node": ">=16.20.1"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"peerDependencies": {
|
||||||
"@aws-sdk/credential-providers": "^3.186.0",
|
"@aws-sdk/credential-providers": "^3.188.0",
|
||||||
"@mongodb-js/saslprep": "^1.1.0"
|
"@mongodb-js/zstd": "^1.1.0",
|
||||||
|
"gcp-metadata": "^5.2.0",
|
||||||
|
"kerberos": "^2.0.1",
|
||||||
|
"mongodb-client-encryption": ">=6.0.0 <7",
|
||||||
|
"snappy": "^7.2.2",
|
||||||
|
"socks": "^2.7.1"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@aws-sdk/credential-providers": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@mongodb-js/zstd": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"gcp-metadata": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"kerberos": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"mongodb-client-encryption": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"snappy": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"socks": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"services/project-history": {
|
"services/project-history": {
|
||||||
|
@ -46791,39 +46886,37 @@
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"method-override": "^3.0.0",
|
"method-override": "^3.0.0",
|
||||||
"mocha": "^10.2.0",
|
"mocha": "^10.2.0",
|
||||||
"mongodb": "^4.11.0",
|
"mongodb": "^6.1.0",
|
||||||
|
"mongodb-legacy": "^6.0.1",
|
||||||
"request": "^2.88.2",
|
"request": "^2.88.2",
|
||||||
"sandboxed-module": "^2.0.4",
|
"sandboxed-module": "^2.0.4",
|
||||||
"sinon": "^9.2.4"
|
"sinon": "^9.2.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bson": {
|
"bson": {
|
||||||
"version": "4.7.2",
|
"version": "6.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz",
|
||||||
"integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==",
|
"integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q=="
|
||||||
"requires": {
|
|
||||||
"buffer": "^5.6.0"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"buffer": {
|
"gcp-metadata": {
|
||||||
"version": "5.7.1",
|
"version": "5.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz",
|
||||||
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
"integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==",
|
||||||
|
"optional": true,
|
||||||
|
"peer": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"base64-js": "^1.3.1",
|
"gaxios": "^5.0.0",
|
||||||
"ieee754": "^1.1.13"
|
"json-bigint": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mongodb": {
|
"mongodb": {
|
||||||
"version": "4.17.1",
|
"version": "6.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.17.1.tgz",
|
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz",
|
||||||
"integrity": "sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==",
|
"integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@aws-sdk/credential-providers": "^3.186.0",
|
|
||||||
"@mongodb-js/saslprep": "^1.1.0",
|
"@mongodb-js/saslprep": "^1.1.0",
|
||||||
"bson": "^4.7.2",
|
"bson": "^6.1.0",
|
||||||
"mongodb-connection-string-url": "^2.6.0",
|
"mongodb-connection-string-url": "^2.6.0"
|
||||||
"socks": "^2.7.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64043,6 +64136,42 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mongodb-legacy": {
|
||||||
|
"version": "6.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/mongodb-legacy/-/mongodb-legacy-6.0.1.tgz",
|
||||||
|
"integrity": "sha512-cbm3UOqAYo6yElNk9CHNp5tQwRl1PCpBpcSkVvlvyg7S+gG6vSt1zrFiEniNaWOwwWnIr/IsAeSo48Nm701B/A==",
|
||||||
|
"requires": {
|
||||||
|
"mongodb": "^6.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"bson": {
|
||||||
|
"version": "6.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz",
|
||||||
|
"integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q=="
|
||||||
|
},
|
||||||
|
"gcp-metadata": {
|
||||||
|
"version": "5.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz",
|
||||||
|
"integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==",
|
||||||
|
"optional": true,
|
||||||
|
"peer": true,
|
||||||
|
"requires": {
|
||||||
|
"gaxios": "^5.0.0",
|
||||||
|
"json-bigint": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mongodb": {
|
||||||
|
"version": "6.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.1.0.tgz",
|
||||||
|
"integrity": "sha512-AvzNY0zMkpothZ5mJAaIo2bGDjlJQqqAbn9fvtVgwIIUPEfdrqGxqNjjbuKyrgQxg2EvCmfWdjq+4uj96c0YPw==",
|
||||||
|
"requires": {
|
||||||
|
"@mongodb-js/saslprep": "^1.1.0",
|
||||||
|
"bson": "^6.1.0",
|
||||||
|
"mongodb-connection-string-url": "^2.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"mongoose": {
|
"mongoose": {
|
||||||
"version": "5.13.20",
|
"version": "5.13.20",
|
||||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.20.tgz",
|
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.20.tgz",
|
||||||
|
|
|
@ -18,11 +18,11 @@ const logger = require('@overleaf/logger')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
check(callback) {
|
check(callback) {
|
||||||
const userId = ObjectId()
|
const userId = new ObjectId()
|
||||||
const cleanupNotifications = callback =>
|
const cleanupNotifications = callback =>
|
||||||
db.notifications.remove({ user_id: userId }, callback)
|
db.notifications.deleteOne({ user_id: userId }, callback)
|
||||||
|
|
||||||
let notificationKey = `smoke-test-notification-${ObjectId()}`
|
let notificationKey = `smoke-test-notification-${new ObjectId()}`
|
||||||
const getOpts = endPath => ({
|
const getOpts = endPath => ({
|
||||||
url: `http://localhost:${port}/user/${userId}${endPath}`,
|
url: `http://localhost:${port}/user/${userId}${endPath}`,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
|
|
|
@ -20,7 +20,7 @@ module.exports = Notifications = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
const query = {
|
const query = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
templateKey: { $exists: true },
|
templateKey: { $exists: true },
|
||||||
}
|
}
|
||||||
db.notifications.find(query).toArray(callback)
|
db.notifications.find(query).toArray(callback)
|
||||||
|
@ -31,7 +31,7 @@ module.exports = Notifications = {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
}
|
}
|
||||||
const query = {
|
const query = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
key: notification.key,
|
key: notification.key,
|
||||||
}
|
}
|
||||||
return db.notifications.count(query, function (err, count) {
|
return db.notifications.count(query, function (err, count) {
|
||||||
|
@ -54,7 +54,7 @@ module.exports = Notifications = {
|
||||||
return callback()
|
return callback()
|
||||||
}
|
}
|
||||||
const doc = {
|
const doc = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
key: notification.key,
|
key: notification.key,
|
||||||
messageOpts: notification.messageOpts,
|
messageOpts: notification.messageOpts,
|
||||||
templateKey: notification.templateKey,
|
templateKey: notification.templateKey,
|
||||||
|
@ -88,8 +88,8 @@ module.exports = Notifications = {
|
||||||
|
|
||||||
removeNotificationId(userId, notificationId, callback) {
|
removeNotificationId(userId, notificationId, callback) {
|
||||||
const searchOps = {
|
const searchOps = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
_id: ObjectId(notificationId),
|
_id: new ObjectId(notificationId),
|
||||||
}
|
}
|
||||||
const updateOperation = { $unset: { templateKey: true, messageOpts: true } }
|
const updateOperation = { $unset: { templateKey: true, messageOpts: true } }
|
||||||
db.notifications.updateOne(searchOps, updateOperation, callback)
|
db.notifications.updateOne(searchOps, updateOperation, callback)
|
||||||
|
@ -97,7 +97,7 @@ module.exports = Notifications = {
|
||||||
|
|
||||||
removeNotificationKey(userId, notificationKey, callback) {
|
removeNotificationKey(userId, notificationKey, callback) {
|
||||||
const searchOps = {
|
const searchOps = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
key: notificationKey,
|
key: notificationKey,
|
||||||
}
|
}
|
||||||
const updateOperation = { $unset: { templateKey: true } }
|
const updateOperation = { $unset: { templateKey: true } }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const Metrics = require('@overleaf/metrics')
|
const Metrics = require('@overleaf/metrics')
|
||||||
const Settings = require('@overleaf/settings')
|
const Settings = require('@overleaf/settings')
|
||||||
const { MongoClient, ObjectId } = require('mongodb')
|
const { MongoClient, ObjectId } = require('mongodb-legacy')
|
||||||
|
|
||||||
const mongoClient = new MongoClient(Settings.mongo.url)
|
const mongoClient = new MongoClient(Settings.mongo.url)
|
||||||
const mongoDb = mongoClient.db()
|
const mongoDb = mongoClient.db()
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
"bunyan": "^1.8.15",
|
"bunyan": "^1.8.15",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"method-override": "^3.0.0",
|
"method-override": "^3.0.0",
|
||||||
"mongodb": "^4.11.0",
|
"mongodb": "^6.1.0",
|
||||||
|
"mongodb-legacy": "^6.0.1",
|
||||||
"request": "^2.88.2"
|
"request": "^2.88.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -18,7 +18,7 @@ const assert = require('assert')
|
||||||
const { ObjectId } = require('mongodb')
|
const { ObjectId } = require('mongodb')
|
||||||
|
|
||||||
const userId = '51dc93e6fb625a261300003b'
|
const userId = '51dc93e6fb625a261300003b'
|
||||||
const notificationId = 'fb625a26f09d'
|
const notificationId = '574ee8d6f40c3a244e704249'
|
||||||
const notificationKey = 'notification-key'
|
const notificationKey = 'notification-key'
|
||||||
|
|
||||||
describe('Notifications Tests', function () {
|
describe('Notifications Tests', function () {
|
||||||
|
@ -46,7 +46,7 @@ describe('Notifications Tests', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
this.stubbedNotification = {
|
this.stubbedNotification = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
key: 'notification-key',
|
key: 'notification-key',
|
||||||
messageOpts: 'some info',
|
messageOpts: 'some info',
|
||||||
templateKey: 'template-key',
|
templateKey: 'template-key',
|
||||||
|
@ -63,7 +63,7 @@ describe('Notifications Tests', function () {
|
||||||
if (err) return done(err)
|
if (err) return done(err)
|
||||||
notifications.should.equal(this.stubbedNotificationArray)
|
notifications.should.equal(this.stubbedNotificationArray)
|
||||||
assert.deepEqual(this.findStub.args[0][0], {
|
assert.deepEqual(this.findStub.args[0][0], {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
templateKey: { $exists: true },
|
templateKey: { $exists: true },
|
||||||
})
|
})
|
||||||
return done()
|
return done()
|
||||||
|
@ -75,7 +75,7 @@ describe('Notifications Tests', function () {
|
||||||
describe('addNotification', function () {
|
describe('addNotification', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.stubbedNotification = {
|
this.stubbedNotification = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
key: 'notification-key',
|
key: 'notification-key',
|
||||||
messageOpts: 'some info',
|
messageOpts: 'some info',
|
||||||
templateKey: 'template-key',
|
templateKey: 'template-key',
|
||||||
|
@ -150,7 +150,7 @@ describe('Notifications Tests', function () {
|
||||||
describe('when the notification is set to expire', function () {
|
describe('when the notification is set to expire', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.stubbedNotification = {
|
this.stubbedNotification = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
key: 'notification-key',
|
key: 'notification-key',
|
||||||
messageOpts: 'some info',
|
messageOpts: 'some info',
|
||||||
templateKey: 'template-key',
|
templateKey: 'template-key',
|
||||||
|
@ -190,7 +190,7 @@ describe('Notifications Tests', function () {
|
||||||
return describe('when the notification has a nonsensical expires field', function () {
|
return describe('when the notification has a nonsensical expires field', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.stubbedNotification = {
|
this.stubbedNotification = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
key: 'notification-key',
|
key: 'notification-key',
|
||||||
messageOpts: 'some info',
|
messageOpts: 'some info',
|
||||||
templateKey: 'template-key',
|
templateKey: 'template-key',
|
||||||
|
@ -229,8 +229,8 @@ describe('Notifications Tests', function () {
|
||||||
err => {
|
err => {
|
||||||
if (err) return done(err)
|
if (err) return done(err)
|
||||||
const searchOps = {
|
const searchOps = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
_id: ObjectId(notificationId),
|
_id: new ObjectId(notificationId),
|
||||||
}
|
}
|
||||||
const updateOperation = {
|
const updateOperation = {
|
||||||
$unset: { templateKey: true, messageOpts: true },
|
$unset: { templateKey: true, messageOpts: true },
|
||||||
|
@ -253,7 +253,7 @@ describe('Notifications Tests', function () {
|
||||||
err => {
|
err => {
|
||||||
if (err) return done(err)
|
if (err) return done(err)
|
||||||
const searchOps = {
|
const searchOps = {
|
||||||
user_id: ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
key: notificationKey,
|
key: notificationKey,
|
||||||
}
|
}
|
||||||
const updateOperation = {
|
const updateOperation = {
|
||||||
|
|
Loading…
Reference in a new issue