<commit_before><?php
/**
 * Nextcloud - passman
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2016
 */

namespace OCA\Passman\Service;

use OCP\IConfig;
use OCP\AppFramework\Db\DoesNotExistException;

use OCA\Passman\Db\VaultMapper;


class VaultService {

	private $vaultMapper;

	public function __construct(VaultMapper $vaultMapper) {
		$this->vaultMapper = $vaultMapper;
	}

	public function getByUser($userId) {
		return $this->vaultMapper->findVaultsFromUser($userId);
	}

	public function createVault($vault_name, $userId) {
		return $this->vaultMapper->create($vault_name, $userId);
	}

	public function setLastAccess($vault_id){
		return $this->vaultMapper->setLastAccess($vault_id);
	}

	public function updateSharingKeys($vault_id, $privateKey, $publicKey){
		return $this->vaultMapper->updateSharingKeys($vault_id, $privateKey, $publicKey);
	}
}<commit_msg>Add getById<commit_after><?php
/**
 * Nextcloud - passman
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright <NAME> 2016
 */

namespace OCA\Passman\Service;

use OCP\IConfig;
use OCP\AppFramework\Db\DoesNotExistException;

use OCA\Passman\Db\VaultMapper;


class VaultService {

	private $vaultMapper;

	public function __construct(VaultMapper $vaultMapper) {
		$this->vaultMapper = $vaultMapper;
	}

	public function getByUser($userId) {
		return $this->vaultMapper->findVaultsFromUser($userId);
	}

	public function getById($vault_id, $user_id) {
		$vault = $this->vaultMapper->find($vault_id, $user_id);
		$vault = $vault[0];
		$return = array(
			'vault_id' => $vault->getId(),
			'guid' => $vault->getGuid(),
			'name' => $vault->getName(),
			'created' => $vault->getCreated(),
			'private_sharing_key' => $vault->getPrivateSharingKey(),
			'public_sharing_key' => $vault->getPublicSharingKey(),
			'sharing_keys_generated' => $vault->getSharingKeysGenerated(),
			'settings' => $vault->getSettings(),
			'last_access' => $vault->getlastAccess()
		);
		return $return;
	}

	public function createVault($vault_name, $userId) {
		return $this->vaultMapper->create($vault_name, $userId);
	}

	public function setLastAccess($vault_id, $user_id){
		return $this->vaultMapper->setLastAccess($vault_id, $user_id);
	}

	public function updateSharingKeys($vault_id, $privateKey, $publicKey){
		return $this->vaultMapper->updateSharingKeys($vault_id, $privateKey, $publicKey);
	}
}
{'fraction_non_alphanumeric': 0.1469673405909798, 'fraction_numerical': 0.0042768273716951785, 'mean_word_length': 5.290953545232274, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 49, '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': '3684792', 'n_tokens_mistral': 952, 'n_tokens_neox': 901, 'n_words': 176}