Skip to content

Commit ecb22d8

Browse files
kelvinsbfilipepacheco
authored andcommitted
fix: suggestions about separation
1 parent df951c1 commit ecb22d8

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

src/decorators/UserDecorator/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/guards/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ async function isRightSessionRole(
4141
return false;
4242
}
4343

44-
export { canActivate, isRightSessionRole };
44+
export { canActivate };

src/shelter/shelter.controller.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ShelterService } from './shelter.service';
1616
import { ServerResponse } from '../utils';
1717
import { StaffGuard } from '@/guards/staff.guard';
1818
import { ApplyUser } from '@/guards/apply-user.guard';
19-
import { UserDecorator } from '@/decorators/UserDecorator';
19+
import { UserDecorator } from '@/decorators/UserDecorator/user.decorator';
2020

2121
@ApiTags('Abrigos')
2222
@Controller('shelters')
@@ -40,7 +40,9 @@ export class ShelterController {
4040
@UseGuards(ApplyUser)
4141
async show(@UserDecorator() user: any, @Param('id') id: string) {
4242
try {
43-
const data = await this.shelterService.show(id, user);
43+
const isLogged =
44+
Boolean(user) && Boolean(user?.sessionId) && Boolean(user?.userId);
45+
const data = await this.shelterService.show(id, isLogged);
4446
return new ServerResponse(200, 'Successfully get shelter', data);
4547
} catch (err: any) {
4648
this.logger.error(`Failed to get shelter: ${err}`);

src/shelter/shelter.service.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ export class ShelterService {
6060
});
6161
}
6262

63-
async show(id: string, user: any) {
64-
const isLogged =
65-
Boolean(user) && Boolean(user?.sessionId) && Boolean(user?.userId);
66-
63+
async show(id: string, shouldShowContact: boolean) {
6764
const data = await this.prismaService.shelter.findFirst({
6865
where: {
6966
id,
@@ -75,7 +72,7 @@ export class ShelterService {
7572
pix: true,
7673
shelteredPeople: true,
7774
capacity: true,
78-
contact: isLogged,
75+
contact: shouldShowContact,
7976
petFriendly: true,
8077
prioritySum: true,
8178
latitude: true,

0 commit comments

Comments
 (0)