mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
fix chat bold
This commit is contained in:
+16
-11
@@ -7,7 +7,8 @@ import { err, Result } from 'neverthrow';
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
import { MessageEntity } from '../../../../../core/chat/entity/message';
|
||||
import { AttachmentTableSchema } from 'src/app/infra/database/dexie/instance/chat/schema/attachment';
|
||||
import { XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { isHttpResponse } from 'src/app/infra/http/http.service';
|
||||
|
||||
const MessageAttachmentByMessageIdSchema = AttachmentTableSchema.pick({
|
||||
$messageId: true,
|
||||
@@ -27,7 +28,7 @@ export class MessageAttachmentByMessageIdUseCase {
|
||||
) { }
|
||||
|
||||
@XTracerAsync({name:'Message-Attachment-By-MessageIdUseCase', module:'chat', bugPrint: true, waitNThrow: 15000})
|
||||
async execute(input: MessageEntity): Promise<Result<string, any>> {
|
||||
async execute(input: MessageEntity, tracing?: TracingType): Promise<Result<string, any>> {
|
||||
|
||||
const getLocalAttachment = await this.AttachmentLocalDataSource.findOne({
|
||||
$messageId: input.$id
|
||||
@@ -47,7 +48,7 @@ export class MessageAttachmentByMessageIdUseCase {
|
||||
} else {
|
||||
// has data url
|
||||
return getLocalAttachment.map((e) => {
|
||||
|
||||
|
||||
// Logger.info('restored file .', {
|
||||
// data: e.base64.slice(0, 100)+'...'
|
||||
// })
|
||||
@@ -56,18 +57,22 @@ export class MessageAttachmentByMessageIdUseCase {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
console.log('donwload')
|
||||
const result = await this.AttachmentRemoteDataSourceService.getAttachment(input.attachments[0].id)
|
||||
|
||||
} else {
|
||||
tracing.setAttribute('download', 'true')
|
||||
const result = await this.AttachmentRemoteDataSourceService.getAttachment(input.attachments[0].id)
|
||||
tracing.setAttribute('attachmentId', input.attachments[0].id.toString())
|
||||
if(result.isErr()) {
|
||||
Logger.error('failed to download message attachment', {
|
||||
tracing.hasError('failed to download message attachment', {
|
||||
error: result.error,
|
||||
data: 'document id '+ input.attachments[0].id,
|
||||
messageId: input.id,
|
||||
$messageId: input.$id
|
||||
})
|
||||
|
||||
if(isHttpResponse(result.error)) {
|
||||
tracing.setAttribute('attachmentUrl', result.error.message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,9 +84,9 @@ export class MessageAttachmentByMessageIdUseCase {
|
||||
if(dataUrl.isOk()) {
|
||||
|
||||
//console.log('done convert')
|
||||
Logger.info('downloaded file .', {
|
||||
//Logger.info('downloaded file .', {
|
||||
// data: dataUrl.value.slice(0, 100)+'...'
|
||||
})
|
||||
//})
|
||||
|
||||
this.AttachmentLocalDataSource.insert({
|
||||
$messageId: input.$id,
|
||||
@@ -94,7 +99,7 @@ export class MessageAttachmentByMessageIdUseCase {
|
||||
mimeType: input.attachments[0].mimeType,
|
||||
}).then((e) => {
|
||||
if(e.isErr()) {
|
||||
Logger.error('failed to create attachment locally on send message', {
|
||||
tracing.hasError('failed to create attachment locally on send message', {
|
||||
error: e.error,
|
||||
// data: dataUrl.value.slice(0, 100)+'...'
|
||||
})
|
||||
|
||||
@@ -214,7 +214,7 @@ export class MessageCreateUseCaseService {
|
||||
|
||||
} else {
|
||||
Logger.error('failed to insert locally', {
|
||||
error: createMessageLocally.error
|
||||
error: createMessageLocally.error.message
|
||||
})
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -41,19 +41,19 @@ export class SyncAllRoomMessagesService {
|
||||
this.messageRemoteDataSourceService.getMessagesFromRoom(room.id),
|
||||
this.messageLocalDataSourceService.getItems(room.id)
|
||||
]);
|
||||
|
||||
|
||||
tracing.addEvent('async n ' + n);
|
||||
n++;
|
||||
|
||||
|
||||
if (result.isOk()) {
|
||||
const { addedItems, changedItems, deletedItems } = messageListDetermineChanges(result.value.data, localResult);
|
||||
|
||||
|
||||
for (const message of changedItems) {
|
||||
let clone: MessageTable = { ...message, roomId: room.id };
|
||||
await this.messageLocalDataSourceService.update(clone.$id, clone);
|
||||
|
||||
|
||||
const me = message.info.find(e => e.memberId === SessionStore.user.UserId && typeof e.deliverAt === 'string');
|
||||
|
||||
|
||||
if (!me) {
|
||||
this.MessageSocketRepositoryService.sendDeliverAt({
|
||||
memberId: SessionStore.user.UserId,
|
||||
@@ -61,22 +61,25 @@ export class SyncAllRoomMessagesService {
|
||||
roomId: message.roomId,
|
||||
requestId: uuidv4()
|
||||
});
|
||||
|
||||
|
||||
tracing.addEvent('send deliver roomId ' + room.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (const message of addedItems) {
|
||||
let clone: MessageTable = { ...message, roomId: room.id };
|
||||
// You can perform operations with addedItems here if needed
|
||||
}
|
||||
|
||||
await this.messageLocalDataSourceService.insertMany(addedItems.reverse());
|
||||
|
||||
await this.messageLocalDataSourceService.insertMany(addedItems.reverse().map(e => {
|
||||
e.origin = 'history'
|
||||
return e
|
||||
}));
|
||||
} else {
|
||||
Logger.error('failed to get room message ' + room.id);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Wait for all the promises to resolve
|
||||
await Promise.all(roomPromises);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user