redai-automation-web-sdk
Version:
TypeScript SDK for RedAI Automation Web API - Zalo Personal automation, messaging, advanced sticker search, and bulk operations. 100% compatible with automation-web backend. v1.8.1: Updated GroupInfo interface to match backend controller with complete gro
52 lines • 1.85 kB
JavaScript
;
/**
* Session Proxy service for managing proxy assignments to sessions
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionProxyService = void 0;
/**
* Session Proxy service class
*/
class SessionProxyService {
constructor(httpClient) {
this.httpClient = httpClient;
}
/**
* Assign proxy cho session và kích hoạt lại instance với proxy mới
*
* Flow:
* 1. Kiểm tra session và proxy tồn tại
* 2. Cập nhật proxy cho session trong database
* 3. Dừng listener cũ (nếu đang chạy)
* 4. Xóa instance cũ khỏi instance manager
* 5. Tạo instance mới với proxy được chỉ định
* 6. Khởi động listener mới với proxy
*
* @param request - Session ID và Proxy ID
* @returns Response với thông tin assign proxy
* @throws Error nếu session chưa đăng nhập hoặc proxy không khả dụng
*
* @example
* ```typescript
* const result = await sessionProxyService.assignProxyToSession({
* sessionId: 'session-175ae5b3-7c5c-4ee4-991f-67dc63156736',
* proxyId: 'f47ac10b-58cc-4372-a567-0e02b2c3d479',
* });
*
* if (result.code === 200 && result.result?.success) {
* console.log('Proxy đã được gắn thành công:', result.result.message);
* } else {
* console.error('Gắn proxy thất bại:', result.error || result.message);
* }
* ```
*/
async assignProxyToSession(request) {
const response = await this.httpClient.post('/proxy/session/assign', {
sessionId: request.sessionId,
proxyId: request.proxyId,
});
return response;
}
}
exports.SessionProxyService = SessionProxyService;
//# sourceMappingURL=session-proxy.service.js.map