mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-25 02:09:05 +01:00
08a2162aa7
* wip * tabun ok * better msg * oops * fix lint * Update gulpfile.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * Update src/client/scripts/set-i18n-contexts.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * refactor Co-authored-by: acid-chicken <root@acid-chicken.com> * ✨ * wip * fix lint * たぶんおk * fix flush * Translate Notification * remove console.log * fix * add notifications * remove san * wip * ok * ✌️ * Update src/prelude/array.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * wip * i18n refactor * Update init.ts * ✌️ Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
55 lines
1.1 KiB
TypeScript
55 lines
1.1 KiB
TypeScript
/**
|
|
* 投稿を表す文字列を取得します。
|
|
* @param {*} note (packされた)投稿
|
|
*/
|
|
const summarize = (note: any, locale: any): string => {
|
|
if (note.deletedAt) {
|
|
return `(${locale['deletedNote']})`;
|
|
}
|
|
|
|
if (note.isHidden) {
|
|
return `(${locale['invisibleNote']})`;
|
|
}
|
|
|
|
let summary = '';
|
|
|
|
// 本文
|
|
if (note.cw != null) {
|
|
summary += note.cw;
|
|
} else {
|
|
summary += note.text ? note.text : '';
|
|
}
|
|
|
|
// ファイルが添付されているとき
|
|
if ((note.files || []).length != 0) {
|
|
summary += ` (${locale['withNFiles'].replace('{n}', note.files.length)})`;
|
|
}
|
|
|
|
// 投票が添付されているとき
|
|
if (note.poll) {
|
|
summary += ` (${locale._cw?.poll || locale['_cw.poll']})`;
|
|
}
|
|
|
|
// 返信のとき
|
|
if (note.replyId) {
|
|
if (note.reply) {
|
|
summary += `\n\nRE: ${summarize(note.reply, locale)}`;
|
|
} else {
|
|
summary += '\n\nRE: ...';
|
|
}
|
|
}
|
|
|
|
// Renoteのとき
|
|
if (note.renoteId) {
|
|
if (note.renote) {
|
|
summary += `\n\nRN: ${summarize(note.renote, locale)}`;
|
|
} else {
|
|
summary += '\n\nRN: ...';
|
|
}
|
|
}
|
|
|
|
return summary.trim();
|
|
};
|
|
|
|
export default summarize;
|