<commit_before>import crypto from 'crypto';
import { promises as fs, createReadStream } from 'fs';

import bcrypt from 'bcrypt';
import { promisifyAll } from 'bluebird';
import gm from 'gm';
import GraphemeBreaker from 'grapheme-breaker';
import _ from 'lodash';
import monitor from 'monitor-dog';
import validator from 'validator';
import { v4 as uuidv4 } from 'uuid';
import config from 'config';

import { getS3 } from '../support/s3';
import {
  BadRequestException,
  NotFoundException,
  ValidationException
} from '../support/exceptions';
import { Attachment, Comment, Post, PubSub as pubSub } from '../models';
import { EventService } from '../support/EventService';
import { userCooldownStart, userDataDeletionStart } from '../jobs/user-gone';

import { valiate as validateUserPrefs } from './user-prefs';


promisifyAll(crypto);
promisifyAll(gm);

// Account is suspended for unknown period
export const GONE_SUSPENDED = 10;
// Account is suspended for cooldown period, the next state is GONE_DELETION
export const GONE_COOLDOWN = 20;
// Cooldown period is over, user data is being deleted, the next state is GONE_DELETED
export const GONE_DELETION = 30;
// User data is fully deleted
export const GONE_DELETED = 40;

export const GONE_NAMES = {
  [GONE_SUSPENDED]: 'SUSPENDED',
  [GONE_COOLDOWN]:  'COOLDOWN',
  [GONE_DELETION]:  'DELETION',
  [GONE_DELETED]:   'DELETED',
};

export function addModel(dbAdapter) {
  return class User {
    static PROFILE_PICTURE_SIZE_LARGE = 75;
    static PROFILE_PICTURE_SIZE_MEDIUM = 50;

    static ACCEPT_DIRECTS_FROM_ALL = 'all';
    static ACCEPT_DIRECTS_FROM_FRIENDS = 'friends';

    static feedNames = [
      'RiverOfNews',
      'Hides',
      'Comments',
      'Likes',
      'Posts',
      'Directs',
      'MyDiscussions',
      'Saves',
    ];

    type = 'user';

    constructor(params) {
      this.goneStatus = params.goneStatus || null;
      this.intId = params.intId;
      this.id = params.id;
      this.username = params.username;
      this.screenName = params.screenName;
      this.email = params.email;
      this.hiddenEmail = params.email;
      this.description = params.description || '';
      this.frontendPreferences = params.frontendPreferences || {};
      this.preferences = validateUserPrefs(params.preferences, true);

      this.isPrivate = params.isPrivate;
      this.isProtected = this.isPrivate === '1' ? '1' : params.isProtected;

      if (parseInt(params.createdAt, 10)) {
        this.createdAt = params.createdAt;
      }

      if (parseInt(params.updatedAt, 10)) {<commit_msg>Correct the empty hiddenEmail value of User<commit_after>import crypto from 'crypto';
import { promises as fs, createReadStream } from 'fs';

import bcrypt from 'bcrypt';
import { promisifyAll } from 'bluebird';
import gm from 'gm';
import GraphemeBreaker from 'grapheme-breaker';
import _ from 'lodash';
import monitor from 'monitor-dog';
import validator from 'validator';
import { v4 as uuidv4 } from 'uuid';
import config from 'config';

import { getS3 } from '../support/s3';
import {
  BadRequestException,
  NotFoundException,
  ValidationException
} from '../support/exceptions';
import { Attachment, Comment, Post, PubSub as pubSub } from '../models';
import { EventService } from '../support/EventService';
import { userCooldownStart, userDataDeletionStart } from '../jobs/user-gone';

import { valiate as validateUserPrefs } from './user-prefs';


promisifyAll(crypto);
promisifyAll(gm);

// Account is suspended for unknown period
export const GONE_SUSPENDED = 10;
// Account is suspended for cooldown period, the next state is GONE_DELETION
export const GONE_COOLDOWN = 20;
// Cooldown period is over, user data is being deleted, the next state is GONE_DELETED
export const GONE_DELETION = 30;
// User data is fully deleted
export const GONE_DELETED = 40;

export const GONE_NAMES = {
  [GONE_SUSPENDED]: 'SUSPENDED',
  [GONE_COOLDOWN]:  'COOLDOWN',
  [GONE_DELETION]:  'DELETION',
  [GONE_DELETED]:   'DELETED',
};

export function addModel(dbAdapter) {
  return class User {
    static PROFILE_PICTURE_SIZE_LARGE = 75;
    static PROFILE_PICTURE_SIZE_MEDIUM = 50;

    static ACCEPT_DIRECTS_FROM_ALL = 'all';
    static ACCEPT_DIRECTS_FROM_FRIENDS = 'friends';

    static feedNames = [
      'RiverOfNews',
      'Hides',
      'Comments',
      'Likes',
      'Posts',
      'Directs',
      'MyDiscussions',
      'Saves',
    ];

    type = 'user';

    constructor(params) {
      this.goneStatus = params.goneStatus || null;
      this.intId = params.intId;
      this.id = params.id;
      this.username = params.username;
      this.screenName = params.screenName;
      this.email = params.email;
      // The .hiddenEmail field holds real email address of inactive user (the
      // .email field of such user is always empty)
      this.hiddenEmail = params.email || '';
      this.description = params.description || '';
      this.frontendPreferences = params.frontendPreferences || {};
      this.preferences = validateUserPrefs(params.preferences, true);

      this.isPrivate = params.isPrivate;
      this.isProtected = this.isPrivate === '1' ? '1' : params.isProtected;

      if (parseInt(params.createdAt, 10)) {
        this.createdAt = params.createdAt;
      }

      if (parseInt(params.updatedAt, 10)) {
{'fraction_non_alphanumeric': 0.11430720060161685, 'fraction_numerical': 0.00827223162248543, 'mean_word_length': 3.602076124567474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6111370', 'n_tokens_mistral': 1749, 'n_tokens_neox': 1678, 'n_words': 455}