This commit is contained in:
syuilo
2018-04-15 06:34:55 +09:00
parent 9c2f340c1e
commit 0ef280377b
3 changed files with 46 additions and 3 deletions

View File

@@ -49,6 +49,33 @@ export interface INotification {
isRead: Boolean;
}
/**
* 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
*/