forked from FoundKeyGang/FoundKey
Do not use _replyIds (#3392)
This commit is contained in:
parent
915d352505
commit
f2f7bdc5a9
3 changed files with 10 additions and 14 deletions
|
@ -18,6 +18,7 @@ Note.createIndex('uri', { sparse: true, unique: true });
|
||||||
Note.createIndex('userId');
|
Note.createIndex('userId');
|
||||||
Note.createIndex('mentions');
|
Note.createIndex('mentions');
|
||||||
Note.createIndex('visibleUserIds');
|
Note.createIndex('visibleUserIds');
|
||||||
|
Note.createIndex('replyId');
|
||||||
Note.createIndex('tagsLower');
|
Note.createIndex('tagsLower');
|
||||||
Note.createIndex('_user.host');
|
Note.createIndex('_user.host');
|
||||||
Note.createIndex('_files._id');
|
Note.createIndex('_files._id');
|
||||||
|
@ -99,7 +100,6 @@ export type INote = {
|
||||||
host: string;
|
host: string;
|
||||||
inbox?: string;
|
inbox?: string;
|
||||||
};
|
};
|
||||||
_replyIds?: mongo.ObjectID[];
|
|
||||||
_files?: IDriveFile[];
|
_files?: IDriveFile[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -258,6 +258,8 @@ export const pack = async (
|
||||||
delete _note._reply;
|
delete _note._reply;
|
||||||
delete _note._renote;
|
delete _note._renote;
|
||||||
delete _note._files;
|
delete _note._files;
|
||||||
|
delete _note._replyIds;
|
||||||
|
|
||||||
if (_note.geo) delete _note.geo.type;
|
if (_note.geo) delete _note.geo.type;
|
||||||
|
|
||||||
// Populate user
|
// Populate user
|
||||||
|
|
|
@ -33,16 +33,13 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
// Lookup note
|
|
||||||
const note = await Note.findOne({
|
const notes = await Note.find({
|
||||||
_id: ps.noteId
|
replyId: ps.noteId
|
||||||
|
}, {
|
||||||
|
limit: ps.limit,
|
||||||
|
skip: ps.offset
|
||||||
});
|
});
|
||||||
|
|
||||||
if (note === null) {
|
res(await packMany(notes, user));
|
||||||
return rej('note not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
const ids = (note._replyIds || []).slice(ps.offset, ps.offset + ps.limit);
|
|
||||||
|
|
||||||
res(await packMany(ids, user));
|
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -622,9 +622,6 @@ function saveQuote(renote: INote, note: INote) {
|
||||||
|
|
||||||
function saveReply(reply: INote, note: INote) {
|
function saveReply(reply: INote, note: INote) {
|
||||||
Note.update({ _id: reply._id }, {
|
Note.update({ _id: reply._id }, {
|
||||||
$push: {
|
|
||||||
_replyIds: note._id
|
|
||||||
},
|
|
||||||
$inc: {
|
$inc: {
|
||||||
repliesCount: 1
|
repliesCount: 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue