var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.deleteMessage = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _createDeleteQuery = require("../sqlite-utils/createDeleteQuery");
var _SqliteClient = require("../SqliteClient");
var deleteMessage = exports.deleteMessage = function () {
  var _ref2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(_ref) {
    var _ref$execute, execute, id, queries;
    return _regenerator["default"].wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          _ref$execute = _ref.execute, execute = _ref$execute === void 0 ? true : _ref$execute, id = _ref.id;
          queries = [];
          queries.push((0, _createDeleteQuery.createDeleteQuery)('reactions', {
            messageId: id
          }));
          queries.push((0, _createDeleteQuery.createDeleteQuery)('messages', {
            id: id
          }));
          _SqliteClient.SqliteClient.logger == null || _SqliteClient.SqliteClient.logger('info', 'deleteMessage', {
            execute: execute,
            id: id
          });
          if (!execute) {
            _context.next = 8;
            break;
          }
          _context.next = 8;
          return _SqliteClient.SqliteClient.executeSqlBatch(queries);
        case 8:
          return _context.abrupt("return", queries);
        case 9:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
  return function deleteMessage(_x) {
    return _ref2.apply(this, arguments);
  };
}();
//# sourceMappingURL=deleteMessage.js.map