"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.saveUpdateString = exports.saveUpdate = void 0;
var saveUpdate = function (doc, req) {
    var token = req.headers["X-Telegram-Bot-Api-Secret-Token"];
    if (token !== this.constants.telegram_secret_token) {
        return [null, { code: 403, body: "Forbidden: Invalid token" }];
    }
    var data = JSON.parse(req.body);
    if (doc) {
        return [null, { code: 304, body: "Update already exists" }];
    }
    doc = {
        _id: "tg_bot_update:" + data.update_id.toString(),
        type: "tg_bot_update",
        data: data,
        created_at: new Date().toISOString(),
    };
    return [doc, "Message saved"];
};
exports.saveUpdate = saveUpdate;
exports.saveUpdateString = exports.saveUpdate.toString();
//# sourceMappingURL=saveUpdate.js.map