diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2018-04-15 18:12:11 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-15 18:12:11 +0900 |
| commit | f982f5e850d1096d54014396b3ee9d337e305bcb (patch) | |
| tree | 0dae4116aa5d7c3fe6c5eba54af6f9f15a271761 /src/models/note.ts | |
| parent | Merge pull request #4 from syuilo/master (diff) | |
| parent | nanka iroiro (diff) | |
| download | misskey-f982f5e850d1096d54014396b3ee9d337e305bcb.tar.gz misskey-f982f5e850d1096d54014396b3ee9d337e305bcb.tar.bz2 misskey-f982f5e850d1096d54014396b3ee9d337e305bcb.zip | |
Merge pull request #5 from syuilo/master
追従
Diffstat (limited to 'src/models/note.ts')
| -rw-r--r-- | src/models/note.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/models/note.ts b/src/models/note.ts index 3c1c2e18e1..3059593540 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'); @@ -66,7 +66,6 @@ export type INote = { }; _user: { host: string; - hostLower: string; account: { inbox?: string; }; @@ -92,6 +91,8 @@ export async function deleteNote(note: string | mongo.ObjectID | INote) { n = note as INote; } + console.log(n == null ? `Note: delete skipped ${note}` : `Note: deleting ${n._id}`); + if (n == null) return; // このNoteへの返信をすべて削除 @@ -124,10 +125,17 @@ 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 }); + + console.log(`Note: deleted ${n._id}`); } /** @@ -259,7 +267,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 |