mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
add contact page
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AttachmentRemoteDataSourceService } from 'src/app/module/chat/data/data-source/attachment/attachment-remote-data-source.service'
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
import { convertBlobToDataURL } from 'src/app/utils/ToBase64';
|
||||
import { AttachmentLocalDataSource } from 'src/app/module/chat/data/data-source/attachment/attachment-local-data-source.service'
|
||||
import { MessageAttachmentByMessageIdInput } from './message-attachment-by-message-id.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DownloadMessageAttachmentUserCaseService {
|
||||
|
||||
constructor(
|
||||
private AttachmentRemoteDataSourceService: AttachmentRemoteDataSourceService,
|
||||
private AttachmentLocalDataSource: AttachmentLocalDataSource
|
||||
) { }
|
||||
|
||||
async execute(input: MessageAttachmentByMessageIdInput) {
|
||||
const result = await this.AttachmentRemoteDataSourceService.getAttachment(input.$messageId)
|
||||
return result.asyncMap(async (e) => {
|
||||
|
||||
const dataUrl = await convertBlobToDataURL(e)
|
||||
Logger.info('downloaded file #1', {
|
||||
data: dataUrl.slice(0, 100)+'...',
|
||||
context: 'DownloadMessageAttachmentUserCaseService'
|
||||
})
|
||||
|
||||
this.AttachmentLocalDataSource.insert({
|
||||
$messageId: input.$messageId,
|
||||
id: input.id,
|
||||
file: dataUrl
|
||||
})
|
||||
|
||||
return dataUrl
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { AttachmentRemoteDataSourceService } from 'src/app/module/chat/data/data
|
||||
import { AttachmentLocalDataSource } from 'src/app/module/chat/data/data-source/attachment/attachment-local-data-source.service'
|
||||
import { convertBlobToDataURL } from 'src/app/utils/ToBase64';
|
||||
import { Result } from 'neverthrow';
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
|
||||
const MessageAttachmentByMessageIdSchema = z.object({
|
||||
$messageId: z.number(),
|
||||
@@ -33,10 +34,13 @@ export class MessageAttachmentByMessageIdUseCase {
|
||||
return getLocalAttachment.map(e => e.file)
|
||||
}
|
||||
} else {
|
||||
const result = await this.AttachmentRemoteDataSourceService.getAttachment(input)
|
||||
const result = await this.AttachmentRemoteDataSourceService.getAttachment(input.id)
|
||||
return result.asyncMap(async (e) => {
|
||||
|
||||
const dataUrl = await convertBlobToDataURL(e)
|
||||
Logger.info('downloaded file', {
|
||||
data: dataUrl.slice(0, 100)+'...'
|
||||
})
|
||||
|
||||
this.AttachmentLocalDataSource.insert({
|
||||
$messageId: input.$messageId,
|
||||
|
||||
Reference in New Issue
Block a user