Merge pull request #2 from Danakcorp/uploader

fix(upload): add log to test uploading
This commit is contained in:
saharbolboliankhah
2025-10-28 12:24:09 +03:30
committed by GitHub
3 changed files with 12 additions and 0 deletions
@@ -40,6 +40,7 @@ export class WildDuckBaseService {
const data = response.data; const data = response.data;
if ("success" in data && data.success === false) { if ("success" in data && data.success === false) {
this.logger.debug(`data--3->>>>> ${data}`);
throw this.handleMailServerError(data.error || "WildDuck API error", response.status); throw this.handleMailServerError(data.error || "WildDuck API error", response.status);
} }
@@ -54,6 +55,8 @@ export class WildDuckBaseService {
this.logger.error(`WildDuck API error data: ${JSON.stringify(error.response?.data)}`); this.logger.error(`WildDuck API error data: ${JSON.stringify(error.response?.data)}`);
if (error.response?.data?.error) { if (error.response?.data?.error) {
this.logger.debug(`error.response.data--3->>>>> ${error.response.data}`);
this.logger.debug(`error.response.data.error--3->>>>> ${error.response.data.error}`);
return throwError(() => this.handleMailServerError(error.response.data.error, error.response.status)); return throwError(() => this.handleMailServerError(error.response.data.error, error.response.status));
} }
@@ -72,6 +72,7 @@ export class WildDuckMessagesService extends WildDuckBaseService {
const url = this.buildUrl(`/users/${userId}/mailboxes/${mailboxId}/messages/${messageId}/message.eml`); const url = this.buildUrl(`/users/${userId}/mailboxes/${mailboxId}/messages/${messageId}/message.eml`);
this.logger.debug(`WildDuck GET: ${url}`); this.logger.debug(`WildDuck GET: ${url}`);
console.log("url-->>>>>", url);
return this.httpService return this.httpService
.get(url, { .get(url, {
responseType: "stream", responseType: "stream",
@@ -82,6 +83,7 @@ export class WildDuckMessagesService extends WildDuckBaseService {
.pipe( .pipe(
map((response) => { map((response) => {
this.logger.debug(`HTTP ${response.status}: ${response.config?.url}`); this.logger.debug(`HTTP ${response.status}: ${response.config?.url}`);
this.logger.debug(`HTTP size: ${response.headers["content-length"]}`);
return { return {
stream: response.data, stream: response.data,
contentType: response.headers["content-type"], contentType: response.headers["content-type"],
@@ -94,6 +96,9 @@ export class WildDuckMessagesService extends WildDuckBaseService {
this.logger.error(`WildDuck API error: ${error.message}`, error.stack); this.logger.error(`WildDuck API error: ${error.message}`, error.stack);
if (error.response?.data?.error) { if (error.response?.data?.error) {
this.logger.debug(`error.response.data--->>>>> ${error.response.data}`);
this.logger.debug(`error.response.data.error--->>>>> ${error.response.data.error}`);
return throwError(() => this.handleMailServerError(error.response.data.error, error.response.status)); return throwError(() => this.handleMailServerError(error.response.data.error, error.response.status));
} }
@@ -136,6 +141,8 @@ export class WildDuckMessagesService extends WildDuckBaseService {
this.logger.error(`WildDuck API error: ${error.message}`, error.stack); this.logger.error(`WildDuck API error: ${error.message}`, error.stack);
if (error.response?.data?.error) { if (error.response?.data?.error) {
this.logger.debug(`error.response.data--2->>>>> ${error.response.data}`);
this.logger.debug(`error.response.data.error--2->>>>> ${error.response.data.error}`);
return throwError(() => this.handleMailServerError(error.response.data.error, error.response.status)); return throwError(() => this.handleMailServerError(error.response.data.error, error.response.status));
} }
@@ -102,6 +102,8 @@ export class UploaderService {
private validateFile(file: File): void { private validateFile(file: File): void {
if (!file) throw new BadRequestException(UploaderMessage.UPLOAD_FILE_INVALID); if (!file) throw new BadRequestException(UploaderMessage.UPLOAD_FILE_INVALID);
this.logger.debug(`file.size----------: ${file.size}`);
this.logger.debug(`this.maxFileSize---------: ${this.maxFileSize}`);
if (file.size && file.size > this.maxFileSize) if (file.size && file.size > this.maxFileSize)
throw new BadRequestException(UploaderMessage.UPLOAD_FILE_TOO_LARGE.replace("[MAX_FILE_SIZE]", this.maxFileSize.toString())); throw new BadRequestException(UploaderMessage.UPLOAD_FILE_TOO_LARGE.replace("[MAX_FILE_SIZE]", this.maxFileSize.toString()));