mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 06:03:07 +02:00
再帰的にNoteをレンダリングするように
This commit is contained in:
parent
2ffd1ea433
commit
cb85d7cb14
1 changed files with 11 additions and 3 deletions
|
@ -5,7 +5,7 @@ import DriveFile from '../../../models/drive-file';
|
|||
import Note, { INote } from '../../../models/note';
|
||||
import User from '../../../models/user';
|
||||
|
||||
export default async (note: INote) => {
|
||||
export default async function renderNote(note: INote, dive = true) {
|
||||
const promisedFiles = note.mediaIds
|
||||
? DriveFile.find({ _id: { $in: note.mediaIds } })
|
||||
: Promise.resolve([]);
|
||||
|
@ -23,7 +23,15 @@ export default async (note: INote) => {
|
|||
});
|
||||
|
||||
if (inReplyToUser !== null) {
|
||||
inReplyTo = inReplyToNote.uri || `${config.url}/notes/${inReplyToNote._id}`;
|
||||
if (inReplyToNote.uri) {
|
||||
inReplyTo = inReplyToNote.uri;
|
||||
} else {
|
||||
if (dive) {
|
||||
inReplyTo = await renderNote(inReplyToNote, false);
|
||||
} else {
|
||||
inReplyTo = `${config.url}/notes/${inReplyToNote._id}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -48,4 +56,4 @@ export default async (note: INote) => {
|
|||
attachment: (await promisedFiles).map(renderDocument),
|
||||
tag: (note.tags || []).map(renderHashtag)
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue