summaryrefslogtreecommitdiff
path: root/src/models/note.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-15 06:34:55 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-15 06:34:55 +0900
commit0ef280377bbbd357bef688ab5c7fd609fd78af72 (patch)
tree7745b237a21de429e828c6f007a59812894fabbf /src/models/note.ts
parenti18n (diff)
downloadsharkey-0ef280377bbbd357bef688ab5c7fd609fd78af72.tar.gz
sharkey-0ef280377bbbd357bef688ab5c7fd609fd78af72.tar.bz2
sharkey-0ef280377bbbd357bef688ab5c7fd609fd78af72.zip
wip
Diffstat (limited to 'src/models/note.ts')
-rw-r--r--src/models/note.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/models/note.ts b/src/models/note.ts
index 6d315db4cf..1dcc70c175 100644
--- a/src/models/note.ts
+++ b/src/models/note.ts
@@ -5,13 +5,13 @@ import db from '../db/mongodb';
import { IUser, pack as packUser } from './user';
import { pack as packApp } from './app';
import { pack as packChannel } from './channel';
-import Vote, { deletePollVote } from './poll-vote';
+import PollVote, { deletePollVote } from './poll-vote';
import Reaction, { deleteNoteReaction } from './note-reaction';
import { pack as packFile } from './drive-file';
import NoteWatching, { deleteNoteWatching } from './note-watching';
import NoteReaction from './note-reaction';
import Favorite, { deleteFavorite } from './favorite';
-import PollVote from './poll-vote';
+import Notification, { deleteNotification } from './notification';
const Note = db.get<INote>('notes');
@@ -123,6 +123,11 @@ export async function deleteNote(note: string | mongo.ObjectID | INote) {
await Favorite.find({ noteId: n._id })
).map(x => deleteFavorite(x)));
+ // この投稿に対するNotificationをすべて削除
+ await Promise.all((
+ await Notification.find({ noteId: n._id })
+ ).map(x => deleteNotification(x)));
+
// このNoteを削除
await Note.remove({
_id: n._id
@@ -258,7 +263,7 @@ export const pack = async (
// Poll
if (meId && _note.poll) {
_note.poll = (async (poll) => {
- const vote = await Vote
+ const vote = await PollVote
.findOne({
userId: meId,
noteId: id