life-manager/codebase/features/escort/backend/tryst-boost-webhook.controller.ts
Claude Code 753a39b421 feat(escort): Add webhook handling for TrystBoost premium feature upgrades and promotions
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-03-20 06:51:52 -07:00

36 lines
1.3 KiB
TypeScript

import { Body, Controller, Post, UseGuards } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { AdPlatform } from '@life-platform/shared';
import { WebhookSignatureGuard } from './guards/webhook-signature.guard';
import { TrystBoostWebhookDto } from './dto/tryst-boost-webhook.dto';
import { AdCheckInsService } from './ad-checkins.service';
@ApiTags('Escort Webhooks')
@Controller('escort/webhooks')
export class TrystBoostWebhookController {
constructor(private readonly adCheckInsService: AdCheckInsService) {}
@Post('tryst-boost')
@UseGuards(WebhookSignatureGuard)
async handleTrystBoostRefreshed(@Body() dto: TrystBoostWebhookDto) {
const checkedInAt = dto.cycle.reactivatedAt;
const notes = [
`Cycle #${dto.cycle.number}: ${dto.cycle.action}`,
`Boost active: ${dto.boost.active}, expires: ${dto.boost.expiresAt}`,
`Next refresh: ${dto.boost.nextRefreshAt}`,
dto.extension ? `Extension: ${dto.extension.name} v${dto.extension.version}` : null,
]
.filter(Boolean)
.join(' | ');
const entry = await this.adCheckInsService.createEntry({
platform: AdPlatform.Tryst,
checkedInAt,
notes,
showOnCalendar: false,
});
return { logged: true, checkinId: entry.id };
}
}