<commit_before>import * as SocketIO from 'socket.io';
import * as cookie from 'cookie';

import { User } from '../../models/user';
import { UserSettings, IUserSettings } from '../../models/user-settings';
import requestApi from '../../core/request-api';
import config from '../../config';

export default function getSessionUser(socket: SocketIO.Socket, sessionStore: any): Promise<Object[]> {
	'use strict';
	return new Promise<Object>((resolve, reject) => {
		// Get cookies
		const cookies: { [key: string]: string } = cookie.parse(socket.handshake.headers.cookie);

		// Get sesson key
		const sid: string = cookies[config.sessionKey];
		const sidkey: string = sid.match(/s:(.+?)\./)[1];

		// Resolve session
		sessionStore.get(sidkey, (err: any, session: any) => {
			if (err !== null) {
				return console.error(err);
			}
			else if (session === null) {
				return;
			}
			else if (typeof session === 'undefined') {
				return;
			}

			const userId: string = session.userId;
			requestApi('account/show', {}, userId).then((user: User) => {
				UserSettings.findOne({
					userId: userId
				}, (_: any, settings: IUserSettings) => {
					user._settings = settings;
					resolve(user);
				});
			});
		});
	});
}<commit_msg>fix build<commit_after>import * as SocketIO from 'socket.io';
import * as cookie from 'cookie';

import { User } from '../../models/user';
import { UserSettings, IUserSettings } from '../../models/user-settings';
import requestApi from '../../core/request-api';
import config from '../../config';

export default function getSessionUser(socket: SocketIO.Socket, sessionStore: any): Promise<Object[]> {
	'use strict';
	return new Promise<Object>((resolve, reject) => {
		// Get cookies
		const cookies: { [key: string]: string } = cookie.parse(socket.handshake.headers.cookie);

		// Get sesson key
		const sid: string = cookies[config.sessionKey];
		const sidkey: string = sid.match(/s:(.+?)\./)[1];

		// Resolve session
		sessionStore.get(sidkey, (err: any, session: any) => {
			if (err !== null) {
				return console.error(err);
			} else if (session === null) {
				return;
			} else if (typeof session === 'undefined') {
				return;
			}

			const userId: string = session.userId;
			requestApi('account/show', {}, userId).then((user: User) => {
				UserSettings.findOne({
					userId: userId
				}, (_: any, settings: IUserSettings) => {
					user._settings = settings;
					resolve(user);
				});
			});
		});
	});
}
{'fraction_non_alphanumeric': 0.17982099267697316, 'fraction_numerical': 0.0008136696501220504, 'mean_word_length': 3.3445229681978796, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1869490', 'n_tokens_mistral': 862, 'n_tokens_neox': 758, 'n_words': 199}