<commit_before>const fs = require('fs');
const ip = require("ip");
const request = require('superagent-bluebird-promise');
const crypto = require('crypto');
const Promise = require('bluebird');

const jobFactory = require('../jobFactory');
const msdb = require('../msdb');
const config = require('../configLoader');

const agent = request.agent({
    keepAliveTimeout: 30000
});

module.exports = () => {
    jobFactory('createThread', (job, done) => {
        const messageBody = job.data.body;

        if (!('userId' in messageBody)) {
            done(new Error('Error: field "userId" was not provided.'))
        }

        if (!('forumId' in messageBody)) {
            done(new Error('Error: field "forumId" was not provided.'))
        }

        if (!('subject' in messageBody)) {
            done(new Error('Error: field "subject" was not provided.'))
        }

        if (!('message' in messageBody)) {
            done(new Error('Error: field "message" was not provided.'))
        }

        const user = msdb.db.phpbb_users.findById(messageBody.userId)
              .then(user => {
                  const currentTime = (new Date()).getTime();

                  return msdb.sequelize.transaction(t => {
                      return Promise.all([
                          msdb.db.phpbb_topics.create({
                              topic_poster: user.user_id,
                              topic_time: currentTime,
                              topic_last_view_time: currentTime,
                              forum_id: messageBody.forumId,
                              topic_title: messageBody.subject,
                              topic_first_poster_name: user.username,
                              topic_first_poster_colour: user.user_colour,
                              is_private: messageBody.forumId === config.get('privateTopicForumId') ? 1 : 0
                          }, {transaction: t}), 
                          agent
                              .post(`${config.get("msUrl")}/render_bbcode.php`)
                              .type('form')<commit_msg>seconds since epoch, not milliseconds<commit_after>const fs = require('fs');
const ip = require("ip");
const request = require('superagent-bluebird-promise');
const crypto = require('crypto');
const Promise = require('bluebird');

const jobFactory = require('../jobFactory');
const msdb = require('../msdb');
const config = require('../configLoader');

const agent = request.agent({
    keepAliveTimeout: 30000
});

module.exports = () => {
    jobFactory('createThread', (job, done) => {
        const messageBody = job.data.body;

        if (!('userId' in messageBody)) {
            done(new Error('Error: field "userId" was not provided.'))
        }

        if (!('forumId' in messageBody)) {
            done(new Error('Error: field "forumId" was not provided.'))
        }

        if (!('subject' in messageBody)) {
            done(new Error('Error: field "subject" was not provided.'))
        }

        if (!('message' in messageBody)) {
            done(new Error('Error: field "message" was not provided.'))
        }

        const user = msdb.db.phpbb_users.findById(messageBody.userId)
              .then(user => {
                  const d = new Date();
                  const currentTime = Math.round(d.getTime() / 1000);

                  return msdb.sequelize.transaction(t => {
                      return Promise.all([
                          msdb.db.phpbb_topics.create({
                              topic_poster: user.user_id,
                              topic_time: currentTime,
                              topic_last_view_time: currentTime,
                              forum_id: messageBody.forumId,
                              topic_title: messageBody.subject,
                              topic_first_poster_name: user.username,
                              topic_first_poster_colour: user.user_colour,
                              is_private: messageBody.forumId === config.get('privateTopicForumId') ? 1 : 0
                          }, {transaction: t}), 
                          agent
                              .post(`${config.get("msUrl")}/render_bbcode.php`)
                              .type('form')
{'fraction_non_alphanumeric': 0.12335526315789473, 'fraction_numerical': 0.0042293233082706765, 'mean_word_length': 1.6424581005586592, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5251981', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1078, 'n_words': 241}