<commit_before>require! {
	'../../auth': authorize
	'../../../config': config
	'../../../models/notice': Notice
	'../../../models/status': Status
	'../../../models/status-favorite': StatusFavorite
	'../../../utils/status-is-favorited': status-is-favorited
	'../../../utils/status-response-filter': status-response-filter
	'../../../utils/streaming': Streamer
	'../../../utils/user-response-filter': user-response-filter
}

module.exports = (req, res) -> authorize req, res, (user, app) ->
	| (status-id = req.body.status_id) == null => res.api-error 400 'status_id parameter is required :('
	| _ => Status.find-by-id status-id, (, target-status) ->
			| !target-status? => res.api-error 404 'Post not found...'
			| !target-status.repost-from-status-id? => favorite-step req, res, app, user, target-status
			| _ => Status.find-by-id target-status.repost-from-status-id (, true-target-status) -> favorite-step req, res, app, user, true-target-status

function favorite-step req, res, app, user, target-status
	status-is-favorited target-status.id, user.id, (is-favorited) ->
		| is-favorited => res.api-error 400 'This post is already favorited :('
		| _ => StatusFavorite.insert { status-id: target-status.id, user-id: user.id } (, favorite) ->
			target-status
				..favorites-count++
				..update ->
			status-response-filter target-post, res.api-render<commit_msg>Improve readability<commit_after>require! {
	'../../auth': authorize
	'../../../config': config
	'../../../models/notice': Notice
	'../../../models/status': Status
	'../../../models/status-favorite': StatusFavorite
	'../../../utils/status-is-favorited'
	'../../../utils/status-response-filter'
	'../../../utils/streaming': Streamer
	'../../../utils/user-response-filter'
}

module.exports = (req, res) -> authorize req, res, (user, app) ->
	| (status-id = req.body.status_id) == null => res.api-error 400 'status_id parameter is required :('
	| _ => Status.find-by-id status-id, (, target-status) ->
			| !target-status? => res.api-error 404 'Post not found...'
			| !target-status.repost-from-status-id? => favorite-step req, res, app, user, target-status
			| _ => Status.find-by-id target-status.repost-from-status-id (, true-target-status) -> favorite-step req, res, app, user, true-target-status

function favorite-step req, res, app, user, target-status
	status-is-favorited target-status.id, user.id, (is-favorited) ->
		| is-favorited => res.api-error 400 'This post is already favorited :('
		| _ => StatusFavorite.insert { status-id: target-status.id, user-id: user.id } (, favorite) ->
			target-status
				..favorites-count++
				..update ->
			status-response-filter target-post, res.api-render
{'fraction_non_alphanumeric': 0.21570093457943926, 'fraction_numerical': 0.0067289719626168224, 'mean_word_length': 3.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2739883', 'n_tokens_mistral': 948, 'n_tokens_neox': 882, 'n_words': 181}