Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEV-3520] payment request supportIssue #1893

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[DEV-3520] Refactoring 2
  • Loading branch information
Yannick1712 committed Jan 14, 2025
commit 4410e82d7ee5a4e9e469616433a49e9aa5d5701a
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ export class SupportIssueService {
private readonly transactionRequestService: TransactionRequestService,
) {}

async createTransactionRequestIssue(uid: string, dto: CreateSupportIssueBaseDto): Promise<SupportIssueDto> {
const transactionRequest = await this.transactionRequestService.getTransactionRequestByUid(uid, {
user: { userData: true },
});
async createTransactionRequestIssue(dto: CreateSupportIssueBaseDto): Promise<SupportIssueDto> {
if (!dto?.transaction?.quoteUid) throw new BadRequestException('JWT Token or quoteUid missing');
const transactionRequest = await this.transactionRequestService.getTransactionRequestByUid(
dto.transaction.quoteUid,
{ user: { userData: true } },
);
if (!transactionRequest) throw new NotFoundException('TransactionRequest not found');

return this.createIssueInternal(transactionRequest.userData, dto, transactionRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { JwtPayload } from 'src/shared/auth/jwt-payload.interface';
import { OptionalJwtAuthGuard } from 'src/shared/auth/optional.guard';
import { RoleGuard } from 'src/shared/auth/role.guard';
import { UserRole } from 'src/shared/auth/user-role.enum';
import { CreateSupportIssueBaseDto, CreateSupportIssueDto, CreateSupportIssueSupportDto } from './dto/create-support-issue.dto';
import { CreateSupportIssueDto, CreateSupportIssueSupportDto } from './dto/create-support-issue.dto';
import { CreateSupportMessageDto } from './dto/create-support-message.dto';
import { GetSupportIssueFilter } from './dto/get-support-issue.dto';
import { SupportIssueDto, SupportMessageDto } from './dto/support-issue.dto';
Expand All @@ -23,9 +23,11 @@ export class SupportIssueController {

@Post()
@ApiBearerAuth()
@UseGuards(AuthGuard(), new RoleGuard(UserRole.ACCOUNT))
async createIssue(@GetJwt() jwt: JwtPayload, @Body() dto: CreateSupportIssueDto): Promise<SupportIssueDto> {
return this.supportIssueService.createIssue(jwt.account, { ...dto, author: CustomerAuthor });
@UseGuards(OptionalJwtAuthGuard)
async createIssue(@Body() dto: CreateSupportIssueDto, @GetJwt() jwt?: JwtPayload): Promise<SupportIssueDto> {
return jwt?.account
? this.supportIssueService.createIssue(jwt.account, { ...dto, author: CustomerAuthor })
: this.supportIssueService.createTransactionRequestIssue(dto);
}

@Post('support')
Expand All @@ -39,14 +41,6 @@ export class SupportIssueController {
return this.supportIssueService.createIssue(+userDataId, dto);
}

@Post('transaction/request/:uid')
async createTransactionRequestIssue(
@Param('uid') uid: string,
@Body() dto: CreateSupportIssueBaseDto,
): Promise<SupportIssueDto> {
return this.supportIssueService.createTransactionRequestIssue(uid, { ...dto, author: CustomerAuthor });
}

@Get()
@ApiBearerAuth()
@UseGuards(AuthGuard(), new RoleGuard(UserRole.ACCOUNT))
Expand Down
Loading