diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-07 19:58:00 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-07 19:58:00 +0900 |
| commit | 1c65cb3e3637c097e876c38147cd1b95b4d356ca (patch) | |
| tree | 4811c28a21a70e0c8f304d1e01d737ecce4ebc4b /src | |
| parent | Fix bug (diff) | |
| download | sharkey-1c65cb3e3637c097e876c38147cd1b95b4d356ca.tar.gz sharkey-1c65cb3e3637c097e876c38147cd1b95b4d356ca.tar.bz2 sharkey-1c65cb3e3637c097e876c38147cd1b95b4d356ca.zip | |
Resolve #2843
Diffstat (limited to 'src')
| -rw-r--r-- | src/services/i/pin.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/services/i/pin.ts b/src/services/i/pin.ts index 142fc18511..ff390eb781 100644 --- a/src/services/i/pin.ts +++ b/src/services/i/pin.ts @@ -24,7 +24,15 @@ export async function addPinned(user: IUser, noteId: mongo.ObjectID) { throw new Error('note not found'); } - const pinnedNoteIds = user.pinnedNoteIds || []; + let pinnedNoteIds = user.pinnedNoteIds || []; + + //#region 現在ピン留め投稿している投稿が実際にデータベースに存在しているのかチェック + // データベースの欠損などで存在していない場合があるので。 + // 存在していなかったらピン留め投稿から外す + const pinnedNotes = (await Promise.all(pinnedNoteIds.map(id => Note.findOne({ _id: id })))).filter(x => x != null); + + pinnedNoteIds = pinnedNoteIds.filter(id => pinnedNotes.some(n => n._id.equals(id))); + //#endregion if (pinnedNoteIds.length >= 5) { throw new Error('cannot pin more notes'); |