<commit_before>'use strict';

const helpers = require('../../helpers');

module.exports = function loadInboundMessage() {
  return (req, res, next) => {
    // If this is not a retry request, we have to create a new inbound message
    if (!req.isARetryRequest()) {
      return next();
    }

    // TODO: This should be moved to receive-message/params middleware
    if (req.inboundMessageText) {
      req.userCommand = req.inboundMessageText.trim();
    }

    return req.conversation.loadInboundMessageAndUpdateMetadataByRequestId(req.metadata.requestId,
      req.metadata)
      .then((message) => {
        req.inboundMessage = message;

        return next();
      })
      .catch(err => helpers.sendErrorResponse(res, err));
  };
};<commit_msg>use new Message.updateInboundMessageMetadataByRequestId static method<commit_after>'use strict';

const helpers = require('../../helpers');
const Message = require('../../../app/models/Message');

module.exports = function loadInboundMessage() {
  return (req, res, next) => {
    // If this is not a retry request, we have to create a new inbound message
    if (!req.isARetryRequest()) {
      return next();
    }

    // TODO: This should be moved to receive-message/params middleware
    if (req.inboundMessageText) {
      req.userCommand = req.inboundMessageText.trim();
    }

    return Message.updateInboundMessageMetadataByRequestId(req.metadata.requestId,
      req.metadata)
      .then((message) => {
        req.inboundMessage = message;

        return next();
      })
      .catch(err => helpers.sendErrorResponse(res, err));
  };
};
{'fraction_non_alphanumeric': 0.13262764632627647, 'fraction_numerical': 0.0, 'mean_word_length': 3.058080808080808, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4643377', 'n_tokens_mistral': 463, 'n_tokens_neox': 458, 'n_words': 115}