2017-02-19 07:20:59 +09:00
|
|
|
const summarize = post => {
|
2017-02-19 07:20:31 +09:00
|
|
|
let summary = post.text ? post.text : '';
|
2017-02-18 13:07:34 +09:00
|
|
|
|
|
|
|
// メディアが添付されているとき
|
|
|
|
if (post.media) {
|
|
|
|
summary += ` (${post.media.length}つのメディア)`;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 投票が添付されているとき
|
|
|
|
if (post.poll) {
|
|
|
|
summary += ' (投票)';
|
|
|
|
}
|
|
|
|
|
|
|
|
// 返信のとき
|
|
|
|
if (post.reply_to_id) {
|
|
|
|
if (post.reply_to) {
|
2017-02-19 07:20:59 +09:00
|
|
|
replySummary = summarize(post.reply_to);
|
2017-02-18 13:07:34 +09:00
|
|
|
summary += ` RE: ${replySummary}`;
|
|
|
|
} else {
|
|
|
|
summary += ' RE: ...';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Repostのとき
|
|
|
|
if (post.repost_id) {
|
|
|
|
if (post.repost) {
|
2017-02-19 07:20:59 +09:00
|
|
|
repostSummary = summarize(post.repost);
|
2017-02-18 13:07:34 +09:00
|
|
|
summary += ` RP: ${repostSummary}`;
|
|
|
|
} else {
|
|
|
|
summary += ' RP: ...';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return summary.trim();
|
|
|
|
};
|
|
|
|
|
2017-02-19 07:20:59 +09:00
|
|
|
module.exports = summarize;
|