mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #15261 from overleaf/csh-issue-11625-mongo-ug-5-chat
Upgrade mongodb module for chat from 4.11.0 to 6.1.0 GitOrigin-RevId: d4ce72b093fd09638a575a14f8945c8cb9ec7f3d
This commit is contained in:
parent
781a827e05
commit
b3b02941c7
11 changed files with 123 additions and 116 deletions
141
package-lock.json
generated
141
package-lock.json
generated
|
@ -6030,7 +6030,6 @@
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.0.tgz",
|
||||||
"integrity": "sha512-Xfijy7HvfzzqiOAhAepF4SGN5e9leLkMvg/OPOF97XemjfVCYN/oWa75wnkc6mltMSTwY+XlbhWgUOJmkFspSw==",
|
"integrity": "sha512-Xfijy7HvfzzqiOAhAepF4SGN5e9leLkMvg/OPOF97XemjfVCYN/oWa75wnkc6mltMSTwY+XlbhWgUOJmkFspSw==",
|
||||||
"devOptional": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"sparse-bitfield": "^3.0.3"
|
"sparse-bitfield": "^3.0.3"
|
||||||
}
|
}
|
||||||
|
@ -32173,8 +32172,7 @@
|
||||||
"node_modules/memory-pager": {
|
"node_modules/memory-pager": {
|
||||||
"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=="
|
||||||
"devOptional": true
|
|
||||||
},
|
},
|
||||||
"node_modules/mensch": {
|
"node_modules/mensch": {
|
||||||
"version": "0.3.4",
|
"version": "0.3.4",
|
||||||
|
@ -38353,7 +38351,6 @@
|
||||||
"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": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
|
"integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
|
||||||
"devOptional": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"memory-pager": "^1.0.2"
|
"memory-pager": "^1.0.2"
|
||||||
}
|
}
|
||||||
|
@ -42104,7 +42101,7 @@
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"exegesis-express": "^4.0.0",
|
"exegesis-express": "^4.0.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"mongodb": "^4.11.0"
|
"mongodb": "^6.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"acorn": "^7.1.1",
|
"acorn": "^7.1.1",
|
||||||
|
@ -42124,54 +42121,70 @@
|
||||||
"integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g=="
|
"integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g=="
|
||||||
},
|
},
|
||||||
"services/chat/node_modules/bson": {
|
"services/chat/node_modules/bson": {
|
||||||
"version": "4.7.2",
|
"version": "6.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/bson/-/bson-6.1.0.tgz",
|
||||||
"integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==",
|
"integrity": "sha512-yiQ3KxvpVoRpx1oD1uPz4Jit9tAVTJgjdmjDKtUErkOoL9VNoF8Dd58qtAOL5E40exx2jvAT9sqdRSK/r+SHlA==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.20.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"services/chat/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": {
|
"dependencies": {
|
||||||
"buffer": "^5.6.0"
|
"gaxios": "^5.0.0",
|
||||||
|
"json-bigint": "^1.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0"
|
"node": ">=12"
|
||||||
}
|
|
||||||
},
|
|
||||||
"services/chat/node_modules/buffer": {
|
|
||||||
"version": "5.7.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
|
||||||
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/feross"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "patreon",
|
|
||||||
"url": "https://www.patreon.com/feross"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "consulting",
|
|
||||||
"url": "https://feross.org/support"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"dependencies": {
|
|
||||||
"base64-js": "^1.3.1",
|
|
||||||
"ieee754": "^1.1.13"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"services/chat/node_modules/mongodb": {
|
"services/chat/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/clsi": {
|
"services/clsi": {
|
||||||
|
@ -49508,7 +49521,6 @@
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.0.tgz",
|
||||||
"integrity": "sha512-Xfijy7HvfzzqiOAhAepF4SGN5e9leLkMvg/OPOF97XemjfVCYN/oWa75wnkc6mltMSTwY+XlbhWgUOJmkFspSw==",
|
"integrity": "sha512-Xfijy7HvfzzqiOAhAepF4SGN5e9leLkMvg/OPOF97XemjfVCYN/oWa75wnkc6mltMSTwY+XlbhWgUOJmkFspSw==",
|
||||||
"devOptional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"sparse-bitfield": "^3.0.3"
|
"sparse-bitfield": "^3.0.3"
|
||||||
}
|
}
|
||||||
|
@ -50775,7 +50787,7 @@
|
||||||
"exegesis-express": "^4.0.0",
|
"exegesis-express": "^4.0.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"mocha": "^10.2.0",
|
"mocha": "^10.2.0",
|
||||||
"mongodb": "^4.11.0",
|
"mongodb": "^6.1.0",
|
||||||
"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",
|
||||||
|
@ -50788,32 +50800,29 @@
|
||||||
"integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g=="
|
"integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g=="
|
||||||
},
|
},
|
||||||
"bson": {
|
"bson": {
|
||||||
"version": "4.7.2",
|
"version": "6.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/bson/-/bson-6.1.0.tgz",
|
||||||
"integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==",
|
"integrity": "sha512-yiQ3KxvpVoRpx1oD1uPz4Jit9tAVTJgjdmjDKtUErkOoL9VNoF8Dd58qtAOL5E40exx2jvAT9sqdRSK/r+SHlA=="
|
||||||
"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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71374,8 +71383,7 @@
|
||||||
"memory-pager": {
|
"memory-pager": {
|
||||||
"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=="
|
||||||
"devOptional": true
|
|
||||||
},
|
},
|
||||||
"mensch": {
|
"mensch": {
|
||||||
"version": "0.3.4",
|
"version": "0.3.4",
|
||||||
|
@ -76290,7 +76298,6 @@
|
||||||
"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": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
|
"integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
|
||||||
"devOptional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"memory-pager": "^1.0.2"
|
"memory-pager": "^1.0.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ export async function updateMessage(
|
||||||
room_id: roomId,
|
room_id: roomId,
|
||||||
})
|
})
|
||||||
if (userId) {
|
if (userId) {
|
||||||
query.user_id = ObjectId(userId)
|
query.user_id = new ObjectId(userId)
|
||||||
}
|
}
|
||||||
const res = await db.messages.updateOne(query, {
|
const res = await db.messages.updateOne(query, {
|
||||||
$set: {
|
$set: {
|
||||||
|
@ -75,13 +75,13 @@ export async function deleteMessage(roomId, messageId) {
|
||||||
|
|
||||||
function _ensureIdsAreObjectIds(query) {
|
function _ensureIdsAreObjectIds(query) {
|
||||||
if (query.user_id && !(query.user_id instanceof ObjectId)) {
|
if (query.user_id && !(query.user_id instanceof ObjectId)) {
|
||||||
query.user_id = ObjectId(query.user_id)
|
query.user_id = new ObjectId(query.user_id)
|
||||||
}
|
}
|
||||||
if (query.room_id && !(query.room_id instanceof ObjectId)) {
|
if (query.room_id && !(query.room_id instanceof ObjectId)) {
|
||||||
query.room_id = ObjectId(query.room_id)
|
query.room_id = new ObjectId(query.room_id)
|
||||||
}
|
}
|
||||||
if (query._id && !(query._id instanceof ObjectId)) {
|
if (query._id && !(query._id instanceof ObjectId)) {
|
||||||
query._id = ObjectId(query._id)
|
query._id = new ObjectId(query._id)
|
||||||
}
|
}
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ export const GLOBAL_THREAD = 'GLOBAL'
|
||||||
|
|
||||||
export async function findOrCreateThread(projectId, threadId) {
|
export async function findOrCreateThread(projectId, threadId) {
|
||||||
let query, update
|
let query, update
|
||||||
projectId = ObjectId(projectId.toString())
|
projectId = new ObjectId(projectId.toString())
|
||||||
if (threadId !== GLOBAL_THREAD) {
|
if (threadId !== GLOBAL_THREAD) {
|
||||||
threadId = ObjectId(threadId.toString())
|
threadId = new ObjectId(threadId.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threadId === GLOBAL_THREAD) {
|
if (threadId === GLOBAL_THREAD) {
|
||||||
|
@ -33,14 +33,14 @@ export async function findOrCreateThread(projectId, threadId) {
|
||||||
{ $set: update },
|
{ $set: update },
|
||||||
{ upsert: true, returnDocument: 'after' }
|
{ upsert: true, returnDocument: 'after' }
|
||||||
)
|
)
|
||||||
return result.value
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function findAllThreadRooms(projectId) {
|
export async function findAllThreadRooms(projectId) {
|
||||||
return db.rooms
|
return db.rooms
|
||||||
.find(
|
.find(
|
||||||
{
|
{
|
||||||
project_id: ObjectId(projectId.toString()),
|
project_id: new ObjectId(projectId.toString()),
|
||||||
thread_id: { $exists: true },
|
thread_id: { $exists: true },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ export async function findAllThreadRoomsAndGlobalThread(projectId) {
|
||||||
return db.rooms
|
return db.rooms
|
||||||
.find(
|
.find(
|
||||||
{
|
{
|
||||||
project_id: ObjectId(projectId.toString()),
|
project_id: new ObjectId(projectId.toString()),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
thread_id: 1,
|
thread_id: 1,
|
||||||
|
@ -68,8 +68,8 @@ export async function findAllThreadRoomsAndGlobalThread(projectId) {
|
||||||
export async function resolveThread(projectId, threadId, userId) {
|
export async function resolveThread(projectId, threadId, userId) {
|
||||||
await db.rooms.updateOne(
|
await db.rooms.updateOne(
|
||||||
{
|
{
|
||||||
project_id: ObjectId(projectId.toString()),
|
project_id: new ObjectId(projectId.toString()),
|
||||||
thread_id: ObjectId(threadId.toString()),
|
thread_id: new ObjectId(threadId.toString()),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
|
@ -85,8 +85,8 @@ export async function resolveThread(projectId, threadId, userId) {
|
||||||
export async function reopenThread(projectId, threadId) {
|
export async function reopenThread(projectId, threadId) {
|
||||||
await db.rooms.updateOne(
|
await db.rooms.updateOne(
|
||||||
{
|
{
|
||||||
project_id: ObjectId(projectId.toString()),
|
project_id: new ObjectId(projectId.toString()),
|
||||||
thread_id: ObjectId(threadId.toString()),
|
thread_id: new ObjectId(threadId.toString()),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$unset: {
|
$unset: {
|
||||||
|
@ -106,6 +106,6 @@ export async function deleteThread(projectId, threadId) {
|
||||||
|
|
||||||
export async function deleteAllThreadsInProject(projectId) {
|
export async function deleteAllThreadsInProject(projectId) {
|
||||||
await db.rooms.deleteMany({
|
await db.rooms.deleteMany({
|
||||||
project_id: ObjectId(projectId.toString()),
|
project_id: new ObjectId(projectId.toString()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"exegesis-express": "^4.0.0",
|
"exegesis-express": "^4.0.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"mongodb": "^4.11.0"
|
"mongodb": "^6.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"acorn": "^7.1.1",
|
"acorn": "^7.1.1",
|
||||||
|
|
|
@ -5,9 +5,9 @@ import * as ChatClient from './helpers/ChatClient.js'
|
||||||
import * as ChatApp from './helpers/ChatApp.js'
|
import * as ChatApp from './helpers/ChatApp.js'
|
||||||
|
|
||||||
describe('Deleting a message', async function () {
|
describe('Deleting a message', async function () {
|
||||||
const projectId = ObjectId().toString()
|
const projectId = new ObjectId().toString()
|
||||||
const userId = ObjectId().toString()
|
const userId = new ObjectId().toString()
|
||||||
const threadId = ObjectId().toString()
|
const threadId = new ObjectId().toString()
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
await ChatApp.ensureRunning()
|
await ChatApp.ensureRunning()
|
||||||
|
|
|
@ -5,14 +5,14 @@ import * as ChatClient from './helpers/ChatClient.js'
|
||||||
import * as ChatApp from './helpers/ChatApp.js'
|
import * as ChatApp from './helpers/ChatApp.js'
|
||||||
|
|
||||||
describe('Deleting a thread', async function () {
|
describe('Deleting a thread', async function () {
|
||||||
const projectId = ObjectId().toString()
|
const projectId = new ObjectId().toString()
|
||||||
const userId = ObjectId().toString()
|
const userId = new ObjectId().toString()
|
||||||
before(async function () {
|
before(async function () {
|
||||||
await ChatApp.ensureRunning()
|
await ChatApp.ensureRunning()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with a thread that is deleted', async function () {
|
describe('with a thread that is deleted', async function () {
|
||||||
const threadId = ObjectId().toString()
|
const threadId = new ObjectId().toString()
|
||||||
const content = 'deleted thread message'
|
const content = 'deleted thread message'
|
||||||
before(async function () {
|
before(async function () {
|
||||||
const { response } = await ChatClient.sendMessage(
|
const { response } = await ChatClient.sendMessage(
|
||||||
|
|
|
@ -8,19 +8,19 @@ const db = ChatApp.db
|
||||||
|
|
||||||
async function getMessage(messageId) {
|
async function getMessage(messageId) {
|
||||||
return await db.messages.findOne({
|
return await db.messages.findOne({
|
||||||
_id: ObjectId(messageId),
|
_id: new ObjectId(messageId),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Destroying a project', async function () {
|
describe('Destroying a project', async function () {
|
||||||
const projectId = ObjectId().toString()
|
const projectId = new ObjectId().toString()
|
||||||
const userId = ObjectId().toString()
|
const userId = new ObjectId().toString()
|
||||||
before(async function () {
|
before(async function () {
|
||||||
await ChatApp.ensureRunning()
|
await ChatApp.ensureRunning()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with a project that has threads and messages', async function () {
|
describe('with a project that has threads and messages', async function () {
|
||||||
const threadId = ObjectId().toString()
|
const threadId = new ObjectId().toString()
|
||||||
before(async function () {
|
before(async function () {
|
||||||
const { response } = await ChatClient.sendMessage(
|
const { response } = await ChatClient.sendMessage(
|
||||||
projectId,
|
projectId,
|
||||||
|
@ -39,7 +39,7 @@ describe('Destroying a project', async function () {
|
||||||
this.globalThreadMessageId = response2.body.id
|
this.globalThreadMessageId = response2.body.id
|
||||||
|
|
||||||
const threadRooms = await db.rooms
|
const threadRooms = await db.rooms
|
||||||
.find({ project_id: ObjectId(projectId) })
|
.find({ project_id: new ObjectId(projectId) })
|
||||||
.toArray()
|
.toArray()
|
||||||
expect(threadRooms.length).to.equal(2)
|
expect(threadRooms.length).to.equal(2)
|
||||||
const threadMessage = await getMessage(this.threadMessageId)
|
const threadMessage = await getMessage(this.threadMessageId)
|
||||||
|
@ -55,7 +55,7 @@ describe('Destroying a project', async function () {
|
||||||
|
|
||||||
it('should remove the messages and threads from the database', async function () {
|
it('should remove the messages and threads from the database', async function () {
|
||||||
const threadRooms = await db.rooms
|
const threadRooms = await db.rooms
|
||||||
.find({ project_id: ObjectId(projectId) })
|
.find({ project_id: new ObjectId(projectId) })
|
||||||
.toArray()
|
.toArray()
|
||||||
expect(threadRooms.length).to.equal(0)
|
expect(threadRooms.length).to.equal(0)
|
||||||
const threadMessage = await getMessage(this.threadMessageId)
|
const threadMessage = await getMessage(this.threadMessageId)
|
||||||
|
|
|
@ -15,9 +15,9 @@ describe('Editing a message', async function () {
|
||||||
const newContent = 'updated thread message'
|
const newContent = 'updated thread message'
|
||||||
let messageId
|
let messageId
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
projectId = ObjectId().toString()
|
projectId = new ObjectId().toString()
|
||||||
userId = ObjectId().toString()
|
userId = new ObjectId().toString()
|
||||||
threadId = ObjectId().toString()
|
threadId = new ObjectId().toString()
|
||||||
|
|
||||||
const { response, body: message } = await ChatClient.sendMessage(
|
const { response, body: message } = await ChatClient.sendMessage(
|
||||||
projectId,
|
projectId,
|
||||||
|
@ -80,7 +80,7 @@ describe('Editing a message', async function () {
|
||||||
projectId,
|
projectId,
|
||||||
threadId,
|
threadId,
|
||||||
messageId,
|
messageId,
|
||||||
ObjectId(),
|
new ObjectId(),
|
||||||
newContent
|
newContent
|
||||||
)
|
)
|
||||||
expect(response.statusCode).to.equal(404)
|
expect(response.statusCode).to.equal(404)
|
||||||
|
|
|
@ -15,8 +15,8 @@ async function getCount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Getting messages', async function () {
|
describe('Getting messages', async function () {
|
||||||
const userId1 = ObjectId().toString()
|
const userId1 = new ObjectId().toString()
|
||||||
const userId2 = ObjectId().toString()
|
const userId2 = new ObjectId().toString()
|
||||||
const content1 = 'foo bar'
|
const content1 = 'foo bar'
|
||||||
const content2 = 'hello world'
|
const content2 = 'hello world'
|
||||||
before(async function () {
|
before(async function () {
|
||||||
|
@ -24,7 +24,7 @@ describe('Getting messages', async function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('globally', async function () {
|
describe('globally', async function () {
|
||||||
const projectId = ObjectId().toString()
|
const projectId = new ObjectId().toString()
|
||||||
before(async function () {
|
before(async function () {
|
||||||
const previousCount = await getCount()
|
const previousCount = await getCount()
|
||||||
const { response } = await ChatClient.sendGlobalMessage(
|
const { response } = await ChatClient.sendGlobalMessage(
|
||||||
|
@ -60,9 +60,9 @@ describe('Getting messages', async function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('from all the threads', async function () {
|
describe('from all the threads', async function () {
|
||||||
const projectId = ObjectId().toString()
|
const projectId = new ObjectId().toString()
|
||||||
const threadId1 = ObjectId().toString()
|
const threadId1 = new ObjectId().toString()
|
||||||
const threadId2 = ObjectId().toString()
|
const threadId2 = new ObjectId().toString()
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
const { response } = await ChatClient.sendMessage(
|
const { response } = await ChatClient.sendMessage(
|
||||||
|
|
|
@ -5,14 +5,14 @@ import * as ChatClient from './helpers/ChatClient.js'
|
||||||
import * as ChatApp from './helpers/ChatApp.js'
|
import * as ChatApp from './helpers/ChatApp.js'
|
||||||
|
|
||||||
describe('Resolving a thread', async function () {
|
describe('Resolving a thread', async function () {
|
||||||
const projectId = ObjectId().toString()
|
const projectId = new ObjectId().toString()
|
||||||
const userId = ObjectId().toString()
|
const userId = new ObjectId().toString()
|
||||||
before(async function () {
|
before(async function () {
|
||||||
await ChatApp.ensureRunning()
|
await ChatApp.ensureRunning()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('with a resolved thread', async function () {
|
describe('with a resolved thread', async function () {
|
||||||
const threadId = ObjectId().toString()
|
const threadId = new ObjectId().toString()
|
||||||
const content = 'resolved message'
|
const content = 'resolved message'
|
||||||
before(async function () {
|
before(async function () {
|
||||||
const { response } = await ChatClient.sendMessage(
|
const { response } = await ChatClient.sendMessage(
|
||||||
|
@ -41,7 +41,7 @@ describe('Resolving a thread', async function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('when a thread is not resolved', async function () {
|
describe('when a thread is not resolved', async function () {
|
||||||
const threadId = ObjectId().toString()
|
const threadId = new ObjectId().toString()
|
||||||
const content = 'open message'
|
const content = 'open message'
|
||||||
before(async function () {
|
before(async function () {
|
||||||
const { response } = await ChatClient.sendMessage(
|
const { response } = await ChatClient.sendMessage(
|
||||||
|
@ -61,7 +61,7 @@ describe('Resolving a thread', async function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('when a thread is resolved then reopened', async function () {
|
describe('when a thread is resolved then reopened', async function () {
|
||||||
const threadId = ObjectId().toString()
|
const threadId = new ObjectId().toString()
|
||||||
const content = 'resolved message'
|
const content = 'resolved message'
|
||||||
before(async function () {
|
before(async function () {
|
||||||
const { response } = await ChatClient.sendMessage(
|
const { response } = await ChatClient.sendMessage(
|
||||||
|
|
|
@ -10,8 +10,8 @@ describe('Sending a message', async function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('globally', async function () {
|
describe('globally', async function () {
|
||||||
const projectId = ObjectId().toString()
|
const projectId = new ObjectId().toString()
|
||||||
const userId = ObjectId().toString()
|
const userId = new ObjectId().toString()
|
||||||
const content = 'global message'
|
const content = 'global message'
|
||||||
before(async function () {
|
before(async function () {
|
||||||
const { response, body } = await ChatClient.sendGlobalMessage(
|
const { response, body } = await ChatClient.sendGlobalMessage(
|
||||||
|
@ -36,9 +36,9 @@ describe('Sending a message', async function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('to a thread', async function () {
|
describe('to a thread', async function () {
|
||||||
const projectId = ObjectId().toString()
|
const projectId = new ObjectId().toString()
|
||||||
const userId = ObjectId().toString()
|
const userId = new ObjectId().toString()
|
||||||
const threadId = ObjectId().toString()
|
const threadId = new ObjectId().toString()
|
||||||
const content = 'thread message'
|
const content = 'thread message'
|
||||||
before(async function () {
|
before(async function () {
|
||||||
const { response, body } = await ChatClient.sendMessage(
|
const { response, body } = await ChatClient.sendMessage(
|
||||||
|
@ -70,9 +70,9 @@ describe('Sending a message', async function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('failure cases', async function () {
|
describe('failure cases', async function () {
|
||||||
const projectId = ObjectId().toString()
|
const projectId = new ObjectId().toString()
|
||||||
const userId = ObjectId().toString()
|
const userId = new ObjectId().toString()
|
||||||
const threadId = ObjectId().toString()
|
const threadId = new ObjectId().toString()
|
||||||
|
|
||||||
describe('with a malformed userId', async function () {
|
describe('with a malformed userId', async function () {
|
||||||
it('should return a graceful error', async function () {
|
it('should return a graceful error', async function () {
|
||||||
|
|
Loading…
Reference in a new issue