"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); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvitesController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const passport_1 = require("@nestjs/passport");
const groups_service_1 = require("../groups/groups.service");
const invite_response_dto_1 = require("../groups/dto/invite-response.dto");
const public_decorator_1 = require("../../common/decorators/public.decorator");
const current_user_decorator_1 = require("../../common/decorators/current-user.decorator");
let InvitesController = class InvitesController {
    constructor(groupsService) {
        this.groupsService = groupsService;
    }
    preview(token) {
        return this.groupsService.getInvitePreview(token);
    }
    accept(token, user) {
        return this.groupsService.acceptInvite(token, user.id);
    }
};
exports.InvitesController = InvitesController;
__decorate([
    (0, public_decorator_1.Public)(),
    (0, common_1.Get)(':token'),
    (0, swagger_1.ApiParam)({ name: 'token' }),
    (0, swagger_1.ApiOperation)({ summary: 'Preview a group invite (public)' }),
    (0, swagger_1.ApiResponse)({ status: 200, type: invite_response_dto_1.InvitePreviewDto }),
    __param(0, (0, common_1.Param)('token')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], InvitesController.prototype, "preview", null);
__decorate([
    (0, common_1.Post)(':token/accept'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, common_1.UseGuards)((0, passport_1.AuthGuard)('jwt')),
    (0, swagger_1.ApiBearerAuth)(),
    (0, swagger_1.ApiParam)({ name: 'token' }),
    (0, swagger_1.ApiOperation)({ summary: 'Accept a group invite (must match invited email)' }),
    __param(0, (0, common_1.Param)('token')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], InvitesController.prototype, "accept", null);
exports.InvitesController = InvitesController = __decorate([
    (0, swagger_1.ApiTags)('Invites'),
    (0, common_1.Controller)({ path: 'invites', version: '1' }),
    __metadata("design:paramtypes", [groups_service_1.GroupsService])
], InvitesController);
//# sourceMappingURL=invites.controller.js.map