<commit_before>/* @flow */

import type { User } from '../../lib/schemaTypes';
import UserModel from '../../models/user';
import ThreadModel from '../../models/thread';
import TextModel from '../../models/text';
import RoomRelModel from '../../models/roomrel';
import ThreadRelModel from '../../models/threadrel';
import uuid from 'node-uuid';
import { PRESENCE_FOREGROUND, PRESENCE_NONE } from '../../lib/Constants';

/*
 * User related actions
 */
export const signIn = (provider: string, accessToken: string): Object => ({
	auth: {
		[provider]: {
			accessToken
		}
	}
});

export const signUp = (user: User): Object => ({
	auth: {
		signup: new UserModel({ ...user, presence: PRESENCE_FOREGROUND })
	}
});

export const clearSignUpError = (signup: Object): Object => ({
	state: {
		signup: {
			...signup,
			error: null,
		},
	}
});

export const cancelSignUp = (): Object => ({
	state: {
		signup: null,
	}
});

export const signOut = (): Object => ({
	state: {
		session: null,
		user: null,
	}
});

export const saveUser = (user: User): Object => ({
	entities: {
		[user.id]: new UserModel({ ...user, presence: PRESENCE_FOREGROUND })
	}
});

export const addPlace = (user: string, type: string, place: Object): Object => ({
	entities: {
		[user]: new UserModel({
			id: user,
			params: {
				places: {
					[type]: place
				}
			},
			presence: PRESENCE_FOREGROUND
		})
	}
});

export const removePlace = (user: string, type: string): Object => ({
	entities: {
		[user]: new UserModel({
			id: user,
			params: {
				places: {
					__op__: {
						[type]: 'delete'
					}
				}
			},
			presence: PRESENCE_FOREGROUND
		})
	}
});

export const banUser = (): Object => ({

});

export const unbanUser = (): Object => ({

});


/*
 * Text related actions
 */
export const sendMessage = (
	data: { body: string; meta?: ?Object; parents: Array<string>; creator: string; }
): Object => {
	const id = uuid.v4();

	return {
		entities: {
			[id]: new TextModel({ id, ...data, create: true })
		}
	};
};

export const startThread = (
	data: { name: string; body: string; meta?: ?Object; parents: Array<string>; creator: string; }
): Object => {
	const id = uuid.v4();

	return {
		entities: {
			[id]: new ThreadModel({ id, ...data, create: true, createTime: Date.now()})
		}
	};
};

export const hideText = (): Object => ({
<commit_msg>Add createTime to text<commit_after>/* @flow */

import type { User } from '../../lib/schemaTypes';
import UserModel from '../../models/user';
import ThreadModel from '../../models/thread';
import TextModel from '../../models/text';
import RoomRelModel from '../../models/roomrel';
import ThreadRelModel from '../../models/threadrel';
import uuid from 'node-uuid';
import { PRESENCE_FOREGROUND, PRESENCE_NONE } from '../../lib/Constants';

/*
 * User related actions
 */
export const signIn = (provider: string, accessToken: string): Object => ({
	auth: {
		[provider]: {
			accessToken
		}
	}
});

export const signUp = (user: User): Object => ({
	auth: {
		signup: new UserModel({ ...user, presence: PRESENCE_FOREGROUND })
	}
});

export const clearSignUpError = (signup: Object): Object => ({
	state: {
		signup: {
			...signup,
			error: null,
		},
	}
});

export const cancelSignUp = (): Object => ({
	state: {
		signup: null,
	}
});

export const signOut = (): Object => ({
	state: {
		session: null,
		user: null,
	}
});

export const saveUser = (user: User): Object => ({
	entities: {
		[user.id]: new UserModel({ ...user, presence: PRESENCE_FOREGROUND })
	}
});

export const addPlace = (user: string, type: string, place: Object): Object => ({
	entities: {
		[user]: new UserModel({
			id: user,
			params: {
				places: {
					[type]: place
				}
			},
			presence: PRESENCE_FOREGROUND
		})
	}
});

export const removePlace = (user: string, type: string): Object => ({
	entities: {
		[user]: new UserModel({
			id: user,
			params: {
				places: {
					__op__: {
						[type]: 'delete'
					}
				}
			},
			presence: PRESENCE_FOREGROUND
		})
	}
});

export const banUser = (): Object => ({

});

export const unbanUser = (): Object => ({

});


/*
 * Text related actions
 */
export const sendMessage = (
	data: { body: string; meta?: ?Object; parents: Array<string>; creator: string; }
): Object => {
	const id = uuid.v4();

	return {
		entities: {
			[id]: new TextModel({
				id,
				...data,
				create: true,
				createTime: Date.now()
			})
		}
	};
};

export const startThread = (
	data: { name: string; body: string; meta?: ?Object; parents: Array<string>; creator: string; }
): Object => {
	const id = uuid.v4();

	return {
		entities: {
			[id]: new ThreadModel({
				id,
				...data,
				create: true,
				createTime: Date.now()
			})
		}
	};
};

export const hideText = (): Object => ({

{'fraction_non_alphanumeric': 0.18842105263157893, 'fraction_numerical': 0.0008421052631578948, 'mean_word_length': 3.026271186440678, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, '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': '95991', 'n_tokens_mistral': 1789, 'n_tokens_neox': 1604, 'n_words': 435}