<commit_before>'use strict';

/**
 * Attachments helper
 */
module.exports = {

  /**
   * add - Adds attachments to its respective direction array.
   *
   * @param  {object} req
   * @param  {object} attachmentObject object containing url, and contentType
   * @param  {string} direction = 'inbound' direction array where to store this attachment
   */
  add: function add(req, attachmentObject, direction = 'inbound') {
    if (attachmentObject.url) {
      // TODO: req.attachments might not exist if this function is called from a route
      // that doesnt set a default req.attachments
      req.attachments[direction].push({
        url: attachmentObject.url,
        contentType: attachmentObject.contentType,
      });
    }
  },

  /**
   * parseFromReq - creates a generic attachment object from a req which contains a mediaUrl in the
   * body of the request.
   *
   * @param  {type} req description
   * @return {type}     description
   */
  parseFromReq: function parseFromReq(req) {
    return {
      url: req.body.mediaUrl,
    };
  },
};<commit_msg>remove TODO that is already fixed in attachments helper<commit_after>'use strict';

/**
 * Attachments helper
 */
module.exports = {

  /**
   * add - Adds attachments to its respective direction array.
   *
   * @param  {object} req
   * @param  {object} attachmentObject object containing url, and contentType
   * @param  {string} direction = 'inbound' direction array where to store this attachment
   */
  add: function add(req, attachmentObject, direction = 'inbound') {
    if (attachmentObject.url) {
      req.attachments[direction].push({
        url: attachmentObject.url,
        contentType: attachmentObject.contentType,
      });
    }
  },

  /**
   * parseFromReq - creates a generic attachment object from a req which contains a mediaUrl in the
   * body of the request.
   *
   * @param  {type} req description
   * @return {type}     description
   */
  parseFromReq: function parseFromReq(req) {
    return {
      url: req.body.mediaUrl,
    };
  },
};
{'fraction_non_alphanumeric': 0.10518590998043052, 'fraction_numerical': 0.0, 'mean_word_length': 2.858490566037736, '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': '1044882', 'n_tokens_mistral': 583, 'n_tokens_neox': 574, 'n_words': 187}