diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-15 06:34:55 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-15 06:34:55 +0900 |
| commit | 0ef280377bbbd357bef688ab5c7fd609fd78af72 (patch) | |
| tree | 7745b237a21de429e828c6f007a59812894fabbf /src/models/notification.ts | |
| parent | i18n (diff) | |
| download | misskey-0ef280377bbbd357bef688ab5c7fd609fd78af72.tar.gz misskey-0ef280377bbbd357bef688ab5c7fd609fd78af72.tar.bz2 misskey-0ef280377bbbd357bef688ab5c7fd609fd78af72.zip | |
wip
Diffstat (limited to 'src/models/notification.ts')
| -rw-r--r-- | src/models/notification.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/models/notification.ts b/src/models/notification.ts index d5ca7135b7..76871166a9 100644 --- a/src/models/notification.ts +++ b/src/models/notification.ts @@ -50,6 +50,33 @@ export interface INotification { } /** + * Notificationを物理削除します + */ +export async function deleteNotification(notification: string | mongo.ObjectID | INotification) { + let n: INotification; + + // Populate + if (mongo.ObjectID.prototype.isPrototypeOf(notification)) { + n = await Notification.findOne({ + _id: notification + }); + } else if (typeof notification === 'string') { + n = await Notification.findOne({ + _id: new mongo.ObjectID(notification) + }); + } else { + n = notification as INotification; + } + + if (n == null) return; + + // このNotificationを削除 + await Notification.remove({ + _id: n._id + }); +} + +/** * Pack a notification for API response */ export const pack = (notification: any) => new Promise<any>(async (resolve, reject) => { |