Update moongo

This commit is contained in:
2026-03-25 20:14:41 +01:00
parent 3ad16d8f32
commit 3eb40a1e26
30 changed files with 418 additions and 331 deletions
+279 -200
View File
@@ -46,8 +46,6 @@
"@types/howler": "^2.2.12", "@types/howler": "^2.2.12",
"@types/lodash": "^4.17.24", "@types/lodash": "^4.17.24",
"@types/mocha": "^10.0.10", "@types/mocha": "^10.0.10",
"@types/mongodb": "^3.3.1",
"@types/mongoose": "^5.5.15",
"@types/morgan": "^1.9.10", "@types/morgan": "^1.9.10",
"@types/node": "^25.5.0", "@types/node": "^25.5.0",
"@types/node-ipc": "^9.2.3", "@types/node-ipc": "^9.2.3",
@@ -79,7 +77,7 @@
"chai-as-promised": "^7.1.1", "chai-as-promised": "^7.1.1",
"chalk": "^2.4.2", "chalk": "^2.4.2",
"color-convert": "^2.0.1", "color-convert": "^2.0.1",
"connect-mongo": "^3.0.0", "connect-mongo": "^6.0.0",
"cookie-parser": "^1.4.4", "cookie-parser": "^1.4.4",
"core-js": "^3.2.1", "core-js": "^3.2.1",
"del": "^5.1.0", "del": "^5.1.0",
@@ -123,7 +121,7 @@
"merge2": "^1.2.4", "merge2": "^1.2.4",
"mocha": "^6.2.0", "mocha": "^6.2.0",
"moment": "^2.24.0", "moment": "^2.24.0",
"mongoose": "^5.6.11", "mongoose": "^9.3.2",
"morgan": "^1.9.1", "morgan": "^1.9.1",
"ngx-bootstrap": "^18.0.1", "ngx-bootstrap": "^18.0.1",
"passport": "^0.4.0", "passport": "^0.4.0",
@@ -5422,6 +5420,15 @@
"win32" "win32"
] ]
}, },
"node_modules/@mongodb-js/saslprep": {
"version": "1.4.6",
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.4.6.tgz",
"integrity": "sha512-y+x3H1xBZd38n10NZF/rEBlvDOOMQ6LKUTHqr8R9VkJ+mmQOYtJFxIlkkK8fZrtOiL6VixbOBWMbZGBdal3Z1g==",
"license": "MIT",
"dependencies": {
"sparse-bitfield": "^3.0.3"
}
},
"node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64": { "node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-arm64/-/msgpackr-extract-darwin-arm64-3.0.3.tgz", "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-arm64/-/msgpackr-extract-darwin-arm64-3.0.3.tgz",
@@ -6080,15 +6087,6 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"node_modules/@types/bson": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/@types/bson/-/bson-4.0.5.tgz",
"integrity": "sha512-vVLwMUqhYJSQ/WKcE60eFqcyuWse5fGH+NMAXHuKrUAPoryq3ATxk5o4bgYNtg5aOM4APVg7Hnb3ASqUYG0PKg==",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/caseless": { "node_modules/@types/caseless": {
"version": "0.12.2", "version": "0.12.2",
"resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz", "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz",
@@ -6354,26 +6352,6 @@
"integrity": "sha512-xPyYSz1cMPnJQhl0CLMH68j3gprKZaTjG3s5Vi+fDgx+uhG9NOXwbVt52eFS8ECyXhyKcjDLCBEqBExKuiZb7Q==", "integrity": "sha512-xPyYSz1cMPnJQhl0CLMH68j3gprKZaTjG3s5Vi+fDgx+uhG9NOXwbVt52eFS8ECyXhyKcjDLCBEqBExKuiZb7Q==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/mongodb": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.3.1.tgz",
"integrity": "sha512-Va7o1fN3zeabmIJSQ6yuAWkqPvrT38HSTIi4YbVOb2UL7FJ4diXrWt+OUuuEFWAVPtF9VZV5h+7LDYdzgXWgQA==",
"license": "MIT",
"dependencies": {
"@types/bson": "*",
"@types/node": "*"
}
},
"node_modules/@types/mongoose": {
"version": "5.5.15",
"resolved": "https://registry.npmjs.org/@types/mongoose/-/mongoose-5.5.15.tgz",
"integrity": "sha512-LgUHpGl6mmcyzjZR/afUZ7mDPjDd38mA0HCf8vL11otVKiNGyu7ug8z3ePx2QAqcPrxbtfaJVgirdBeNXYG54Q==",
"license": "MIT",
"dependencies": {
"@types/mongodb": "*",
"@types/node": "*"
}
},
"node_modules/@types/morgan": { "node_modules/@types/morgan": {
"version": "1.9.10", "version": "1.9.10",
"resolved": "https://registry.npmjs.org/@types/morgan/-/morgan-1.9.10.tgz", "resolved": "https://registry.npmjs.org/@types/morgan/-/morgan-1.9.10.tgz",
@@ -6654,6 +6632,21 @@
"integrity": "sha512-42qYzEoJ1yQlDNWSwtJmQKUKAoYv25mjsxKXhwn4/1qlG3Xlr8t8EK/2771dVi5ytw/KX5XwwG5L8lNxLf6qSQ==", "integrity": "sha512-42qYzEoJ1yQlDNWSwtJmQKUKAoYv25mjsxKXhwn4/1qlG3Xlr8t8EK/2771dVi5ytw/KX5XwwG5L8lNxLf6qSQ==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/webidl-conversions": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz",
"integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==",
"license": "MIT"
},
"node_modules/@types/whatwg-url": {
"version": "13.0.0",
"resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-13.0.0.tgz",
"integrity": "sha512-N8WXpbE6Wgri7KUSvrmQcqrMllKZ9uxkYWMt+mCSGwNc0Hsw9VQTW7ApqI4XNrx6/SaM2QQJCzMPDEXE058s+Q==",
"license": "MIT",
"dependencies": {
"@types/webidl-conversions": "*"
}
},
"node_modules/@types/wrap-ansi": { "node_modules/@types/wrap-ansi": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz", "resolved": "https://registry.npmjs.org/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz",
@@ -9426,6 +9419,18 @@
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
"integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y="
}, },
"node_modules/asn1.js": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz",
"integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==",
"license": "MIT",
"dependencies": {
"bn.js": "^4.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0",
"safer-buffer": "^2.1.0"
}
},
"node_modules/asn1js": { "node_modules/asn1js": {
"version": "3.0.7", "version": "3.0.7",
"resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.7.tgz", "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.7.tgz",
@@ -9478,14 +9483,6 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/async": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz",
"integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==",
"dependencies": {
"lodash": "^4.17.11"
}
},
"node_modules/async-done": { "node_modules/async-done": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.1.tgz", "resolved": "https://registry.npmjs.org/async-done/-/async-done-1.3.1.tgz",
@@ -10293,6 +10290,12 @@
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz",
"integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==" "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w=="
}, },
"node_modules/bn.js": {
"version": "4.12.3",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.3.tgz",
"integrity": "sha512-fGTi3gxV/23FTYdAoUtLYp6qySe2KE3teyZitipKNRuVYcBkoP/bB3guXN/XVKUe9mxCHXnc9C4ocyz8OmgN0g==",
"license": "MIT"
},
"node_modules/body": { "node_modules/body": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/body/-/body-5.1.0.tgz", "resolved": "https://registry.npmjs.org/body/-/body-5.1.0.tgz",
@@ -10591,12 +10594,12 @@
} }
}, },
"node_modules/bson": { "node_modules/bson": {
"version": "1.1.1", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz", "resolved": "https://registry.npmjs.org/bson/-/bson-7.2.0.tgz",
"integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg==", "integrity": "sha512-YCEo7KjMlbNlyHhz7zAZNDpIpQbd+wOEHJYezv0nMYTn4x31eIUM2yomNNubclAt63dObUzKHWsBLJ9QcZNSnQ==",
"deprecated": "Fixed a critical issue with BSON serialization documented in CVE-2019-2391, see https://bit.ly/2KcpXdo for more details", "license": "Apache-2.0",
"engines": { "engines": {
"node": ">=0.6.19" "node": ">=20.19.0"
} }
}, },
"node_modules/buffer": { "node_modules/buffer": {
@@ -12045,13 +12048,45 @@
} }
}, },
"node_modules/connect-mongo": { "node_modules/connect-mongo": {
"version": "3.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/connect-mongo/-/connect-mongo-3.0.0.tgz", "resolved": "https://registry.npmjs.org/connect-mongo/-/connect-mongo-6.0.0.tgz",
"integrity": "sha512-Y95urWNGrAoKY2w31s7Q9Gs/W3qdMCshUIeDTgulssHi6KueYtz4XrbV3kcnQaR8EcBQvooNNX7aOaAJDgudag==", "integrity": "sha512-mHxfnTiWk7ZtxmHdcrFBKlr7fCtgGoFpx/oe9jFW0yb2NinagsxEeuol78nUWMpnWyYK0nnuXMlU9wrgUjTE6g==",
"license": "MIT",
"dependencies": { "dependencies": {
"mongodb": "^3.1.0" "debug": "^4.4.3",
"kruptein": "3.0.8"
},
"engines": {
"node": ">=20.8.0"
},
"peerDependencies": {
"express-session": "^1.17.1",
"mongodb": ">=5.0.0"
} }
}, },
"node_modules/connect-mongo/node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/connect-mongo/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/connect/node_modules/debug": { "node_modules/connect/node_modules/debug": {
"version": "2.6.9", "version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
@@ -15148,35 +15183,71 @@
} }
}, },
"node_modules/express-session": { "node_modules/express-session": {
"version": "1.16.2", "version": "1.19.0",
"resolved": "https://registry.npmjs.org/express-session/-/express-session-1.16.2.tgz", "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.19.0.tgz",
"integrity": "sha512-oy0sRsdw6n93E9wpCNWKRnSsxYnSDX9Dnr9mhZgqUEEorzcq5nshGYSZ4ZReHFhKQ80WI5iVUUSPW7u3GaKauw==", "integrity": "sha512-0csaMkGq+vaiZTmSMMGkfdCOabYv192VbytFypcvI0MANrp+4i/7yEkJ0sbAEhycQjntaKGzYfjfXQyVb7BHMA==",
"license": "MIT",
"dependencies": { "dependencies": {
"cookie": "0.3.1", "cookie": "~0.7.2",
"cookie-signature": "1.0.6", "cookie-signature": "~1.0.7",
"debug": "2.6.9", "debug": "~2.6.9",
"depd": "~2.0.0", "depd": "~2.0.0",
"on-headers": "~1.0.2", "on-headers": "~1.1.0",
"parseurl": "~1.3.3", "parseurl": "~1.3.3",
"safe-buffer": "5.1.2", "safe-buffer": "~5.2.1",
"uid-safe": "~2.1.5" "uid-safe": "~2.1.5"
}, },
"engines": { "engines": {
"node": ">= 0.8.0" "node": ">= 0.8.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
} }
}, },
"node_modules/express-session/node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express-session/node_modules/cookie-signature": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
"license": "MIT"
},
"node_modules/express-session/node_modules/on-headers": { "node_modules/express-session/node_modules/on-headers": {
"version": "1.0.2", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz",
"integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", "integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==",
"license": "MIT",
"engines": { "engines": {
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/express-session/node_modules/safe-buffer": { "node_modules/express-session/node_modules/safe-buffer": {
"version": "5.1.2", "version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
}, },
"node_modules/express/node_modules/cookie": { "node_modules/express/node_modules/cookie": {
"version": "0.7.2", "version": "0.7.2",
@@ -21660,9 +21731,13 @@
"integrity": "sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw==" "integrity": "sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw=="
}, },
"node_modules/kareem": { "node_modules/kareem": {
"version": "2.3.1", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz", "resolved": "https://registry.npmjs.org/kareem/-/kareem-3.2.0.tgz",
"integrity": "sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw==" "integrity": "sha512-VS8MWZz/cT+SqBCpVfNN4zoVz5VskR3N4+sTmUXme55e9avQHntpwpNq0yjnosISXqwJ3AQVjlbI4Dyzv//JtA==",
"license": "Apache-2.0",
"engines": {
"node": ">=18.0.0"
}
}, },
"node_modules/karma-source-map-support": { "node_modules/karma-source-map-support": {
"version": "1.4.0", "version": "1.4.0",
@@ -21692,6 +21767,18 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/kruptein": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/kruptein/-/kruptein-3.0.8.tgz",
"integrity": "sha512-0CyalFA0Cjp3jnziMp0u1uLZW2/ouhQ0mEMfYlroBXNe86na1RwAuwBcdRAegeWZNMfQy/G5fN47g/Axjtqrfw==",
"license": "MIT",
"dependencies": {
"asn1.js": "^5.4.1"
},
"engines": {
"node": ">8"
}
},
"node_modules/last-run": { "node_modules/last-run": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz", "resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz",
@@ -23092,7 +23179,7 @@
"version": "1.5.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
"integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
"optional": true "license": "MIT"
}, },
"node_modules/meow": { "node_modules/meow": {
"version": "3.7.0", "version": "3.7.0",
@@ -23766,80 +23853,90 @@
} }
}, },
"node_modules/mongodb": { "node_modules/mongodb": {
"version": "3.2.7", "version": "7.1.1",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.7.tgz", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-7.1.1.tgz",
"integrity": "sha512-2YdWrdf1PJgxcCrT1tWoL6nHuk6hCxhddAAaEh8QJL231ci4+P9FLyqopbTm2Z2sAU6mhCri+wd9r1hOcHdoMw==", "integrity": "sha512-067DXiMjcpYQl6bGjWQoTUEE9UoRViTtKFcoqX7z08I+iDZv/emH1g8XEFiO3qiDfXAheT5ozl1VffDTKhIW/w==",
"license": "Apache-2.0",
"dependencies": { "dependencies": {
"mongodb-core": "3.2.7", "@mongodb-js/saslprep": "^1.3.0",
"safe-buffer": "^5.1.2" "bson": "^7.1.1",
"mongodb-connection-string-url": "^7.0.0"
}, },
"engines": { "engines": {
"node": ">=4" "node": ">=20.19.0"
},
"peerDependencies": {
"@aws-sdk/credential-providers": "^3.806.0",
"@mongodb-js/zstd": "^7.0.0",
"gcp-metadata": "^7.0.1",
"kerberos": "^7.0.0",
"mongodb-client-encryption": ">=7.0.0 <7.1.0",
"snappy": "^7.3.2",
"socks": "^2.8.6"
},
"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/mongodb-core": { "node_modules/mongodb-connection-string-url": {
"version": "3.2.7", "version": "7.0.1",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.7.tgz", "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-7.0.1.tgz",
"integrity": "sha512-WypKdLxFNPOH/Jy6i9z47IjG2wIldA54iDZBmHMINcgKOUcWJh8og+Wix76oGd7EyYkHJKssQ2FAOw5Su/n4XQ==", "integrity": "sha512-h0AZ9A7IDVwwHyMxmdMXKy+9oNlF0zFoahHiX3vQ8e3KFcSP3VmsmfvtRSuLPxmyv2vjIDxqty8smTgie/SNRQ==",
"license": "Apache-2.0",
"dependencies": { "dependencies": {
"bson": "^1.1.1", "@types/whatwg-url": "^13.0.0",
"require_optional": "^1.0.1", "whatwg-url": "^14.1.0"
"safe-buffer": "^5.1.2"
}, },
"optionalDependencies": { "engines": {
"saslprep": "^1.0.0" "node": ">=20.19.0"
} }
}, },
"node_modules/mongodb-core/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"node_modules/mongodb/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"node_modules/mongoose": { "node_modules/mongoose": {
"version": "5.6.11", "version": "9.3.2",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.6.11.tgz", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-9.3.2.tgz",
"integrity": "sha512-+Mxfmu2Jcspmdqk1111BLUj5mzSLHWKVovImkjzO9GMymTwkHshsuSFmUN7ou4dWy2WR8DPSJcwU52HhnnNk8Q==", "integrity": "sha512-4hMJA4vLAeNG6LnDwJImPYM+uJMVw+sFs7jtS/91OKOT7rzv19ytAAeswtAdWoinVBUVrzmClL/ZoPhcU5RL8w==",
"license": "MIT",
"dependencies": { "dependencies": {
"async": "2.6.2", "kareem": "3.2.0",
"bson": "~1.1.1", "mongodb": "~7.1",
"kareem": "2.3.1", "mpath": "0.9.0",
"mongodb": "3.2.7", "mquery": "6.0.0",
"mongodb-core": "3.2.7", "ms": "2.1.3",
"mongoose-legacy-pluralize": "1.0.2", "sift": "17.1.3"
"mpath": "0.6.0",
"mquery": "3.2.1",
"ms": "2.1.2",
"regexp-clone": "1.0.0",
"safe-buffer": "5.1.2",
"sift": "7.0.1",
"sliced": "1.0.1"
}, },
"engines": { "engines": {
"node": ">=4.0.0" "node": ">=20.19.0"
}
}, },
"node_modules/mongoose-legacy-pluralize": { "funding": {
"version": "1.0.2", "type": "opencollective",
"resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz", "url": "https://opencollective.com/mongoose"
"integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==",
"peerDependencies": {
"mongoose": "*"
} }
}, },
"node_modules/mongoose/node_modules/ms": { "node_modules/mongoose/node_modules/ms": {
"version": "2.1.2", "version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
}, "license": "MIT"
"node_modules/mongoose/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
}, },
"node_modules/morgan": { "node_modules/morgan": {
"version": "1.9.1", "version": "1.9.1",
@@ -23865,46 +23962,23 @@
} }
}, },
"node_modules/mpath": { "node_modules/mpath": {
"version": "0.6.0", "version": "0.9.0",
"resolved": "https://registry.npmjs.org/mpath/-/mpath-0.6.0.tgz", "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz",
"integrity": "sha512-i75qh79MJ5Xo/sbhxrDrPSEG0H/mr1kcZXJ8dH6URU5jD/knFxCVqVC/gVSW7GIXL/9hHWlT9haLbCXWOll3qw==", "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==",
"license": "MIT",
"engines": { "engines": {
"node": ">=4.0.0" "node": ">=4.0.0"
} }
}, },
"node_modules/mquery": { "node_modules/mquery": {
"version": "3.2.1", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.1.tgz", "resolved": "https://registry.npmjs.org/mquery/-/mquery-6.0.0.tgz",
"integrity": "sha512-kY/K8QToZWTTocm0U+r8rqcJCp5PRl6e8tPmoDs5OeSO3DInZE2rAL6AYH+V406JTo8305LdASOQcxRDqHojyw==", "integrity": "sha512-b2KQNsmgtkscfeDgkYMcWGn9vZI9YoXh802VDEwE6qc50zxBFQ0Oo8ROkawbPAsXCY1/Z1yp0MagqsZStPWJjw==",
"dependencies": { "license": "MIT",
"bluebird": "3.5.1",
"debug": "3.1.0",
"regexp-clone": "^1.0.0",
"safe-buffer": "5.1.2",
"sliced": "1.0.1"
},
"engines": { "engines": {
"node": ">=4.0.0" "node": ">=20.19.0"
} }
}, },
"node_modules/mquery/node_modules/bluebird": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA=="
},
"node_modules/mquery/node_modules/debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/mquery/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"node_modules/mrmime": { "node_modules/mrmime": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz",
@@ -29799,11 +29873,6 @@
"resolved": "https://registry.npmjs.org/regex-parser/-/regex-parser-2.3.1.tgz", "resolved": "https://registry.npmjs.org/regex-parser/-/regex-parser-2.3.1.tgz",
"integrity": "sha512-yXLRqatcCuKtVHsWrNg0JL3l1zGfdXeEvDa0bdu4tCDQw0RpMDZsqbkyRTUnKMR0tXF627V2oEWjBEaEdqTwtQ==" "integrity": "sha512-yXLRqatcCuKtVHsWrNg0JL3l1zGfdXeEvDa0bdu4tCDQw0RpMDZsqbkyRTUnKMR0tXF627V2oEWjBEaEdqTwtQ=="
}, },
"node_modules/regexp-clone": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz",
"integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw=="
},
"node_modules/regexp.prototype.flags": { "node_modules/regexp.prototype.flags": {
"version": "1.5.4", "version": "1.5.4",
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz",
@@ -30236,15 +30305,6 @@
"uuid": "bin/uuid" "uuid": "bin/uuid"
} }
}, },
"node_modules/require_optional": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
"integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==",
"dependencies": {
"resolve-from": "^2.0.0",
"semver": "^5.1.0"
}
},
"node_modules/require-directory": { "node_modules/require-directory": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
@@ -30327,14 +30387,6 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/resolve-from": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz",
"integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/resolve-options": { "node_modules/resolve-options": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz", "resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz",
@@ -30787,18 +30839,6 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
}, },
"node_modules/saslprep": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz",
"integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
"optional": true,
"dependencies": {
"sparse-bitfield": "^3.0.3"
},
"engines": {
"node": ">=6"
}
},
"node_modules/sass": { "node_modules/sass": {
"version": "1.77.6", "version": "1.77.6",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.77.6.tgz", "resolved": "https://registry.npmjs.org/sass/-/sass-1.77.6.tgz",
@@ -31365,9 +31405,10 @@
} }
}, },
"node_modules/sift": { "node_modules/sift": {
"version": "7.0.1", "version": "17.1.3",
"resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", "resolved": "https://registry.npmjs.org/sift/-/sift-17.1.3.tgz",
"integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g==" "integrity": "sha512-Rtlj66/b0ICeFzYTuNvX/EF1igRbbnGSvEyT79McoZa/DeGhMyC5pWKOEsZKnpkqtSeovd5FL/bjHWC3CIIvCQ==",
"license": "MIT"
}, },
"node_modules/signal-exit": { "node_modules/signal-exit": {
"version": "3.0.7", "version": "3.0.7",
@@ -31531,11 +31572,6 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/sliced": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz",
"integrity": "sha512-VZBmZP8WU3sMOZm1bdgTadsQbcscK0UM8oKxKVBs4XAhUo2Xxzm/OFMGBkPusxw9xL3Uy8LrzEqGqJhclsr0yA=="
},
"node_modules/snapdragon": { "node_modules/snapdragon": {
"version": "0.8.2", "version": "0.8.2",
"resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
@@ -31820,7 +31856,7 @@
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
"integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==",
"optional": true, "license": "MIT",
"dependencies": { "dependencies": {
"memory-pager": "^1.0.2" "memory-pager": "^1.0.2"
} }
@@ -33511,6 +33547,27 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/tr46": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz",
"integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==",
"license": "MIT",
"dependencies": {
"punycode": "^2.3.1"
},
"engines": {
"node": ">=18"
}
},
"node_modules/tr46/node_modules/punycode": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/tracer": { "node_modules/tracer": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/tracer/-/tracer-1.0.1.tgz", "resolved": "https://registry.npmjs.org/tracer/-/tracer-1.0.1.tgz",
@@ -35125,6 +35182,15 @@
"resolved": "https://registry.npmjs.org/webgl-debug/-/webgl-debug-2.0.1.tgz", "resolved": "https://registry.npmjs.org/webgl-debug/-/webgl-debug-2.0.1.tgz",
"integrity": "sha512-G7BOpMmqdc31X1nb3eqwVxw/v1MNV/ulgw7Bs+7+a/sn+fC0d0OiMkerA55C6+3BL2vULyJ3kZLPcEL5GbXzhw==" "integrity": "sha512-G7BOpMmqdc31X1nb3eqwVxw/v1MNV/ulgw7Bs+7+a/sn+fC0d0OiMkerA55C6+3BL2vULyJ3kZLPcEL5GbXzhw=="
}, },
"node_modules/webidl-conversions": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
}
},
"node_modules/webpack": { "node_modules/webpack": {
"version": "5.105.4", "version": "5.105.4",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.105.4.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.105.4.tgz",
@@ -35659,6 +35725,19 @@
"node": ">=0.6.0" "node": ">=0.6.0"
} }
}, },
"node_modules/whatwg-url": {
"version": "14.2.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz",
"integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==",
"license": "MIT",
"dependencies": {
"tr46": "^5.1.0",
"webidl-conversions": "^7.0.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/whet.extend": { "node_modules/whet.extend": {
"version": "0.9.9", "version": "0.9.9",
"resolved": "https://registry.npmjs.org/whet.extend/-/whet.extend-0.9.9.tgz", "resolved": "https://registry.npmjs.org/whet.extend/-/whet.extend-0.9.9.tgz",
+2 -4
View File
@@ -88,8 +88,6 @@
"@types/howler": "^2.2.12", "@types/howler": "^2.2.12",
"@types/lodash": "^4.17.24", "@types/lodash": "^4.17.24",
"@types/mocha": "^10.0.10", "@types/mocha": "^10.0.10",
"@types/mongodb": "^3.3.1",
"@types/mongoose": "^5.5.15",
"@types/morgan": "^1.9.10", "@types/morgan": "^1.9.10",
"@types/node": "^25.5.0", "@types/node": "^25.5.0",
"@types/node-ipc": "^9.2.3", "@types/node-ipc": "^9.2.3",
@@ -121,7 +119,7 @@
"chai-as-promised": "^7.1.1", "chai-as-promised": "^7.1.1",
"chalk": "^2.4.2", "chalk": "^2.4.2",
"color-convert": "^2.0.1", "color-convert": "^2.0.1",
"connect-mongo": "^3.0.0", "connect-mongo": "^6.0.0",
"cookie-parser": "^1.4.4", "cookie-parser": "^1.4.4",
"core-js": "^3.2.1", "core-js": "^3.2.1",
"del": "^5.1.0", "del": "^5.1.0",
@@ -165,7 +163,7 @@
"merge2": "^1.2.4", "merge2": "^1.2.4",
"mocha": "^6.2.0", "mocha": "^6.2.0",
"moment": "^2.24.0", "moment": "^2.24.0",
"mongoose": "^5.6.11", "mongoose": "^9.3.2",
"morgan": "^1.9.1", "morgan": "^1.9.1",
"ngx-bootstrap": "^18.0.1", "ngx-bootstrap": "^18.0.1",
"passport": "^0.4.0", "passport": "^0.4.0",
+1 -1
View File
@@ -229,7 +229,7 @@ export async function removeFriend(accountId: string, friendId: string) {
const existing = await findFriendRequest(accountId, friendId); const existing = await findFriendRequest(accountId, friendId);
if (existing) { if (existing) {
existing.remove(); existing.deleteOne();
} }
} }
+3 -3
View File
@@ -289,12 +289,12 @@ export class AdminServerActions implements IAdminServerActions, SocketServer {
} }
@Method({ promise: true }) @Method({ promise: true })
async getPoniesCreators(account: string) { async getPoniesCreators(account: string) {
const items: ICharacter[] = await Character.find({ account }, '_id name creator').lean().exec(); const items = await Character.find({ account }, '_id name creator').lean<ICharacter[]>().exec();
return items.map(({ _id, name, creator }) => <PonyCreator>{ _id, name, creator }); return items.map(({ _id, name, creator }) => <PonyCreator>{ _id: _id.toString(), name, creator });
} }
@Method({ promise: true }) @Method({ promise: true })
async getPoniesForAccount(account: string) { async getPoniesForAccount(account: string) {
return await Character.find({ account }).lean().exec(); return await Character.find({ account }).lean().exec() as any;
} }
@Method({ promise: true }) @Method({ promise: true })
async getDetailsForAccount(accountId: string) { async getDetailsForAccount(accountId: string) {
+1 -1
View File
@@ -183,7 +183,7 @@ export async function removeAccount(service: AdminService, accountId: string) {
if (account) { if (account) {
checkIfNotAdmin(account, `remove account: ${accountId}`); checkIfNotAdmin(account, `remove account: ${accountId}`);
await account.remove(); await account.deleteOne();
service.removedItem('accounts', accountId); service.removedItem('accounts', accountId);
} }
+5 -4
View File
@@ -6,7 +6,7 @@ import {
} from '../../common/adminInterfaces'; } from '../../common/adminInterfaces';
import { execAsync } from '../serverUtils'; import { execAsync } from '../serverUtils';
import { import {
IAccount, Account, Origin, Event, iterate, ISession, Session, SupporterInvite as DBSupporterInvite, Account, Origin, Event, iterate, ISession, Session, SupporterInvite as DBSupporterInvite,
findAccount, ISupporterInvite, ID findAccount, ISupporterInvite, ID
} from '../db'; } from '../db';
import { servers, serverStatus, loginServers } from '../internal'; import { servers, serverStatus, loginServers } from '../internal';
@@ -157,7 +157,7 @@ export async function getChat(search: string, date: string, caseInsensitive: boo
} }
export async function getChatForAccounts(accountIds: string[], date: string) { export async function getChatForAccounts(accountIds: string[], date: string) {
const accounts: Partial<IAccount>[] = await Account.find({ _id: { $in: accountIds } }, '_id merges').lean().exec(); const accounts = await Account.find({ _id: { $in: accountIds } }, '_id merges').lean().exec();
const map = new Map<string, string>(); const map = new Map<string, string>();
const ids = flatten(accounts.map(a => [a._id.toString(), ...(a.merges || []).map(a => a.id)])); const ids = flatten(accounts.map(a => [a._id.toString(), ...(a.merges || []).map(a => a.id)]));
@@ -174,6 +174,7 @@ export async function getChatForAccounts(accountIds: string[], date: string) {
const fixed = chat.replace(/^([0-9:]+) \[([a-f0-9]{24})\]/gmu, (_, date, id) => const fixed = chat.replace(/^([0-9:]+) \[([a-f0-9]{24})\]/gmu, (_, date, id) =>
`${date} ${map.has(id) ? map.get(id) : `[${id}]`}`); `${date} ${map.has(id) ? map.get(id) : `[${id}]`}`);
return fixed; return fixed;
} }
@@ -187,11 +188,11 @@ export async function clearSessions(accountId: string) {
const user = data && data.passport && data.passport.user; const user = data && data.passport && data.passport.user;
if (user === accountId) { if (user === accountId) {
clearIds.push(session._id); clearIds.push(session._id.toString());
} }
} }
} catch (e) { } catch (e) {
logger.error('Error when claring session', e, session._id, session.session); logger.error('Error when clearing session', e, session._id, session.session);
} }
}); });
+7 -7
View File
@@ -137,19 +137,19 @@ async function merge(
Promise.all([ Promise.all([
SupporterInvite.updateMany({ source: merge._id }, { source: account._id }).exec(), SupporterInvite.updateMany({ source: merge._id }, { source: account._id }).exec(),
SupporterInvite.updateMany({ target: merge._id }, { target: account._id }).exec(), SupporterInvite.updateMany({ target: merge._id }, { target: account._id }).exec(),
]).then(() => SupporterInvite.remove({ target: account._id, source: account._id }).exec()), ]).then(() => SupporterInvite.deleteOne({ target: account._id, source: account._id }).exec()),
Promise.all([ Promise.all([
FriendRequest.updateMany({ source: merge._id }, { source: account._id }).exec(), FriendRequest.updateMany({ source: merge._id }, { source: account._id }).exec(),
FriendRequest.updateMany({ target: merge._id }, { target: account._id }).exec(), FriendRequest.updateMany({ target: merge._id }, { target: account._id }).exec(),
]).then(() => FriendRequest.remove({ target: account._id, source: account._id }).exec()), ]).then(() => FriendRequest.deleteOne({ target: account._id, source: account._id }).exec()),
Promise.all([ Promise.all([
HideRequest.updateMany({ source: merge._id }, { source: account._id }).exec(), HideRequest.updateMany({ source: merge._id }, { source: account._id }).exec(),
HideRequest.updateMany({ target: merge._id }, { target: account._id }).exec(), HideRequest.updateMany({ target: merge._id }, { target: account._id }).exec(),
]).then(() => HideRequest.remove({ target: account._id, source: account._id }).exec()), ]).then(() => HideRequest.deleteOne({ target: account._id, source: account._id }).exec()),
]); ]);
await removeDuplicateFriendRequests(id); await removeDuplicateFriendRequests(id);
await merge.remove(); await merge.deleteOne();
await kickFromAllServers(withId); await kickFromAllServers(withId);
await removedDocument('accounts', withId); await removedDocument('accounts', withId);
await updateCharacterCount(id); await updateCharacterCount(id);
@@ -175,7 +175,7 @@ async function removeDuplicateFriendRequests(id: string) {
} }
if (removeRequests.length) { if (removeRequests.length) {
await FriendRequest.remove({ _id: { $in: removeRequests } }).exec(); await FriendRequest.deleteOne({ _id: { $in: removeRequests } }).exec();
} }
} }
@@ -227,7 +227,7 @@ export async function split(
const friendsToRemove = [...(keep.friends || []), ...(split.friends || [])]; const friendsToRemove = [...(keep.friends || []), ...(split.friends || [])];
await FriendRequest.deleteMany({ await FriendRequest.deleteOne({
$or: [ $or: [
{ target: account._id, source: { $in: friendsToRemove } }, { target: account._id, source: { $in: friendsToRemove } },
{ source: account._id, target: { $in: friendsToRemove } }, { source: account._id, target: { $in: friendsToRemove } },
@@ -243,7 +243,7 @@ export async function split(
const hidesToRemove = [...(keep.hides || []), ...(split.hides || [])].map(hide => hide.id); const hidesToRemove = [...(keep.hides || []), ...(split.hides || [])].map(hide => hide.id);
await HideRequest.deleteMany({ await HideRequest.deleteOne({
$or: [ $or: [
{ source: account._id, target: { $in: hidesToRemove } }, { source: account._id, target: { $in: hidesToRemove } },
], ],
+2 -2
View File
@@ -75,7 +75,7 @@ export async function removeCharacter(service: AdminService, characterId: string
return; return;
await kickFromAllServersByCharacter(characterId); await kickFromAllServersByCharacter(characterId);
await character.remove(); await character.deleteOne();
await updateCharacterCount(character.account); await updateCharacterCount(character.account);
logRemovedCharacter(character); logRemovedCharacter(character);
service.ponies.removed(characterId); service.ponies.removed(characterId);
@@ -83,7 +83,7 @@ export async function removeCharacter(service: AdminService, characterId: string
async function removeCharacters(character: ICharacter[], accountId: string, removedDocument: RemovedDocument) { async function removeCharacters(character: ICharacter[], accountId: string, removedDocument: RemovedDocument) {
await Bluebird.map(character, async c => { await Bluebird.map(character, async c => {
await c.remove(); await c.deleteOne();
await removedDocument('ponies', c._id.toString()); await removedDocument('ponies', c._id.toString());
logRemovedCharacter(c); logRemovedCharacter(c);
}, { concurrency: 4 }); }, { concurrency: 4 });
+3 -3
View File
@@ -88,7 +88,7 @@ export const createSavePony =
character.desc = typeof data.desc === 'string' ? data.desc.substr(0, PLAYER_DESC_MAX_LENGTH) : ''; character.desc = typeof data.desc === 'string' ? data.desc.substr(0, PLAYER_DESC_MAX_LENGTH) : '';
character.name = data.name; character.name = data.name;
character.tag = data.tag; character.tag = data.tag;
character.site = auth ? auth._id : null; character.site = auth?._id;
character.info = info; character.info = info;
character.flags = flags; character.flags = flags;
character.lastUsed = new Date(); character.lastUsed = new Date();
@@ -115,9 +115,9 @@ export const createSavePony =
} }
if (created) { if (created) {
log(account._id, `created pony "${character.name}"`); log(account._id.toString(), `created pony "${character.name}"`);
} else if (nameChanged) { } else if (nameChanged) {
log(account._id, `renamed pony "${oldName}" => "${character.name}"`); log(account._id.toString(), `renamed pony "${oldName}" => "${character.name}"`);
} }
return toPonyObject(character); return toPonyObject(character);
+1 -1
View File
@@ -65,7 +65,7 @@ export async function updateAuthInfo(
} }
if (!auth.account && accountId) { if (!auth.account && accountId) {
changes.account = Types.ObjectId(accountId); changes.account = new Types.ObjectId(accountId);
} }
if (Object.keys(changes).length > 0) { if (Object.keys(changes).length > 0) {
+2 -2
View File
@@ -4,7 +4,7 @@ require('source-map-support').install();
import 'core-js/stable/promise/finally'; import 'core-js/stable/promise/finally';
import 'reflect-metadata'; import 'reflect-metadata';
import * as Promise from 'bluebird'; import * as Bluebird from 'bluebird';
import * as fs from 'fs'; import * as fs from 'fs';
import { argv } from 'yargs'; import { argv } from 'yargs';
@@ -16,4 +16,4 @@ import { argv } from 'yargs';
(global as any).TESTS = false; (global as any).TESTS = false;
(global as any).performance = Date; (global as any).performance = Date;
Promise.promisifyAll(fs); Bluebird.promisifyAll(fs);
+3 -2
View File
@@ -2,7 +2,7 @@ import { repeat } from 'lodash';
import { toByteArray } from 'base64-js'; import { toByteArray } from 'base64-js';
import { encodeString } from 'ag-sockets/dist/utf8'; import { encodeString } from 'ag-sockets/dist/utf8';
import { PonyOptions, EntityState, UpdateFlags } from '../common/interfaces'; import { PonyOptions, EntityState, UpdateFlags } from '../common/interfaces';
import { ICharacter, IAccount, Character, MongoQuery, queryCharacter } from './db'; import { ICharacter, IAccount, Character, queryCharacter } from './db';
import { isForbiddenName } from '../common/security'; import { isForbiddenName } from '../common/security';
import { supporterLevel } from '../common/adminUtils'; import { supporterLevel } from '../common/adminUtils';
import { CharacterFlags, CharacterState, ServerConfig, CharacterStateFlags } from '../common/adminInterfaces'; import { CharacterFlags, CharacterState, ServerConfig, CharacterStateFlags } from '../common/adminInterfaces';
@@ -22,6 +22,7 @@ import { saySystem } from './chat';
import { isPonyFlying } from '../common/entityUtils'; import { isPonyFlying } from '../common/entityUtils';
import { createCharacterState, updateClientCharacter } from './playerUtils'; import { createCharacterState, updateClientCharacter } from './playerUtils';
import { encodeExpression } from '../common/encoders/expressionEncoder'; import { encodeExpression } from '../common/encoders/expressionEncoder';
import { QueryFilter } from 'mongoose';
export const defaultCharacterState: CharacterState = { x: 0, y: 0 }; export const defaultCharacterState: CharacterState = { x: 0, y: 0 };
@@ -177,7 +178,7 @@ export function logRemovedCharacter({ _id, account, name, info }: ICharacter) {
log(systemMessage(`${account}`, `removed pony [${_id}] "${name}" ${info}`)); log(systemMessage(`${account}`, `removed pony [${_id}] "${name}" ${info}`));
} }
export async function swapCharacter(client: IClient, { server }: World, query: MongoQuery<ICharacter>) { export async function swapCharacter(client: IClient, { server }: World, query: QueryFilter<ICharacter>) {
if (client.isSwitchingMap) if (client.isSwitchingMap)
return; return;
+26 -27
View File
@@ -1,4 +1,4 @@
import { model, Schema, Types, Document, Query } from 'mongoose'; import { model, Schema, Types, Document, Query, QueryFilter, UpdateQuery } from 'mongoose';
import { import {
TimestampsBase, EventBase, CharacterBase, AccountBase, AuthBase, OriginBase, OriginInfoBase, CharacterState, TimestampsBase, EventBase, CharacterBase, AccountBase, AuthBase, OriginBase, OriginInfoBase, CharacterState,
SupporterInviteBase, FriendRequestBase, HideRequestBase, MergeHideData SupporterInviteBase, FriendRequestBase, HideRequestBase, MergeHideData
@@ -9,6 +9,7 @@ import { FriendData } from '../common/interfaces';
import { replaceEmojis } from '../common/emoji'; import { replaceEmojis } from '../common/emoji';
import { filterForbidden } from './characterUtils'; import { filterForbidden } from './characterUtils';
import { filterName } from '../common/swears'; import { filterName } from '../common/swears';
import { compact, noop } from 'lodash';
//set('debug', true); // debug mongoose //set('debug', true); // debug mongoose
@@ -205,13 +206,13 @@ export const Origin = model<IOrigin>('Origin', originSchema);
export const Session = model<ISession>('session', sessionSchema); export const Session = model<ISession>('session', sessionSchema);
export const Character = model<ICharacter>('Character', characterSchema); export const Character = model<ICharacter>('Character', characterSchema);
accountSchema.post('remove', function (doc: Document) { accountSchema.post('deleteOne', function (doc: Document) {
Promise.all([ Promise.all([
Character.deleteMany({ account: doc._id }).exec(), Character.deleteOne({ account: doc._id }).exec(),
Event.deleteMany({ account: doc._id }).exec(), Event.deleteOne({ account: doc._id }).exec(),
Auth.deleteMany({ account: doc._id }).exec(), Auth.deleteOne({ account: doc._id }).exec(),
FriendRequest.deleteMany({ $or: [{ target: doc._id }, { source: doc._id }] }).exec(), FriendRequest.deleteOne({ $or: [{ target: doc._id }, { source: doc._id }] }).exec(),
HideRequest.deleteMany({ $or: [{ target: doc._id }, { source: doc._id }] }).exec(), HideRequest.deleteOne({ $or: [{ target: doc._id }, { source: doc._id }] }).exec(),
]).catch(logger.error); ]).catch(logger.error);
}); });
@@ -249,15 +250,11 @@ export interface MongoUpdateExpr<T> extends MongoUpdateExprField<T> {
$addToSet?: any; $addToSet?: any;
} }
export type MongoQuery<T> = {
[P in keyof T]?: T[P] | MongoQueryExpr<T[P]>;
};
export type MongoUpdate<T> = { export type MongoUpdate<T> = {
[P in keyof T]?: T[P] | MongoUpdateExprField<T[P]>; [P in keyof T]?: T[P] | MongoUpdateExprField<T[P]>;
} & MongoUpdateExpr<T>; } & MongoUpdateExpr<T>;
export function iterate<T>(query: Query<T>, onData: (doc: T) => void) { export function iterate<T>(query: Query<T, T>, onData: (doc: T) => void) {
return new Promise<void>(resolve => { return new Promise<void>(resolve => {
query.cursor() query.cursor()
.on('data', onData) .on('data', onData)
@@ -290,7 +287,7 @@ export type FindCharacter = (characterId: ID, accountId: ID) => Promise<ICharact
export type FindCharacterSafe = (characterId: ID, accountId: ID) => Promise<ICharacter>; export type FindCharacterSafe = (characterId: ID, accountId: ID) => Promise<ICharacter>;
export type FindCharacters = (accountId: ID, fields?: string) => Promise<ICharacter[]>; export type FindCharacters = (accountId: ID, fields?: string) => Promise<ICharacter[]>;
export type UpdateCharacterState = (characterId: ID, serverName: string, state: CharacterState) => Promise<void>; export type UpdateCharacterState = (characterId: ID, serverName: string, state: CharacterState) => Promise<void>;
export type QueryCharacter = (query: MongoQuery<ICharacter>, fields?: string) => Promise<ICharacter | undefined>; export type QueryCharacter = (query: QueryFilter<ICharacter>, fields?: string) => Promise<ICharacter | undefined>;
export function createCharacter(account: IAccount) { export function createCharacter(account: IAccount) {
return new Character({ account: account._id, creator: `${account.name} [${account._id}]` }); return new Character({ account: account._id, creator: `${account.name} [${account._id}]` });
@@ -323,12 +320,13 @@ export function findLatestCharacters(account: ID, count: number): Promise<IChara
.exec(); .exec();
} }
export function removeCharacter(id: ID, account: ID): Promise<ICharacter | undefined> { export async function removeCharacter(id: ID, account: ID): Promise<ICharacter | undefined> {
return Character.findOneAndRemove({ _id: id, account }).exec().then(nullToUndefined); const doc = await Character.findOneAndDelete({ _id: id, account }).exec();
return doc ?? undefined;
} }
export const updateCharacterState: UpdateCharacterState = (characterId, serverName, state) => export const updateCharacterState: UpdateCharacterState = (characterId, serverName, state) =>
Character.updateOne({ _id: characterId }, { [`state.${serverName}`]: state }).exec().then(nullToUndefined); Character.updateOne({ _id: characterId }, { [`state.${serverName}`]: state }).exec().then(noop);
export const queryCharacter: QueryCharacter = (query, fields) => export const queryCharacter: QueryCharacter = (query, fields) =>
Character.findOne(query, fields).exec() as any; Character.findOne(query, fields).exec() as any;
@@ -338,8 +336,8 @@ export const queryCharacter: QueryCharacter = (query, fields) =>
export type FindAuth = (authId: ID, accountId: ID, fields?: string) => Promise<IAuth | undefined>; export type FindAuth = (authId: ID, accountId: ID, fields?: string) => Promise<IAuth | undefined>;
export type FindAuths = (accountId: ID, fields?: string) => Promise<IAuth[]>; export type FindAuths = (accountId: ID, fields?: string) => Promise<IAuth[]>;
export type CountAuths = (accountId: ID) => Promise<number>; export type CountAuths = (accountId: ID) => Promise<number>;
export type QueryAuths = (query: MongoQuery<IAuth>, fields?: string) => Promise<IAuth[]>; export type QueryAuths = (query: QueryFilter<IAuth>, fields?: string) => Promise<IAuth[]>;
export type UpdateAuth = (authId: ID, update: MongoUpdate<IAuth>) => Promise<void>; export type UpdateAuth = (authId: ID, update: UpdateQuery<IAuth>) => Promise<void>;
export const findAuthByOpenId = (openId: string, provider: string): Promise<IAuth | undefined> => export const findAuthByOpenId = (openId: string, provider: string): Promise<IAuth | undefined> =>
Auth.findOne({ openId, provider }).exec().then(nullToUndefined); Auth.findOne({ openId, provider }).exec().then(nullToUndefined);
@@ -363,22 +361,23 @@ export const queryAuths: QueryAuths = (query, fields) =>
Auth.find(query, fields).lean().exec(); Auth.find(query, fields).lean().exec();
export const updateAuth: UpdateAuth = (id, update) => export const updateAuth: UpdateAuth = (id, update) =>
Auth.updateOne({ _id: id }, update).exec(); Auth.updateOne({ _id: id }, update).exec().then(noop);
// accounts // accounts
export type FindAccountSafe = (accountId: ID, projection?: string) => Promise<IAccount>; export type FindAccountSafe = (accountId: ID, projection?: string) => Promise<IAccount>;
export type UpdateAccount = (accountId: ID, update: MongoUpdate<IAccount>) => Promise<void>; export type UpdateAccount = (accountId: ID, update: MongoUpdate<IAccount>) => Promise<void>;
export type UpdateAccounts = (query: MongoQuery<IAccount>, update: MongoUpdate<IAccount>) => Promise<void>; export type UpdateAccounts = (query: QueryFilter<IAccount>, update: MongoUpdate<IAccount>) => Promise<void>;
export type QueryAccounts = (query: MongoQuery<IAccount>, fields?: string) => Promise<IAccount[]>; export type QueryAccounts = (query: QueryFilter<IAccount>, fields?: string) => Promise<IAccount[]>;
export type QueryAccount = (query: MongoQuery<IAccount>, fields?: string) => Promise<IAccount | undefined>; export type QueryAccount = (query: QueryFilter<IAccount>, fields?: string) => Promise<IAccount | undefined>;
export const findAccount = (account: ID, projection?: string): Promise<IAccount | undefined> => export const findAccount = (account: ID, projection?: string): Promise<IAccount | undefined> =>
Account.findById(account, projection).exec().then(nullToUndefined); Account.findById(account, projection).exec().then(nullToUndefined);
export function checkIfAdmin(account: ID): Promise<boolean> { export function checkIfAdmin(account: ID): Promise<boolean> {
return Account.findOne({ _id: account }, 'roles').lean().exec() return Account.findOne({ _id: account }, 'roles').lean().exec()
.then(a => a && isAdmin(a)); .then(a => a && isAdmin(a)).then(r => !!r);
} }
export function findAccountSafe(account: ID, projection?: string): Promise<IAccount> { export function findAccountSafe(account: ID, projection?: string): Promise<IAccount> {
@@ -387,10 +386,10 @@ export function findAccountSafe(account: ID, projection?: string): Promise<IAcco
} }
export const updateAccount: UpdateAccount = (accountId, update) => export const updateAccount: UpdateAccount = (accountId, update) =>
Account.updateOne({ _id: accountId }, update).exec(); Account.updateOne({ _id: accountId }, update).exec().then(noop);
export const updateAccounts: UpdateAccounts = (query, update) => export const updateAccounts: UpdateAccounts = (query, update) =>
Account.updateMany(query, update).exec(); Account.updateMany(query, update).exec().then(noop);
export const queryAccounts: QueryAccounts = (query, fields) => export const queryAccounts: QueryAccounts = (query, fields) =>
Account.find(query, fields).lean().exec(); Account.find(query, fields).lean().exec();
@@ -428,8 +427,8 @@ export async function findFriends(accountId: ID, withCharacters: boolean): Promi
let characters: ICharacter[] = []; let characters: ICharacter[] = [];
if (withCharacters) { if (withCharacters) {
const characterIds = accounts.map(a => a.lastCharacter).filter(id => id); const characterIds = compact(accounts.map(a => a.lastCharacter?.toString()));
characters = await Character.find({ _id: { $in: characterIds } }, '_id name info').lean().exec(); characters = await Character.find({ _id: { $in: characterIds } }, '_id name info').lean<ICharacter[]>().exec();
} }
return accounts.map(a => { return accounts.map(a => {
+4 -4
View File
@@ -49,7 +49,7 @@ export function createLiveEndPoint<T extends Doc>(
.tap(item => { .tap(item => {
if (item) { if (item) {
removedItem(item._id.toString()); removedItem(item._id.toString());
return item.remove() as any; return item.deleteOne() as any;
} }
}) })
.tap(item => item && afterDelete && afterDelete(item)) .tap(item => item && afterDelete && afterDelete(item))
@@ -86,12 +86,12 @@ export function createLiveEndPoint<T extends Doc>(
function findItemsExact(date: Date): Promise<T[]> { function findItemsExact(date: Date): Promise<T[]> {
return Promise.resolve(model.find({ updatedAt: date }, fields.join(' ')) return Promise.resolve(model.find({ updatedAt: date }, fields.join(' '))
.lean() .lean<T[]>()
.exec()); .exec());
} }
function hasItem(items: T[], id: string) { function hasItem(items: T[], id: string) {
return items.some(i => i._id === id); return items.some(i => i._id.toString() === id);
} }
function addTailItems(items: T[]): Promise<{ items: T[]; more: boolean; }> { function addTailItems(items: T[]): Promise<{ items: T[]; more: boolean; }> {
@@ -108,7 +108,7 @@ export function createLiveEndPoint<T extends Doc>(
} }
return findItemsExact(items[items.length - 1].updatedAt) return findItemsExact(items[items.length - 1].updatedAt)
.then(other => other.filter(i => !hasItem(items, i._id))) .then(other => other.filter(i => !hasItem(items, i?._id.toString())))
.then(other => [...items, ...other]) .then(other => [...items, ...other])
.then(items => ({ items, more: true })); .then(items => ({ items, more: true }));
} }
+1 -1
View File
@@ -101,7 +101,7 @@ const cleanupStrayAuths = (removedDocument: RemovedDocument) =>
const date = fromNow(-1 * DAY); const date = fromNow(-1 * DAY);
const query = { account: { $exists: false }, updatedAt: { $lt: date }, createdAt: { $lt: date } }; const query = { account: { $exists: false }, updatedAt: { $lt: date }, createdAt: { $lt: date } };
const items = await queryAuths(query, '_id'); const items = await queryAuths(query, '_id');
await Auth.deleteMany(query).exec(); await Auth.deleteOne(query).exec();
await Bluebird.map(items, item => removedDocument('auths', item._id.toString()), { concurrency: 4 }); await Bluebird.map(items, item => removedDocument('auths', item._id.toString()), { concurrency: 4 });
logPerformance(`[async] cleanupAccountAlerts (${Date.now() - start}ms)`); logPerformance(`[async] cleanupAccountAlerts (${Date.now() - start}ms)`);
}; };
+3 -3
View File
@@ -1,7 +1,7 @@
import { Request } from 'express'; import { Request } from 'express';
import { truncate } from 'lodash'; import { truncate } from 'lodash';
import { Reporter } from './serverInterfaces'; import { Reporter } from './serverInterfaces';
import { Event, IEvent, IOriginInfo, ID, IAccount } from './db'; import { Event, IOriginInfo, ID, IAccount } from './db';
import { logger, system } from './logger'; import { logger, system } from './logger';
import { ServerConfig } from '../common/adminInterfaces'; import { ServerConfig } from '../common/adminInterfaces';
import { getOrigin } from './originUtils'; import { getOrigin } from './originUtils';
@@ -32,7 +32,7 @@ const createLogEvent =
return Event.updateOne({ _id: event._id }, { desc: event.desc, count: event.count + 1 }).exec(); return Event.updateOne({ _id: event._id }, { desc: event.desc, count: event.count + 1 }).exec();
} else { } else {
return Event.create(<IEvent>{ server, account, pony, type, message, origin, desc }); return Event.create({ server, account, pony, type, message, origin, desc }) as any;
} }
}) })
.catch(logger.error); .catch(logger.error);
@@ -97,7 +97,7 @@ export function create(server: ServerConfig, account?: ID, pony?: ID, originInfo
/* istanbul ignore next */ /* istanbul ignore next */
export function createFromRequest(server: ServerConfig, req: Request, pony?: any) { export function createFromRequest(server: ServerConfig, req: Request, pony?: any) {
const user = req && req.user as IAccount | undefined; const user = req && req.user as IAccount | undefined;
const account = user ? user.id : undefined; const account = user?._id?.toString();
const origin = req ? getOrigin(req) : undefined; const origin = req ? getOrigin(req) : undefined;
return create(server, account, pony, origin); return create(server, account, pony, origin);
} }
+1 -1
View File
@@ -27,7 +27,7 @@ export const validAccount = (server: ServerConfig): RequestHandler => (req, res,
const accountId = req.body.accountId as string; const accountId = req.body.accountId as string;
const accountName = req.body.accountName as string; const accountName = req.body.accountName as string;
if (!account || account.id !== accountId) { if (!account || account._id.toString() !== accountId) {
if (!/#$/.test(accountId)) { if (!/#$/.test(accountId)) {
createFromRequest(server, req).warn(ACCOUNT_ERROR, `${accountName} [${accountId}] (${req.path})`); createFromRequest(server, req).warn(ACCOUNT_ERROR, `${accountName} [${accountId}] (${req.path})`);
} }
+1 -1
View File
@@ -31,7 +31,7 @@ export default function (server: ServerConfig, settings: Settings, removedDocume
savePonyHandler(req.user as IAccount, req.body.pony, createFromRequest(server, req)))); savePonyHandler(req.user as IAccount, req.body.pony, createFromRequest(server, req))));
app.post('/pony/remove', offline, hash, validAccount, wrap(server, req => app.post('/pony/remove', offline, hash, validAccount, wrap(server, req =>
removePonyHandler(req.body.id, (req.user as IAccount).id))); removePonyHandler(req.body.id, (req.user as IAccount)?._id.toString())));
return app; return app;
} }
+1 -2
View File
@@ -1,5 +1,4 @@
import { Router } from 'express'; import { Router } from 'express';
import { noop } from 'lodash';
import { findAllCharacters, findAllVisibleAuths, IAccount, Account } from '../db'; import { findAllCharacters, findAllVisibleAuths, IAccount, Account } from '../db';
import { offline, hash, handleJSON } from '../requestUtils'; import { offline, hash, handleJSON } from '../requestUtils';
import { createGetAccountData } from '../api/account'; import { createGetAccountData } from '../api/account';
@@ -27,7 +26,7 @@ export default function (server: ServerConfig, settings: Settings) {
(lastBrowserId && account.lastBrowserId !== lastBrowserId)) { (lastBrowserId && account.lastBrowserId !== lastBrowserId)) {
account.lastUserAgent = lastUserAgent; account.lastUserAgent = lastUserAgent;
account.lastBrowserId = lastBrowserId; account.lastBrowserId = lastBrowserId;
Account.updateOne({ _id: account._id }, { lastUserAgent, lastBrowserId }, noop); Account.updateOne({ _id: account._id }, { lastUserAgent, lastBrowserId });
} }
return await getAccountData(account); return await getAccountData(account);
+10 -5
View File
@@ -84,8 +84,8 @@ const ignoreErrors = [
function kickCurrentUser(req: Request) { function kickCurrentUser(req: Request) {
const user = req.user as IAccount | undefined; const user = req.user as IAccount | undefined;
if (user) { if (user?._id) {
kickFromAllServers(user.id) kickFromAllServers(user._id?.toString())
.catch(e => logger.error(e)); .catch(e => logger.error(e));
} }
} }
@@ -97,7 +97,7 @@ function logIn(req: Request, account: IAccount) {
}); });
} }
function isMerge(accountId: string) { function isMerge(accountId: string | undefined) {
const minTime = fromNow(-10 * MINUTE).getTime(); const minTime = fromNow(-10 * MINUTE).getTime();
remove(mergeRequests, r => r.time < minTime); remove(mergeRequests, r => r.time < minTime);
return mergeRequests.some(r => r.accountId === accountId); return mergeRequests.some(r => r.accountId === accountId);
@@ -186,7 +186,7 @@ async function handleAuth(
req: Request, res: Response, error: Error | null, account: IAccount | null, req: Request, res: Response, error: Error | null, account: IAccount | null,
) { ) {
const user = req.user as IAccount | undefined; const user = req.user as IAccount | undefined;
const merge = isMerge(user && user.id); const merge = isMerge(user?._id?.toString());
try { try {
if (error) { if (error) {
@@ -359,7 +359,12 @@ export function authRoutes(
return [account._id.toString(), account.name]; return [account._id.toString(), account.name];
})); }));
passport.use(new LocalStrategy((login, _pass, done) => Account.findById(login, done))); passport.use(new LocalStrategy((login, _pass, done) =>
Account.findById(login)
.then(data => done(undefined, data as any))
.catch(e => done(e)))
);
app.get('/local', passport.authenticate('local', { successRedirect: '/', failureRedirect: '/failed-login' })); app.get('/local', passport.authenticate('local', { successRedirect: '/', failureRedirect: '/failed-login' }));
} }
+14 -11
View File
@@ -9,7 +9,7 @@ import * as expressSession from 'express-session';
import * as serveFavicon from 'serve-favicon'; import * as serveFavicon from 'serve-favicon';
import * as Rollbar from 'rollbar'; import * as Rollbar from 'rollbar';
import { Passport } from 'passport'; import { Passport } from 'passport';
import * as connectMongo from 'connect-mongo'; import MongoStore from 'connect-mongo';
import * as express from 'express'; import * as express from 'express';
import { WebSocketServer } from '@encharm/cws'; import { WebSocketServer } from '@encharm/cws';
import { compact, once } from 'lodash'; import { compact, once } from 'lodash';
@@ -67,14 +67,11 @@ function getServiceWorker() {
} }
} }
mongoose.connect(config.db, { const clientP = mongoose.connect(config.db, {
reconnectTries: Number.MAX_VALUE, autoIndex: true,
useNewUrlParser: true, serverSelectionTimeoutMS: 5000,
useCreateIndex: true, }).then(m => m.connection.getClient());
useFindAndModify: false,
});
const MongoStore = connectMongo(expressSession);
const app = express(); const app = express();
const production = app.get('env') === 'production'; const production = app.get('env') === 'production';
const maxAge = production ? YEAR : 0; const maxAge = production ? YEAR : 0;
@@ -163,8 +160,14 @@ app.use(require('cookie-parser')());
if (args.login || args.admin) { if (args.login || args.admin) {
passport.serializeUser<string>((account, done) => done(null, (account as IAccount)._id.toString())); passport.serializeUser<string>((account, done) => done(null, (account as IAccount)._id.toString()));
passport.deserializeUser<string>((id, done) => passport.deserializeUser<string>(async (id, done) => {
Account.findById(id, (err, a) => done(err, a && !isBanned(a) ? a : false))); try {
const account = await Account.findById(id).exec();
done(undefined, account && !isBanned(account) ? account : false);
} catch (error) {
done(error);
}
});
} }
const ignore = [ const ignore = [
@@ -198,7 +201,7 @@ const createSession = () => expressSession({
cookie: { cookie: {
maxAge: WEEK * 2, maxAge: WEEK * 2,
}, },
store: new MongoStore({ mongooseConnection: mongoose.connection }), store: new MongoStore({ client: clientP }),
}); });
const statsPath = pathTo('logs', `stats-${server.id}.csv`); const statsPath = pathTo('logs', `stats-${server.id}.csv`);
+4 -4
View File
@@ -96,12 +96,12 @@ export class SupporterInvitesService {
type LeanInvite = ISupporterInvite & { source: IAccount }; type LeanInvite = ISupporterInvite & { source: IAccount };
export async function updateSupporterInvites(model: Model<ISupporterInvite>) { export async function updateSupporterInvites(model: Model<ISupporterInvite>) {
const invites: LeanInvite[] = await model.find({}, '_id active') const invites = await model.find({}, '_id active')
.populate('source', '_id supporter patreon roles') .populate('source', '_id supporter patreon roles')
.lean() .lean<LeanInvite[]>()
.exec(); .exec();
const itemsBySource = toPairs(groupBy(invites, i => i.source._id as string)); const itemsBySource = toPairs(groupBy(invites, i => i.source._id));
const itemsToUpdate = itemsBySource const itemsToUpdate = itemsBySource
.map(([_, items]) => { .map(([_, items]) => {
const source = items[0].source; const source = items[0].source;
@@ -123,5 +123,5 @@ export async function updateSupporterInvites(model: Model<ISupporterInvite>) {
return model.updateMany({ _id: { $in: ids } }, { active }).exec(); return model.updateMany({ _id: { $in: ids } }, { active }).exec();
})); }));
await model.deleteMany({ active: false, updatedAt: { $lt: fromNow(-100 * DAY) } }).exec(); await model.deleteOne({ active: false, updatedAt: { $lt: fromNow(-100 * DAY) } }).exec();
} }
+3 -3
View File
@@ -62,7 +62,7 @@ export function genId() {
} }
export function genObjectId() { export function genObjectId() {
return Types.ObjectId(genId()); return new Types.ObjectId(genId());
} }
export function mockClient(fields: any = {}): IClient { export function mockClient(fields: any = {}): IClient {
@@ -81,8 +81,8 @@ export function mockClient(fields: any = {}): IClient {
friends: new Set<string>(), friends: new Set<string>(),
accountSettings: {}, accountSettings: {},
originalRequest: { headers: {} }, originalRequest: { headers: {} },
account: { id: accountId, _id: Types.ObjectId(accountId), ignores: [] }, account: { id: accountId, _id: new Types.ObjectId(accountId), ignores: [] },
character: { id: characterId, _id: Types.ObjectId(characterId) }, character: { id: characterId, _id: new Types.ObjectId(characterId) },
isMod: false, isMod: false,
pony, pony,
map: createServerMap('', 0, 1, 1), map: createServerMap('', 0, 1, 1),
+2 -2
View File
@@ -54,7 +54,7 @@ describe('api pony', () => {
describe('for existing character', () => { describe('for existing character', () => {
const characterId = genId(); const characterId = genId();
const characterObjectId = Types.ObjectId(characterId); const characterObjectId = new Types.ObjectId(characterId);
let character: ICharacter; let character: ICharacter;
let account = { _id: 'accid' } as any; let account = { _id: 'accid' } as any;
@@ -212,7 +212,7 @@ describe('api pony', () => {
beforeEach(() => { beforeEach(() => {
character = { character = {
_id: Types.ObjectId(characterId), _id: new Types.ObjectId(characterId),
save() { return this; } save() { return this; }
} as any; } as any;
+6 -6
View File
@@ -14,7 +14,7 @@ describe('authUtils', () => {
describe('updateAuthInfo()', () => { describe('updateAuthInfo()', () => {
it('updates url and name fields', async () => { it('updates url and name fields', async () => {
const updateAuth = stub(); const updateAuth = stub();
const a = auth({ _id: 'bar' }); const a = auth({ _id: new Types.ObjectId('bar') });
await updateAuthInfo(updateAuth, a, profile({ username: 'foo', url: 'bar' }), undefined); await updateAuthInfo(updateAuth, a, profile({ username: 'foo', url: 'bar' }), undefined);
@@ -33,7 +33,7 @@ describe('authUtils', () => {
it('updates email field (from empty)', async () => { it('updates email field (from empty)', async () => {
const updateAuth = stub(); const updateAuth = stub();
const a = auth({ _id: 'bar' }); const a = auth({ _id: new Types.ObjectId('bar') });
await updateAuthInfo(updateAuth, a, profile({ emails: ['b', 'c'] }), undefined); await updateAuthInfo(updateAuth, a, profile({ emails: ['b', 'c'] }), undefined);
@@ -44,7 +44,7 @@ describe('authUtils', () => {
it('saves updated auth', async () => { it('saves updated auth', async () => {
const updateAuth = stub(); const updateAuth = stub();
await updateAuthInfo(updateAuth, auth({ _id: 'bar' }), profile({ username: 'foo' }), undefined); await updateAuthInfo(updateAuth, auth({ _id: new Types.ObjectId('bar') }), profile({ username: 'foo' }), undefined);
assert.calledWith(updateAuth, 'bar', { name: 'foo' }); assert.calledWith(updateAuth, 'bar', { name: 'foo' });
}); });
@@ -55,20 +55,20 @@ describe('authUtils', () => {
await updateAuthInfo(stub(), a, profile({ username: 'foo', url: 'bar' }), accountId); await updateAuthInfo(stub(), a, profile({ username: 'foo', url: 'bar' }), accountId);
expect(a.account).eql(Types.ObjectId(accountId)); expect(a.account).eql(new Types.ObjectId(accountId));
}); });
it('does not save auth if nothing changed', async () => { it('does not save auth if nothing changed', async () => {
const updateAuth = stub(); const updateAuth = stub();
await updateAuthInfo(updateAuth, auth({ _id: 'bar', name: 'foo' }), profile({ username: 'foo' }), undefined); await updateAuthInfo(updateAuth, auth({ _id: new Types.ObjectId('bar'), name: 'foo' }), profile({ username: 'foo' }), undefined);
assert.notCalled(updateAuth); assert.notCalled(updateAuth);
}); });
it('does nothing if email list is the same', async () => { it('does nothing if email list is the same', async () => {
const updateAuth = stub(); const updateAuth = stub();
const a = auth({ _id: 'bar', emails: ['a', 'b'] }); const a = auth({ _id: new Types.ObjectId('bar'), emails: ['a', 'b'] });
await updateAuthInfo(updateAuth, a, profile({ emails: ['b', 'a'] }), undefined); await updateAuthInfo(updateAuth, a, profile({ emails: ['b', 'a'] }), undefined);
+10 -7
View File
@@ -12,13 +12,14 @@ import { createServerMap } from '../../server/serverMap';
import { CounterService } from '../../server/services/counter'; import { CounterService } from '../../server/services/counter';
import { createCharacterState } from '../../server/playerUtils'; import { createCharacterState } from '../../server/playerUtils';
import { hasFlag } from '../../common/utils'; import { hasFlag } from '../../common/utils';
import { Types } from 'mongoose';
describe('characterUtils', () => { describe('characterUtils', () => {
describe('createPony()', () => { describe('createPony()', () => {
const defaultState: CharacterState = { x: 0, y: 0, flags: 0 }; const defaultState: CharacterState = { x: 0, y: 0, flags: 0 };
it('creates pony entity', () => { it('creates pony entity', () => {
const pony = createPony(account({ _id: '' }), character({ name: 'foo' }), defaultState); const pony = createPony(account({ _id: new Types.ObjectId('') }), character({ name: 'foo' }), defaultState);
expect(pony).not.undefined; expect(pony).not.undefined;
expect(pony.type).equal(entities.pony.type); expect(pony.type).equal(entities.pony.type);
@@ -27,7 +28,7 @@ describe('characterUtils', () => {
it('sets initial position for character from state', () => { it('sets initial position for character from state', () => {
const main: CharacterState = { ...defaultState, x: 1, y: 2 }; const main: CharacterState = { ...defaultState, x: 1, y: 2 };
const pony = createPony(account({ _id: '' }), character({ name: 'foo' }), main); const pony = createPony(account({ _id: new Types.ObjectId('') }), character({ name: 'foo' }), main);
expect(pony.x).eql(1, 'x'); expect(pony.x).eql(1, 'x');
expect(pony.y).eql(2, 'y'); expect(pony.y).eql(2, 'y');
@@ -36,7 +37,7 @@ describe('characterUtils', () => {
it('sets facing from state', () => { it('sets facing from state', () => {
const main: CharacterState = { ...defaultState, flags: CharacterStateFlags.Right }; const main: CharacterState = { ...defaultState, flags: CharacterStateFlags.Right };
const pony = createPony(account({ _id: '' }), character({ name: 'foo' }), main); const pony = createPony(account({ _id: new Types.ObjectId('') }), character({ name: 'foo' }), main);
expect(pony.state).equal(EntityState.FacingRight); expect(pony.state).equal(EntityState.FacingRight);
}); });
@@ -44,7 +45,7 @@ describe('characterUtils', () => {
it('sets extra flag from state', () => { it('sets extra flag from state', () => {
const main: CharacterState = { ...defaultState, flags: CharacterStateFlags.Extra }; const main: CharacterState = { ...defaultState, flags: CharacterStateFlags.Extra };
const pony = createPony(account({ _id: '' }), character({ name: 'foo' }), main); const pony = createPony(account({ _id: new Types.ObjectId('') }), character({ name: 'foo' }), main);
expect(pony.options!.extra).true; expect(pony.options!.extra).true;
}); });
@@ -52,7 +53,7 @@ describe('characterUtils', () => {
it('sets held item from state', () => { it('sets held item from state', () => {
const main: CharacterState = { ...defaultState, hold: 'apple' }; const main: CharacterState = { ...defaultState, hold: 'apple' };
const pony = createPony(account({ _id: '' }), character({ name: 'foo' }), main); const pony = createPony(account({ _id: new Types.ObjectId('') }), character({ name: 'foo' }), main);
expect(pony.options!.hold).equal(entities.apple.type); expect(pony.options!.hold).equal(entities.apple.type);
}); });
@@ -60,7 +61,9 @@ describe('characterUtils', () => {
it('ignores held item from state if type is invalid', () => { it('ignores held item from state if type is invalid', () => {
const main: CharacterState = { ...defaultState, hold: 'does_not_exist' }; const main: CharacterState = { ...defaultState, hold: 'does_not_exist' };
const pony = createPony(account({ _id: '' }), character({ name: 'foo' }), main); const pony = createPony(account({ _id: new Types.ObjectId('')
}), character({ name: 'foo' }), main);
expect(pony.options!.hold).undefined; expect(pony.options!.hold).undefined;
}); });
@@ -143,7 +146,7 @@ describe('characterUtils', () => {
updatePony(entity1, account({ _id: genObjectId() }), character({ name: 'Foo', info: OFFLINE_PONY })); updatePony(entity1, account({ _id: genObjectId() }), character({ name: 'Foo', info: OFFLINE_PONY }));
updatePony( updatePony(
entity2, account({ _id: '' }), character({ name: 'Bar', info: 'DAT/AADapSD/1wC7Li42QAJkJEAT8ADAAxADhAYQFGAQAA==' })); entity2, account({ _id: new Types.ObjectId('') }), character({ name: 'Bar', info: 'DAT/AADapSD/1wC7Li42QAJkJEAT8ADAAxADhAYQFGAQAA==' }));
expect(entity1.canFly).false; expect(entity1.canFly).false;
expect(entity2.canFly).true; expect(entity2.canFly).true;
+2 -2
View File
@@ -99,7 +99,7 @@ describe('liveEndPoint', () => {
const find = stubFind([{ _id: 'aaa' }, { _id: 'bbb' }]); const find = stubFind([{ _id: 'aaa' }, { _id: 'bbb' }]);
return liveEndPoint.getAll() return liveEndPoint.getAll()
.then(() => assert.calledWithMatch(find, { updatedAt: { $gt: new Date(0) } }, '_id name desc')); .then(() => assert.calledWithMatch(find as any, { updatedAt: { $gt: new Date(0) } }, '_id name desc'));
}); });
it('passes given timestamp to find method', () => { it('passes given timestamp to find method', () => {
@@ -107,7 +107,7 @@ describe('liveEndPoint', () => {
const find = stubFind([{ _id: 'aaa' }, { _id: 'bbb' }]); const find = stubFind([{ _id: 'aaa' }, { _id: 'bbb' }]);
return liveEndPoint.getAll(timestamp) return liveEndPoint.getAll(timestamp)
.then(() => assert.calledWithMatch(find, { updatedAt: { $gt: new Date(timestamp) } }, '_id name desc')); .then(() => assert.calledWithMatch(find as any, { updatedAt: { $gt: new Date(timestamp) } }, '_id name desc'));
}); });
describe('if items exceed limit', () => { describe('if items exceed limit', () => {
+1 -1
View File
@@ -12,7 +12,7 @@ describe('originUtils', () => {
beforeEach(() => { beforeEach(() => {
clock = useFakeTimers(); clock = useFakeTimers();
update = stub(Account, 'update').returns({ exec: () => Promise.resolve() } as any); update = stub(Account as any, 'update').returns({ exec: () => Promise.resolve() } as any);
}); });
afterEach(() => { afterEach(() => {
+8 -8
View File
@@ -55,11 +55,11 @@ describe('serverUtils', () => {
const id = genId(); const id = genId();
expect(toPonyObject(character({ expect(toPonyObject(character({
_id: Types.ObjectId(id), _id: new Types.ObjectId(id),
name: 'foo', name: 'foo',
desc: 'aaa', desc: 'aaa',
info: 'info', info: 'info',
site: Types.ObjectId('000000000000000000000002'), site: new Types.ObjectId('000000000000000000000002'),
tag: 'tag', tag: 'tag',
lastUsed: new Date(123), lastUsed: new Date(123),
}))).eql({ }))).eql({
@@ -79,7 +79,7 @@ describe('serverUtils', () => {
const id = genId(); const id = genId();
expect(toPonyObject(character({ expect(toPonyObject(character({
_id: Types.ObjectId(id), _id: new Types.ObjectId(id),
name: 'foo', name: 'foo',
}))).eql({ }))).eql({
id: id, id: id,
@@ -96,7 +96,7 @@ describe('serverUtils', () => {
it('sets hide support field', () => { it('sets hide support field', () => {
const output = toPonyObject(character({ const output = toPonyObject(character({
_id: Types.ObjectId(genId()), _id: new Types.ObjectId(genId()),
name: 'foo', name: 'foo',
flags: CharacterFlags.HideSupport, flags: CharacterFlags.HideSupport,
})); }));
@@ -106,7 +106,7 @@ describe('serverUtils', () => {
it('sets respawn at spawn field', () => { it('sets respawn at spawn field', () => {
const output = toPonyObject(character({ const output = toPonyObject(character({
_id: Types.ObjectId(genId()), _id: new Types.ObjectId(genId()),
name: 'foo', name: 'foo',
flags: CharacterFlags.RespawnAtSpawn, flags: CharacterFlags.RespawnAtSpawn,
})); }));
@@ -124,11 +124,11 @@ describe('serverUtils', () => {
const id = genId(); const id = genId();
expect(toPonyObjectAdmin(character({ expect(toPonyObjectAdmin(character({
_id: Types.ObjectId(id), _id: new Types.ObjectId(id),
name: 'foo', name: 'foo',
desc: 'aaa', desc: 'aaa',
info: 'info', info: 'info',
site: Types.ObjectId('000000000000000000000001'), site: new Types.ObjectId('000000000000000000000001'),
tag: 'tag', tag: 'tag',
lastUsed: new Date(123), lastUsed: new Date(123),
creator: 'foo bar', creator: 'foo bar',
@@ -156,7 +156,7 @@ describe('serverUtils', () => {
const id = genId(); const id = genId();
expect(toSocialSite(auth({ expect(toSocialSite(auth({
_id: Types.ObjectId(id), _id: new Types.ObjectId(id),
name: 'foo', name: 'foo',
provider: 'github', provider: 'github',
url: 'foo.com', url: 'foo.com',
@@ -29,7 +29,6 @@ describe('SupporterInvitesService', () => {
countDocuments: stub(), countDocuments: stub(),
create: stub(), create: stub(),
deleteOne: stub(), deleteOne: stub(),
deleteMany: stub(),
updateMany: stub(), updateMany: stub(),
} as any; } as any;
log = stub(); log = stub();
@@ -43,7 +42,7 @@ describe('SupporterInvitesService', () => {
describe('getInvites()', () => { describe('getInvites()', () => {
it('returns all invites from given client', async () => { it('returns all invites from given client', async () => {
const client = mockClient(); const client = mockClient();
model.find.withArgs({ source: client.account._id }).returns({ model.find.withArgs({ source: client.account._id } as any).returns({
exec: stub().resolves([ exec: stub().resolves([
{ _id: 'foo', name: 'Foo', info: 'info', active: true, anotherField: 'xyz' }, { _id: 'foo', name: 'Foo', info: 'info', active: true, anotherField: 'xyz' },
]) ])
@@ -292,7 +291,7 @@ describe('SupporterInvitesService', () => {
await service.uninvite(requester, 'foobar'); await service.uninvite(requester, 'foobar');
assert.calledWithMatch(model.deleteOne, { _id: 'foobar', source: requester.account._id }); assert.calledWithMatch(model.deleteOne as any, { _id: 'foobar', source: requester.account._id });
}); });
}); });
@@ -312,12 +311,12 @@ describe('SupporterInvitesService', () => {
{ _id: 'aaa', active: false, source: { supporter: SupporterFlags.Supporter1 } }, { _id: 'aaa', active: false, source: { supporter: SupporterFlags.Supporter1 } },
{ _id: 'bbb', active: true, source: { supporter: SupporterFlags.Supporter1 } }, { _id: 'bbb', active: true, source: { supporter: SupporterFlags.Supporter1 } },
]; ];
model.find.withArgs({}, '_id active') model.find.withArgs({} as any, '_id active')
.returns({ .returns({
populate: stub().withArgs('source', '_id supporter patreon roles') populate: stub().withArgs('source', '_id supporter patreon roles')
.returns({ lean: stub().returns(exec(data)) }) .returns({ lean: stub().returns(exec(data)) })
} as any); } as any);
model.deleteMany.returns({ exec: stub() } as any); model.deleteOne.returns({ exec: stub() } as any);
model.updateMany.returns({ exec: stub() } as any); model.updateMany.returns({ exec: stub() } as any);
await updateSupporterInvites(model as any); await updateSupporterInvites(model as any);
@@ -331,7 +330,7 @@ describe('SupporterInvitesService', () => {
{ _id: 'bbb', active: true, source: {} }, { _id: 'bbb', active: true, source: {} },
]; ];
model.find.returns({ populate: stub().returns({ lean: stub().returns(exec(data)) }) } as any); model.find.returns({ populate: stub().returns({ lean: stub().returns(exec(data)) }) } as any);
model.deleteMany.returns({ exec: stub() } as any); model.deleteOne.returns({ exec: stub() } as any);
model.updateMany.returns({ exec: stub() } as any); model.updateMany.returns({ exec: stub() } as any);
await updateSupporterInvites(model as any); await updateSupporterInvites(model as any);
@@ -345,7 +344,7 @@ describe('SupporterInvitesService', () => {
{ _id: 'bbb', active: true, source: {} }, { _id: 'bbb', active: true, source: {} },
]; ];
model.find.returns({ populate: stub().returns({ lean: stub().returns(exec(data)) }) } as any); model.find.returns({ populate: stub().returns({ lean: stub().returns(exec(data)) }) } as any);
model.deleteMany.returns({ exec: stub() } as any); model.deleteOne.returns({ exec: stub() } as any);
model.updateMany.returns({ exec: stub() } as any); model.updateMany.returns({ exec: stub() } as any);
await updateSupporterInvites(model as any); await updateSupporterInvites(model as any);
@@ -360,7 +359,7 @@ describe('SupporterInvitesService', () => {
{ _id: 'bbb', active: false, source: {} }, { _id: 'bbb', active: false, source: {} },
]; ];
model.find.returns({ populate: stub().returns({ lean: stub().returns(exec(data)) }) } as any); model.find.returns({ populate: stub().returns({ lean: stub().returns(exec(data)) }) } as any);
model.deleteMany.returns({ exec: stub() } as any); model.deleteOne.returns({ exec: stub() } as any);
model.updateMany.returns({ exec: stub() } as any); model.updateMany.returns({ exec: stub() } as any);
await updateSupporterInvites(model as any); await updateSupporterInvites(model as any);
@@ -370,12 +369,12 @@ describe('SupporterInvitesService', () => {
it('removes old inactive entries', async () => { it('removes old inactive entries', async () => {
model.find.returns({ populate: stub().returns({ lean: stub().returns({ exec: stub() }) }) } as any); model.find.returns({ populate: stub().returns({ lean: stub().returns({ exec: stub() }) }) } as any);
model.deleteMany.returns({ exec: stub() } as any); model.deleteOne.returns({ exec: stub() } as any);
clock.setSystemTime(123 * DAY); clock.setSystemTime(123 * DAY);
await updateSupporterInvites(model as any); await updateSupporterInvites(model as any);
assert.calledWithMatch(model.deleteMany, { active: false, updatedAt: { $lt: new Date(23 * DAY) } }); assert.calledWithMatch(model.deleteOne as any, { active: false, updatedAt: { $lt: new Date(23 * DAY) } });
}); });
}); });
}); });