Spaces:
Running
Running
File size: 6,894 Bytes
9f29339 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | "use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var IntegrationsController_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntegrationsController = void 0;
const common_1 = require("@nestjs/common");
const integrations_service_1 = require("./integrations.service");
let IntegrationsController = IntegrationsController_1 = class IntegrationsController {
integrationsService;
logger = new common_1.Logger(IntegrationsController_1.name);
constructor(integrationsService) {
this.integrationsService = integrationsService;
}
async googleCallback(code, state, error, res) {
if (error) {
this.logger.warn(`Google OAuth error: ${error}`);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=google_calendar&status=error`);
}
try {
const result = await this.integrationsService.handleOAuthCallback(code, state);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=${result.provider}&status=${result.success ? "connected" : "error"}`);
}
catch (err) {
this.logger.error(`Google OAuth callback failed: ${err.message}`);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=google_calendar&status=error`);
}
}
async outlookCallback(code, state, error, res) {
if (error) {
this.logger.warn(`Outlook OAuth error: ${error}`);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=outlook&status=error`);
}
try {
const result = await this.integrationsService.handleOAuthCallback(code, state);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=${result.provider}&status=${result.success ? "connected" : "error"}`);
}
catch (err) {
this.logger.error(`Outlook OAuth callback failed: ${err.message}`);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=outlook&status=error`);
}
}
async zoomCallback(code, state, error, res) {
if (error) {
this.logger.warn(`Zoom OAuth error: ${error}`);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=zoom&status=error`);
}
try {
const result = await this.integrationsService.handleOAuthCallback(code, state);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=${result.provider}&status=${result.success ? "connected" : "error"}`);
}
catch (err) {
this.logger.error(`Zoom OAuth callback failed: ${err.message}`);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=zoom&status=error`);
}
}
async riversideCallback(code, state, error, res) {
if (error) {
this.logger.warn(`Riverside OAuth error: ${error}`);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=riverside&status=error`);
}
try {
const result = await this.integrationsService.handleOAuthCallback(code, state);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=${result.provider}&status=${result.success ? "connected" : "error"}`);
}
catch (err) {
this.logger.error(`Riverside OAuth callback failed: ${err.message}`);
return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=riverside&status=error`);
}
}
};
exports.IntegrationsController = IntegrationsController;
__decorate([
(0, common_1.Get)("google/callback"),
__param(0, (0, common_1.Query)("code")),
__param(1, (0, common_1.Query)("state")),
__param(2, (0, common_1.Query)("error")),
__param(3, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String, String, Object]),
__metadata("design:returntype", Promise)
], IntegrationsController.prototype, "googleCallback", null);
__decorate([
(0, common_1.Get)("outlook/callback"),
__param(0, (0, common_1.Query)("code")),
__param(1, (0, common_1.Query)("state")),
__param(2, (0, common_1.Query)("error")),
__param(3, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String, String, Object]),
__metadata("design:returntype", Promise)
], IntegrationsController.prototype, "outlookCallback", null);
__decorate([
(0, common_1.Get)("zoom/callback"),
__param(0, (0, common_1.Query)("code")),
__param(1, (0, common_1.Query)("state")),
__param(2, (0, common_1.Query)("error")),
__param(3, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String, String, Object]),
__metadata("design:returntype", Promise)
], IntegrationsController.prototype, "zoomCallback", null);
__decorate([
(0, common_1.Get)("riverside/callback"),
__param(0, (0, common_1.Query)("code")),
__param(1, (0, common_1.Query)("state")),
__param(2, (0, common_1.Query)("error")),
__param(3, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, String, String, Object]),
__metadata("design:returntype", Promise)
], IntegrationsController.prototype, "riversideCallback", null);
exports.IntegrationsController = IntegrationsController = IntegrationsController_1 = __decorate([
(0, common_1.Controller)("api/integrations"),
__metadata("design:paramtypes", [integrations_service_1.IntegrationsService])
], IntegrationsController);
//# sourceMappingURL=integrations.controller.js.map |