Implement #2736
This commit is contained in:
17
src/models/note-unread.ts
Normal file
17
src/models/note-unread.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import * as mongo from 'mongodb';
|
||||
import db from '../db/mongodb';
|
||||
|
||||
const NoteUnread = db.get<INoteUnread>('noteUnreads');
|
||||
NoteUnread.createIndex(['userId', 'noteId'], { unique: true });
|
||||
export default NoteUnread;
|
||||
|
||||
export interface INoteUnread {
|
||||
_id: mongo.ObjectID;
|
||||
noteId: mongo.ObjectID;
|
||||
userId: mongo.ObjectID;
|
||||
isSpecified: boolean;
|
||||
|
||||
_note: {
|
||||
userId: mongo.ObjectID;
|
||||
};
|
||||
}
|
@ -295,8 +295,8 @@ export const pack = async (
|
||||
|
||||
delete _note._user;
|
||||
delete _note._reply;
|
||||
delete _note.repost;
|
||||
delete _note.mentions;
|
||||
delete _note._renote;
|
||||
delete _note._files;
|
||||
if (_note.geo) delete _note.geo.type;
|
||||
|
||||
// Populate user
|
||||
|
@ -348,7 +348,8 @@ export const pack = (
|
||||
me?: string | mongo.ObjectID | IUser,
|
||||
options?: {
|
||||
detail?: boolean,
|
||||
includeSecrets?: boolean
|
||||
includeSecrets?: boolean,
|
||||
includeHasUnreadNotes?: boolean
|
||||
}
|
||||
) => new Promise<any>(async (resolve, reject) => {
|
||||
|
||||
@ -510,6 +511,11 @@ export const pack = (
|
||||
}
|
||||
}
|
||||
|
||||
if (!opts.includeHasUnreadNotes) {
|
||||
delete _user.hasUnreadSpecifiedNotes;
|
||||
delete _user.hasUnreadMentions;
|
||||
}
|
||||
|
||||
// resolve promises in _user object
|
||||
_user = await rap(_user);
|
||||
|
||||
|
Reference in New Issue
Block a user