mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 21:23:08 +02:00
Refactor
This commit is contained in:
parent
f97cdfaa20
commit
62509edcbe
1 changed files with 16 additions and 12 deletions
|
@ -82,34 +82,38 @@ export default async function renderNote(note: INote, dive = true): Promise<any>
|
||||||
|
|
||||||
const files = await promisedFiles;
|
const files = await promisedFiles;
|
||||||
|
|
||||||
|
let text = note.text;
|
||||||
|
|
||||||
if (note.poll != null) {
|
if (note.poll != null) {
|
||||||
if (note.text == null) note.text = '';
|
if (text == null) text = '';
|
||||||
const url = `${config.url}/notes/${note._id}`;
|
const url = `${config.url}/notes/${note._id}`;
|
||||||
// TODO: i18n
|
// TODO: i18n
|
||||||
note.text += `\n\n[投票を見る](${url})`;
|
text += `\n\n[投票を見る](${url})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.renoteId != null) {
|
if (note.renoteId != null) {
|
||||||
if (note.text == null) note.text = '';
|
if (text == null) text = '';
|
||||||
const url = `${config.url}/notes/${note.renoteId}`;
|
const url = `${config.url}/notes/${note.renoteId}`;
|
||||||
note.text += `\n\nRE: ${url}`;
|
text += `\n\nRE: ${url}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 省略されたメンションのホストを復元する
|
// 省略されたメンションのホストを復元する
|
||||||
const text = note.text ? parseMfm(note.text).map(x => {
|
if (text != null) {
|
||||||
if (x.type == 'mention' && x.host == null) {
|
text = parseMfm(text).map(x => {
|
||||||
return `${x.content}@${config.host}`;
|
if (x.type == 'mention' && x.host == null) {
|
||||||
} else {
|
return `${x.content}@${config.host}`;
|
||||||
return x.content;
|
} else {
|
||||||
}
|
return x.content;
|
||||||
}).join('') : null;
|
}
|
||||||
|
}).join('');
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: `${config.url}/notes/${note._id}`,
|
id: `${config.url}/notes/${note._id}`,
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
attributedTo,
|
attributedTo,
|
||||||
summary: note.cw,
|
summary: note.cw,
|
||||||
content: toHtml(note),
|
content: toHtml(Object.assign({}, note, { text })),
|
||||||
_misskey_content: text,
|
_misskey_content: text,
|
||||||
published: note.createdAt.toISOString(),
|
published: note.createdAt.toISOString(),
|
||||||
to,
|
to,
|
||||||
|
|
Loading…
Reference in a new issue