summaryrefslogtreecommitdiff
path: root/src/web/app/common/scripts/get-post-summary.ls
blob: 67178bc3241e098ce1ccd48c9880aef500124a2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
get-post-summary = (post) ~>
	summary = if post.text? then post.text else ''

	# メディアが添付されているとき
	if post.media?
		summary += " (#{post.media.length}つのメディア)"

	# 投票が添付されているとき
	if post.poll?
		summary += " (投票)"

	# 返信のとき
	if post.reply_to_id?
		if post.reply_to?
			reply-summary = get-post-summary post.reply_to
			summary += " RE: #{reply-summary}"
		else
			summary += " RE: ..."

	# Repostのとき
	if post.repost_id?
		if post.repost?
			repost-summary = get-post-summary post.repost
			summary += " RP: #{repost-summary}"
		else
			summary += " RP: ..."

	return summary.trim!

module.exports = get-post-summary