diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-16 11:38:09 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-16 11:38:09 +0900 |
| commit | 9427a756c9e4a1d95210ccfca56fdb67d62183ec (patch) | |
| tree | 667cf5f4d6ecf80d0e3a22c4085a410537d1dc9d /src/server/api/common | |
| parent | fix(package): update @types/node to version 10.12.0 (#2912) (diff) | |
| download | sharkey-9427a756c9e4a1d95210ccfca56fdb67d62183ec.tar.gz sharkey-9427a756c9e4a1d95210ccfca56fdb67d62183ec.tar.bz2 sharkey-9427a756c9e4a1d95210ccfca56fdb67d62183ec.zip | |
Update mongodb
Diffstat (limited to 'src/server/api/common')
| -rw-r--r-- | src/server/api/common/read-messaging-message.ts | 9 | ||||
| -rw-r--r-- | src/server/api/common/read-notification.ts | 7 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/server/api/common/read-messaging-message.ts b/src/server/api/common/read-messaging-message.ts index 075e369832..63080d22a4 100644 --- a/src/server/api/common/read-messaging-message.ts +++ b/src/server/api/common/read-messaging-message.ts @@ -1,4 +1,5 @@ import * as mongo from 'mongodb'; +import isObjectId from '../../../misc/is-objectid'; import Message from '../../../models/messaging-message'; import { IMessagingMessage as IMessage } from '../../../models/messaging-message'; import { publishMainStream } from '../../../stream'; @@ -15,21 +16,21 @@ export default ( message: string | string[] | IMessage | IMessage[] | mongo.ObjectID | mongo.ObjectID[] ) => new Promise<any>(async (resolve, reject) => { - const userId = mongo.ObjectID.prototype.isPrototypeOf(user) + const userId = isObjectId(user) ? user : new mongo.ObjectID(user); - const otherpartyId = mongo.ObjectID.prototype.isPrototypeOf(otherparty) + const otherpartyId = isObjectId(otherparty) ? otherparty : new mongo.ObjectID(otherparty); const ids: mongo.ObjectID[] = Array.isArray(message) - ? mongo.ObjectID.prototype.isPrototypeOf(message[0]) + ? isObjectId(message[0]) ? (message as mongo.ObjectID[]) : typeof message[0] === 'string' ? (message as string[]).map(m => new mongo.ObjectID(m)) : (message as IMessage[]).map(m => m._id) - : mongo.ObjectID.prototype.isPrototypeOf(message) + : isObjectId(message) ? [(message as mongo.ObjectID)] : typeof message === 'string' ? [new mongo.ObjectID(message)] diff --git a/src/server/api/common/read-notification.ts b/src/server/api/common/read-notification.ts index 2d58ada4ce..27d3f1be32 100644 --- a/src/server/api/common/read-notification.ts +++ b/src/server/api/common/read-notification.ts @@ -1,4 +1,5 @@ import * as mongo from 'mongodb'; +import isObjectId from '../../../misc/is-objectid'; import { default as Notification, INotification } from '../../../models/notification'; import { publishMainStream } from '../../../stream'; import Mute from '../../../models/mute'; @@ -12,17 +13,17 @@ export default ( message: string | string[] | INotification | INotification[] | mongo.ObjectID | mongo.ObjectID[] ) => new Promise<any>(async (resolve, reject) => { - const userId = mongo.ObjectID.prototype.isPrototypeOf(user) + const userId = isObjectId(user) ? user : new mongo.ObjectID(user); const ids: mongo.ObjectID[] = Array.isArray(message) - ? mongo.ObjectID.prototype.isPrototypeOf(message[0]) + ? isObjectId(message[0]) ? (message as mongo.ObjectID[]) : typeof message[0] === 'string' ? (message as string[]).map(m => new mongo.ObjectID(m)) : (message as INotification[]).map(m => m._id) - : mongo.ObjectID.prototype.isPrototypeOf(message) + : isObjectId(message) ? [(message as mongo.ObjectID)] : typeof message === 'string' ? [new mongo.ObjectID(message)] |