mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-23 17:06:41 +02:00
chore: archive finance, mail, moodlit apps and rename voxel-lava
- Move finance, mail, moodlit to apps-archived for later development - Rename games/voxel-lava to games/voxelava 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c3c272abc9
commit
ace7fa8f7f
427 changed files with 0 additions and 0 deletions
|
|
@ -0,0 +1,81 @@
|
|||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Delete,
|
||||
Body,
|
||||
Param,
|
||||
Query,
|
||||
UseGuards,
|
||||
ParseUUIDPipe,
|
||||
} from '@nestjs/common';
|
||||
import { JwtAuthGuard, CurrentUser, CurrentUserData } from '@manacore/shared-nestjs-auth';
|
||||
import { AttachmentService } from './attachment.service';
|
||||
import { AttachmentQueryDto, CreateAttachmentDto, UploadUrlDto } from './dto/attachment.dto';
|
||||
|
||||
@Controller()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class AttachmentController {
|
||||
constructor(private readonly attachmentService: AttachmentService) {}
|
||||
|
||||
@Get('emails/:emailId/attachments')
|
||||
async findByEmail(
|
||||
@CurrentUser() user: CurrentUserData,
|
||||
@Param('emailId', ParseUUIDPipe) emailId: string
|
||||
) {
|
||||
const attachments = await this.attachmentService.findByEmailId(emailId, user.userId);
|
||||
return { attachments };
|
||||
}
|
||||
|
||||
@Get('attachments/:id')
|
||||
async findOne(@CurrentUser() user: CurrentUserData, @Param('id', ParseUUIDPipe) id: string) {
|
||||
const attachment = await this.attachmentService.findById(id, user.userId);
|
||||
if (!attachment) {
|
||||
return { attachment: null };
|
||||
}
|
||||
return { attachment };
|
||||
}
|
||||
|
||||
@Post('attachments')
|
||||
async create(@CurrentUser() user: CurrentUserData, @Body() dto: CreateAttachmentDto) {
|
||||
const attachment = await this.attachmentService.create({
|
||||
...dto,
|
||||
userId: user.userId,
|
||||
});
|
||||
return { attachment };
|
||||
}
|
||||
|
||||
@Delete('attachments/:id')
|
||||
async delete(@CurrentUser() user: CurrentUserData, @Param('id', ParseUUIDPipe) id: string) {
|
||||
await this.attachmentService.delete(id, user.userId);
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
// Get presigned URL for client-side upload
|
||||
@Post('attachments/upload-url')
|
||||
async getUploadUrl(@CurrentUser() user: CurrentUserData, @Body() dto: UploadUrlDto) {
|
||||
const result = await this.attachmentService.getUploadUrl(user.userId, dto);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Get presigned URL for downloading
|
||||
@Get('attachments/:id/download')
|
||||
async getDownloadUrl(
|
||||
@CurrentUser() user: CurrentUserData,
|
||||
@Param('id', ParseUUIDPipe) id: string
|
||||
) {
|
||||
const result = await this.attachmentService.getDownloadUrl(id, user.userId);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Mark attachment as uploaded (called after client uploads to presigned URL)
|
||||
@Post('attachments/:id/complete')
|
||||
async markUploaded(
|
||||
@CurrentUser() user: CurrentUserData,
|
||||
@Param('id', ParseUUIDPipe) id: string,
|
||||
@Body() body: { storageKey: string }
|
||||
) {
|
||||
const attachment = await this.attachmentService.markUploaded(id, user.userId, body.storageKey);
|
||||
return { attachment };
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue