<commit_before>'use strict';

const globalHooks = require('../../../hooks');
const hooks = require('feathers-hooks');
const auth = require('feathers-authentication');
const search = require('feathers-mongodb-fuzzy-search');
const permissions = require('../utils/filePermissionHelper');
const FileModel = require('../model').fileModel;

const restrictToCurrentUser = hook => {
	let files = hook.result.data;
	let userId = hook.params.account.userId;
	let allowedFiles = [];
	// permissions check for each file
	return Promise.all(files.map(f => {
		return permissions.checkPermissions(userId, f.key, ['can-write'], false).then(isAllowed => {
			if (isAllowed) {
				f.context = isAllowed.context;
				allowedFiles.push(f);
			}
			return;
		})
	})).then(_ => {
		// get context folder name
		return Promise.all(allowedFiles.map(f => {
			let context = f.context;
			if (!context) {
				f.context = 'geteilte Datei';
			}
			else if (context === 'user') {
				f.context = 'Meine Dateien';
			}
			else {
				f.context = context.name;
			}
			return f;
		})).then(files => {
			hook.result.data = files;
			return hook;
		});
	})
};

exports.before = {
	all: [auth.hooks.authenticate('jwt')],
	find: [search({escape: false})],
	get: [],
	create: [],
	update: [],
	patch: [],
	remove: []<commit_msg>linting errors<commit_after>'use strict';

const globalHooks = require('../../../hooks');
const hooks = require('feathers-hooks');
const auth = require('feathers-authentication');
const search = require('feathers-mongodb-fuzzy-search');
const permissions = require('../utils/filePermissionHelper');
const FileModel = require('../model').fileModel;

const restrictToCurrentUser = hook => {
	let files = hook.result.data;
	let userId = hook.params.account.userId;
	let allowedFiles = [];
	// permissions check for each file
	return Promise.all(files.map(f => {
		return permissions.checkPermissions(userId, f.key, ['can-write'], false).then(isAllowed => {
			if (isAllowed) {
				f.context = isAllowed.context;
				allowedFiles.push(f);
			}
			return;
		});
	})).then(_ => {
		// get context folder name
		return Promise.all(allowedFiles.map(f => {
			let context = f.context;
			if (!context) {
				f.context = 'geteilte Datei';
			}
			else if (context === 'user') {
				f.context = 'Meine Dateien';
			}
			else {
				f.context = context.name;
			}
			return f;
		})).then(files => {
			hook.result.data = files;
			return hook;
		});
	});
};

exports.before = {
	all: [auth.hooks.authenticate('jwt')],
	find: [search({escape: false})],
	get: [],
	create: [],
	update: [],
	patch: [],
	remove: []
{'fraction_non_alphanumeric': 0.1812572310065561, 'fraction_numerical': 0.0, 'mean_word_length': 3.550877192982456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1878760', 'n_tokens_mistral': 947, 'n_tokens_neox': 872, 'n_words': 185}