Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion dashboard/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const API_BASE_URL = '/api';
export interface Session {
id: string;
name: string;
status: 'created' | 'idle' | 'initializing' | 'connecting' | 'qr_ready' | 'ready' | 'disconnected';
status: 'created' | 'idle' | 'initializing' | 'connecting' | 'qr_ready' | 'ready' | 'disconnected' | 'failed';
phone?: string;
pushName?: string;
lastActive?: string;
Expand Down
6 changes: 3 additions & 3 deletions src/modules/channel/channel.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get, Post, Delete, Param, Body, Query } from '@nestjs/common';
import { Controller, Get, Post, Delete, Param, Body, Query, BadRequestException, NotFoundException } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody, ApiQuery } from '@nestjs/swagger';
import { SessionService } from '../session/session.service';

Expand All @@ -10,7 +10,7 @@ export class ChannelController {
private getEngine(sessionId: string) {
const engine = this.sessionService.getEngine(sessionId);
if (!engine) {
throw new Error('Session is not started');
throw new BadRequestException('Session is not started');
}
return engine;
}
Expand Down Expand Up @@ -41,7 +41,7 @@ export class ChannelController {
const engine = this.getEngine(sessionId);
const channel = await engine.getChannelById(channelId);
if (!channel) {
throw new Error(`Channel ${channelId} not found`);
throw new NotFoundException(`Channel ${channelId} not found`);
}
return channel;
}
Expand Down
16 changes: 8 additions & 8 deletions src/modules/contact/contact.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get, Post, Delete, Param, HttpCode, HttpStatus } from '@nestjs/common';
import { Controller, Get, Post, Delete, Param, HttpCode, HttpStatus, BadRequestException, NotFoundException } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger';
import { SessionService } from '../session/session.service';

Expand All @@ -19,7 +19,7 @@ export class ContactController {
async findAll(@Param('sessionId') sessionId: string) {
const engine = this.sessionService.getEngine(sessionId);
if (!engine) {
throw new Error('Session is not started');
throw new BadRequestException('Session is not started');
}
return engine.getContacts();
}
Expand All @@ -36,11 +36,11 @@ export class ContactController {
async findOne(@Param('sessionId') sessionId: string, @Param('contactId') contactId: string) {
const engine = this.sessionService.getEngine(sessionId);
if (!engine) {
throw new Error('Session is not started');
throw new BadRequestException('Session is not started');
}
const contact = await engine.getContactById(contactId);
if (!contact) {
throw new Error(`Contact ${contactId} not found`);
throw new NotFoundException(`Contact ${contactId} not found`);
}
return contact;
}
Expand All @@ -56,7 +56,7 @@ export class ContactController {
async checkNumber(@Param('sessionId') sessionId: string, @Param('number') number: string) {
const engine = this.sessionService.getEngine(sessionId);
if (!engine) {
throw new Error('Session is not started');
throw new BadRequestException('Session is not started');
}
const exists = await engine.checkNumberExists(number);
return {
Expand All @@ -79,7 +79,7 @@ export class ContactController {
async getProfilePicture(@Param('sessionId') sessionId: string, @Param('contactId') contactId: string) {
const engine = this.sessionService.getEngine(sessionId);
if (!engine) {
throw new Error('Session is not started');
throw new BadRequestException('Session is not started');
}
const url = await engine.getProfilePicture(contactId);
return { url };
Expand All @@ -97,7 +97,7 @@ export class ContactController {
async blockContact(@Param('sessionId') sessionId: string, @Param('contactId') contactId: string) {
const engine = this.sessionService.getEngine(sessionId);
if (!engine) {
throw new Error('Session is not started');
throw new BadRequestException('Session is not started');
}
await engine.blockContact(contactId);
return { success: true, message: 'Contact blocked' };
Expand All @@ -114,7 +114,7 @@ export class ContactController {
async unblockContact(@Param('sessionId') sessionId: string, @Param('contactId') contactId: string) {
const engine = this.sessionService.getEngine(sessionId);
if (!engine) {
throw new Error('Session is not started');
throw new BadRequestException('Session is not started');
}
await engine.unblockContact(contactId);
return { success: true, message: 'Contact unblocked' };
Expand Down
6 changes: 3 additions & 3 deletions src/modules/group/group.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get, Post, Put, Delete, Param, Body, HttpCode, HttpStatus } from '@nestjs/common';
import { Controller, Get, Post, Put, Delete, Param, Body, HttpCode, HttpStatus, BadRequestException, NotFoundException } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';
import { SessionService } from '../session/session.service';

Expand Down Expand Up @@ -44,7 +44,7 @@ export class GroupController {
const engine = this.getEngine(sessionId);
const group = await engine.getGroupInfo(groupId);
if (!group) {
throw new Error(`Group ${groupId} not found`);
throw new NotFoundException(`Group ${groupId} not found`);
}
return group;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ export class GroupController {
private getEngine(sessionId: string) {
const engine = this.sessionService.getEngine(sessionId);
if (!engine) {
throw new Error('Session is not started');
throw new BadRequestException('Session is not started');
}
return engine;
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/label/label.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get, Post, Delete, Param, Body } from '@nestjs/common';
import { Controller, Get, Post, Delete, Param, Body, BadRequestException, NotFoundException } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';
import { SessionService } from '../session/session.service';

Expand All @@ -10,7 +10,7 @@ export class LabelController {
private getEngine(sessionId: string) {
const engine = this.sessionService.getEngine(sessionId);
if (!engine) {
throw new Error('Session is not started');
throw new BadRequestException('Session is not started');
}
return engine;
}
Expand Down Expand Up @@ -42,7 +42,7 @@ export class LabelController {
const engine = this.getEngine(sessionId);
const label = await engine.getLabelById(labelId);
if (!label) {
throw new Error(`Label ${labelId} not found`);
throw new NotFoundException(`Label ${labelId} not found`);
}
return label;
}
Expand Down