Abolish common and misc directories

This commit is contained in:
Akihiko Odaki
2018-04-02 12:58:53 +09:00
parent a0f8b4e940
commit 5b9f3701f5
111 changed files with 133 additions and 133 deletions

45
src/get-post-summary.ts Normal file
View File

@@ -0,0 +1,45 @@
/**
* 投稿を表す文字列を取得します。
* @param {*} post 投稿
*/
const summarize = (post: any): string => {
let summary = '';
// チャンネル
summary += post.channel ? `${post.channel.title}:` : '';
// 本文
summary += post.text ? post.text : '';
// メディアが添付されているとき
if (post.media) {
summary += ` (${post.media.length}つのメディア)`;
}
// 投票が添付されているとき
if (post.poll) {
summary += ' (投票)';
}
// 返信のとき
if (post.replyId) {
if (post.reply) {
summary += ` RE: ${summarize(post.reply)}`;
} else {
summary += ' RE: ...';
}
}
// Repostのとき
if (post.repostId) {
if (post.repost) {
summary += ` RP: ${summarize(post.repost)}`;
} else {
summary += ' RP: ...';
}
}
return summary.trim();
};
export default summarize;