Skip to content

Commit

Permalink
feat(album): envia email notificando sobre marcação em foto
Browse files Browse the repository at this point in the history
  • Loading branch information
guiseek committed Dec 28, 2024
1 parent 67e6f61 commit 442be65
Show file tree
Hide file tree
Showing 35 changed files with 335 additions and 143 deletions.
24 changes: 24 additions & 0 deletions apps/devmx/public/portal-devpr-mx.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion apps/server/src/assets/templates/user-code.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div>
<h2>{{value}}</h2>
<h3>{{value}}</h3>
</div>

12 changes: 12 additions & 0 deletions apps/server/src/assets/templates/user-tag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div>
<h3>Olá {{displayName}}, tudo beleza?</h3>

<p>
Você foi marcado(a) em uma foto da comunidade, acesse o album
<a href="{{url}}">{{title}}</a> para ver
</p>
</div>

<footer>
<img src="https://devparana.mx/portal-devpr-mx.svg" alt="Portal devparana.mx">
</footer>
11 changes: 8 additions & 3 deletions packages/album/data-access/src/lib/application/photo.facade.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { createClientProvider, EntityFacade } from '@devmx/shared-data-access';
import { Photo, EditablePhoto } from '@devmx/shared-api-interfaces';
import { take } from 'rxjs';
import {
Photo,
EditablePhoto,
UpdatePhotoTags,
} from '@devmx/shared-api-interfaces';
import {
CreatePhotoUseCase,
DeletePhotoUseCase,
Expand All @@ -10,7 +15,7 @@ import {
UploadPhoto,
UploadPhotoUseCase,
} from '@devmx/album-domain/client';
import { take } from 'rxjs';


export class PhotoFacade extends EntityFacade<Photo> {
constructor(
Expand Down Expand Up @@ -59,7 +64,7 @@ export class PhotoFacade extends EntityFacade<Photo> {
return request$.pipe(take(1));
}

updateTags(data: EditablePhoto) {
updateTags(data: UpdatePhotoTags) {
this.onUpdate(this.updatePhotoTagsUseCase.execute(data));
}

Expand Down
4 changes: 2 additions & 2 deletions packages/album/data-source/src/lib/album.providers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { provideFacades, provideServices, provideUseCases } from './providers';
import { provideAlbum, providePhoto } from './providers';

export function provideAlbums() {
return [...provideServices(), ...provideUseCases(), ...provideFacades()];
return [...provideAlbum(), ...providePhoto()];
}
28 changes: 18 additions & 10 deletions packages/album/data-source/src/lib/application/photos.facade.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { PhotoDto, CreatePhotoDto, UpdatePhotoDto } from '../dtos';
import { PhotoDto, CreatePhotoDto, UpdatePhotoDto, UpdatePhotoTagsDto } from '../dtos';
import { Photo } from '@devmx/shared-api-interfaces';
import { plainToInstance } from 'class-transformer';
import {
CreatePhotoUseCase,
DeletePhotoUseCase,
FindPhotoByIDUseCase,
FindPhotosUseCase,
UpdatePhotoTagsUseCase,
UpdatePhotoUseCase,
} from '@devmx/album-domain/server';
import {
Expand All @@ -20,7 +21,8 @@ export class PhotosFacade {
private findPhotosUseCase: FindPhotosUseCase,
private findPhotoByIDUseCase: FindPhotoByIDUseCase,
private updatePhotoUseCase: UpdatePhotoUseCase,
private deletePhotoUseCase: DeletePhotoUseCase
private deletePhotoUseCase: DeletePhotoUseCase,
private updatePhotoTagsUseCase: UpdatePhotoTagsUseCase
) {}

async create(data: CreatePhotoDto) {
Expand All @@ -30,23 +32,28 @@ export class PhotosFacade {

async find(params: QueryParamsDto<Photo>) {
const { data, items, pages } = await this.findPhotosUseCase.execute(params);
const albums = plainToInstance(PhotoDto, data);
return new PageDto(albums, items, pages);
const photos = plainToInstance(PhotoDto, data);
return new PageDto(photos, items, pages);
}

async findOne(id: string) {
const album = await this.findPhotoByIDUseCase.execute(id);
return plainToInstance(PhotoDto, album);
const photo = await this.findPhotoByIDUseCase.execute(id);
return plainToInstance(PhotoDto, photo);
}

async update(id: string, data: UpdatePhotoDto) {
const album = await this.updatePhotoUseCase.execute({ ...data, id });
return plainToInstance(PhotoDto, album);
const photo = await this.updatePhotoUseCase.execute({ ...data, id });
return plainToInstance(PhotoDto, photo);
}

async updateTags(id: string, data: UpdatePhotoTagsDto) {
const photo = await this.updatePhotoTagsUseCase.execute({ ...data, id });
return plainToInstance(PhotoDto, photo);
}

async delete(id: string) {
const album = this.deletePhotoUseCase.execute(id);
return plainToInstance(PhotoDto, album);
const photo = this.deletePhotoUseCase.execute(id);
return plainToInstance(PhotoDto, photo);
}
}

Expand All @@ -57,5 +64,6 @@ export function providePhotosFacade() {
FindPhotoByIDUseCase,
UpdatePhotoUseCase,
DeletePhotoUseCase,
UpdatePhotoTagsUseCase
]);
}
13 changes: 7 additions & 6 deletions packages/album/data-source/src/lib/dtos/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './album';
export * from './create-album';
export * from './create-photo';
export * from './photo';
export * from './update-album';
export * from './update-photo';
export * from './album';
export * from './create-album';
export * from './create-photo';
export * from './photo';
export * from './update-album';
export * from './update-photo-tags';
export * from './update-photo';
42 changes: 42 additions & 0 deletions packages/album/data-source/src/lib/dtos/update-photo-tags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { IsNotEmpty, IsNumber, IsOptional } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { UserTagDto } from '@devmx/shared-data-source';
import { Exclude, Type } from 'class-transformer';
import {
UserTag,
ImageMimeType,
UpdatePhotoTags,
} from '@devmx/shared-api-interfaces';

export class UpdatePhotoTagsDto implements UpdatePhotoTags {
id: string;

@Exclude()
data: string;

@IsNumber()
@ApiProperty()
@Type(() => Number)
width: number;

@IsNumber()
@ApiProperty()
@Type(() => Number)
height: number;

@IsNotEmpty()
album: string;

@IsOptional()
@ApiPropertyOptional()
type: ImageMimeType;

@IsOptional()
@ApiPropertyOptional()
caption?: string;

@Type(() => UserTagDto)
tags: UserTag[] = [];

owner: string;
}
23 changes: 23 additions & 0 deletions packages/album/data-source/src/lib/providers/album.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { provideAlbumsMongoService } from '../infrastructure';
import { provideAlbumsFacade } from '../application';
import {
provideCreateAlbumUseCase,
provideDeleteAlbumUseCase,
provideFindAlbumByIDUseCase,
provideFindAlbumsUseCase,
provideUpdateAlbumUseCase,
} from '@devmx/album-domain/server';

export function provideAlbum() {
return [
provideAlbumsMongoService(),

provideCreateAlbumUseCase(),
provideFindAlbumsUseCase(),
provideFindAlbumByIDUseCase(),
provideUpdateAlbumUseCase(),
provideDeleteAlbumUseCase(),

provideAlbumsFacade()
];
}
5 changes: 0 additions & 5 deletions packages/album/data-source/src/lib/providers/facades.ts

This file was deleted.

5 changes: 2 additions & 3 deletions packages/album/data-source/src/lib/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './facades';
export * from './services';
export * from './use-cases';
export * from './album';
export * from './photo';
Loading

0 comments on commit 442be65

Please sign in to comment.