2018-04-07 10:30:37 -07:00
|
|
|
/**
|
|
|
|
* 投稿を表す文字列を取得します。
|
2018-05-05 09:34:48 -07:00
|
|
|
* @param {*} note (packされた)投稿
|
2018-04-07 10:30:37 -07:00
|
|
|
*/
|
2020-05-22 21:19:31 -07:00
|
|
|
const summarize = (note: any, locale: any): string => {
|
2018-05-27 22:39:46 -07:00
|
|
|
if (note.deletedAt) {
|
2020-05-22 21:19:31 -07:00
|
|
|
return `(${locale['deletedNote']})`;
|
2018-05-27 22:39:46 -07:00
|
|
|
}
|
|
|
|
|
2018-04-28 16:51:17 -07:00
|
|
|
if (note.isHidden) {
|
2020-05-22 21:19:31 -07:00
|
|
|
return `(${locale['invisibleNote']})`;
|
2018-04-28 16:51:17 -07:00
|
|
|
}
|
|
|
|
|
2018-04-07 10:30:37 -07:00
|
|
|
let summary = '';
|
|
|
|
|
|
|
|
// 本文
|
2018-12-19 10:22:27 -08:00
|
|
|
if (note.cw != null) {
|
2018-12-17 03:17:21 -08:00
|
|
|
summary += note.cw;
|
|
|
|
} else {
|
|
|
|
summary += note.text ? note.text : '';
|
|
|
|
}
|
2018-04-07 10:30:37 -07:00
|
|
|
|
2018-09-05 03:32:46 -07:00
|
|
|
// ファイルが添付されているとき
|
2018-10-08 13:31:26 -07:00
|
|
|
if ((note.files || []).length != 0) {
|
2020-05-22 21:19:31 -07:00
|
|
|
summary += ` (${locale['withNFiles'].replace('{n}', note.files.length)})`;
|
2018-04-07 10:30:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 投票が添付されているとき
|
|
|
|
if (note.poll) {
|
2020-05-22 21:19:31 -07:00
|
|
|
summary += ` (${locale._cw?.poll || locale['_cw.poll']})`;
|
2018-04-07 10:30:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 返信のとき
|
|
|
|
if (note.replyId) {
|
|
|
|
if (note.reply) {
|
2020-05-22 21:19:31 -07:00
|
|
|
summary += `\n\nRE: ${summarize(note.reply, locale)}`;
|
2018-04-07 10:30:37 -07:00
|
|
|
} else {
|
2018-11-29 16:34:37 -08:00
|
|
|
summary += '\n\nRE: ...';
|
2018-04-07 10:30:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Renoteのとき
|
|
|
|
if (note.renoteId) {
|
|
|
|
if (note.renote) {
|
2020-05-22 21:19:31 -07:00
|
|
|
summary += `\n\nRN: ${summarize(note.renote, locale)}`;
|
2018-04-07 10:30:37 -07:00
|
|
|
} else {
|
2018-11-29 16:34:37 -08:00
|
|
|
summary += '\n\nRN: ...';
|
2018-04-07 10:30:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return summary.trim();
|
|
|
|
};
|
|
|
|
|
|
|
|
export default summarize;
|