<commit_before><?php
function Assets_credits_post($params = array())
{
    $req = array_merge($_REQUEST, $params);
	Q_Valid::requireFields(array('amount', 'currency'), $req, true);

	$loggedUserId = Users::loggedInUser(true)->id;
	$amount = (float)$req['amount'];
	$credits = (int)Assets_Credits::amount();
	$needCredits = Assets_Credits::convertToCredits($amount, $req['currency']);

	if ($credits < $needCredits) {
		$needCredits = $needCredits - $credits;
		Q_response::setSlot('status', false);
		Q_response::setSlot('details', compact("credits", "needCredits"));
		return;
	}

	// if stream defined
	$toPublisherId = Q::ifset($req, 'toStream', 'publisherId', null);
	$toStreamName = Q::ifset($req, 'toStream', 'streamName', null);
	$userId = Q::ifset($req, 'userId', null);
	$items = Q::ifset($req, 'items', null);

	// convert amount to credits in items
	if ($items) {
		foreach ($items as $key => $item) {
			$items[$key]['amount'] = Assets_Credits::convertToCredits($item['amount'], $req['currency']);
		}
	}

	if ($toPublisherId && $toStreamName) {
		Assets_Credits::spend($needCredits, Assets::JOINED_PAID_STREAM, $loggedUserId, compact(
			"toPublisherId", "toStreamName", "items"
		));
	} elseif ($userId) {
		Assets_Credits::send($needCredits, Assets::PAYMENT_TO_USER, $userId, $loggedUserId, compact(
			"toPublisherId", "toStreamName", "items"
		));
	}

	Q_response::setSlot('status', true);
	Q_response::setSlot('details', compact("credits", "needCredits"));
}<commit_msg>Fixed Asset/credits/post handler.If currency "credits", don't convert.<commit_after><?php
function Assets_credits_post($params = array())
{
    $req = array_merge($_REQUEST, $params);
	Q_Valid::requireFields(array('amount', 'currency'), $req, true);

	$loggedUserId = Users::loggedInUser(true)->id;
	$amount = (float)$req['amount'];
	$credits = (int)Assets_Credits::amount();
	$needCredits = $req['currency'] == "credits" ? $amount : Assets_Credits::convertToCredits($amount, $req['currency']);

	if ($credits < $needCredits) {
		$needCredits = $needCredits - $credits;
		Q_response::setSlot('status', false);
		Q_response::setSlot('details', compact("credits", "needCredits"));
		return;
	}

	// if stream defined
	$toPublisherId = Q::ifset($req, 'toStream', 'publisherId', null);
	$toStreamName = Q::ifset($req, 'toStream', 'streamName', null);
	$userId = Q::ifset($req, 'userId', null);
	$items = Q::ifset($req, 'items', null);

	// convert amount to credits in items
	if ($items) {
		foreach ($items as $key => $item) {
			$items[$key]['amount'] = Assets_Credits::convertToCredits($item['amount'], $req['currency']);
		}
	}

	if ($toPublisherId && $toStreamName) {
		Assets_Credits::spend($needCredits, Assets::JOINED_PAID_STREAM, $loggedUserId, compact(
			"toPublisherId", "toStreamName", "items"
		));
	} elseif ($userId) {
		Assets_Credits::send($needCredits, Assets::PAYMENT_TO_USER, $userId, $loggedUserId, compact(
			"toPublisherId", "toStreamName", "items"
		));
	}

	Q_response::setSlot('status', true);
	Q_response::setSlot('details', compact("credits", "needCredits"));
}
{'fraction_non_alphanumeric': 0.19772357723577236, 'fraction_numerical': 0.0, 'mean_word_length': 6.748110831234257, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '370244', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1092, 'n_words': 197}