mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
fix chage duplicate message
This commit is contained in:
@@ -27,7 +27,7 @@ const MemberSchema = z.object({
|
||||
export const RoomEntitySchema = z.object({
|
||||
$id: z.string(),
|
||||
id: z.string().uuid().optional(),
|
||||
roomName: z.string(),
|
||||
roomName: z.string().nullable(),
|
||||
createdBy: z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
|
||||
@@ -49,7 +49,7 @@ export const MessageEntitySchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string().nullable(),
|
||||
userPhoto: z.string().nullable().optional(),
|
||||
}).nullable(),
|
||||
reactions: z.object({
|
||||
id: z.string(),
|
||||
@@ -67,7 +67,8 @@ export const MessageEntitySchema = z.object({
|
||||
origin: z.enum(['history', 'local', 'incoming']).optional(),
|
||||
requestId: z.string().nullable().optional(),
|
||||
sendAttemp: z.number().optional(),
|
||||
hasAttachment: z.boolean().optional()
|
||||
hasAttachment: z.boolean().optional(),
|
||||
deviceId: z.string().nullable().optional()
|
||||
})
|
||||
|
||||
export type IMessage = z.infer<typeof MessageEntitySchema>;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { MessageEntity, IMessage } from "../entity/message";
|
||||
import { MessageOutPutDataDTO } from "src/app/core/chat/repository/dto/messageOutputDTO";
|
||||
import { MessageInputDTO } from "../usecase/message/message-create-use-case.service";
|
||||
import { getInstanceId } from "src/app/module/chat/domain/chat-service.service";
|
||||
|
||||
export class MessageMapper {
|
||||
static toDomain(DTO: MessageOutPutDataDTO) : MessageEntity {
|
||||
@@ -27,8 +28,8 @@ export class MessageMapper {
|
||||
docId: Number(e.docId) || 0,
|
||||
mimeType: e.mimeType,
|
||||
description: e.description
|
||||
}))[0] || {}
|
||||
|
||||
})) || [],
|
||||
deviceId: getInstanceId()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ export const MessageOutPutDataDTOSchema = z.object({
|
||||
applicationId: z.number().optional(),
|
||||
docId: z.number().optional(),
|
||||
id: z.string().optional()
|
||||
}))
|
||||
})),
|
||||
deviceId: z.string().nullable().optional()
|
||||
});
|
||||
|
||||
export type MessageOutPutDataDTO = z.infer<typeof MessageOutPutDataDTOSchema>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { z } from "zod";
|
||||
|
||||
const SocketRoomUpdateOutPutSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
roomName: z.string().min(1),
|
||||
roomName: z.string().nullable(),
|
||||
createdBy: z.string().nullable(), // Allowing null for createdBy
|
||||
createdAt: z.string().datetime(),
|
||||
expirationDate: z.string().nullable().optional(), // Allowing null and making it optional
|
||||
|
||||
@@ -3,7 +3,7 @@ import { filter, map } from 'rxjs/operators';
|
||||
import { z } from 'zod';
|
||||
import { IMessageSocketRepository } from 'src/app/core/chat/repository/message/message-socket-repository';
|
||||
import { MessageEntity } from '../../entity/message';
|
||||
import { InstanceId } from 'src/app/module/chat/domain/chat-service.service';
|
||||
import { getInstanceId } from 'src/app/module/chat/domain/chat-service.service';
|
||||
|
||||
|
||||
export const ListenMessageByRoomIdNewInputDTOSchema = z.object({
|
||||
@@ -25,8 +25,10 @@ export class ListenMessageByRoomIdNewUseCase {
|
||||
|
||||
return this.MessageSocketRepositoryService.listenToMessages().pipe(
|
||||
map(message => message.data),
|
||||
filter((message) => !message?.requestId?.startsWith(InstanceId) && message?.roomId == data.roomId),
|
||||
map(message => Object.assign(new MessageEntity(), message))
|
||||
filter((message) => message.deviceId != getInstanceId()),
|
||||
map(message => {
|
||||
return Object.assign(new MessageEntity(), message)
|
||||
})
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageSocketRepositoryService } from 'src/app/module/chat/data/repository/message/message-live-signalr-data-source.service'
|
||||
import { InstanceId } from '../../../../module/chat/domain/chat-service.service';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { z } from 'zod';
|
||||
import { IMessageSocketRepository } from '../../repository/message/message-socket-repository';
|
||||
import { getInstanceId } from 'src/app/module/chat/domain/chat-service.service';
|
||||
|
||||
export const ListenSendMessageInputDTOSchema = z.object({
|
||||
roomId: z.string(),
|
||||
@@ -25,10 +25,7 @@ export class ListenSendMessageUseCase {
|
||||
|
||||
return this.MessageSocketRepositoryService.listenToMessages().pipe(
|
||||
map(message => message.data),
|
||||
filter((message) => {
|
||||
|
||||
return message?.requestId?.startsWith(InstanceId) && message?.roomId == roomId
|
||||
}),
|
||||
filter((message) => message.deviceId != getInstanceId()),
|
||||
map(message => message)
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
|
||||
import { IMessage, MessageAttachmentSource, MessageEntity, MessageEntitySchema, } from '../../entity/message';
|
||||
import { z } from 'zod';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { InstanceId } from '../../../../module/chat/domain/chat-service.service';
|
||||
import { createBlobFromBase64, createDataURL } from 'src/app/utils/ToBase64';
|
||||
import { zodSafeValidation } from 'src/app/utils/zodValidation';
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
@@ -105,7 +104,7 @@ export class MessageCreateUseCaseService {
|
||||
if(validation.isOk()) {
|
||||
message.sendAttemp++;
|
||||
|
||||
message.requestId = InstanceId +'@'+ uuidv4();
|
||||
message.requestId = uuidv4();
|
||||
message.sending = true;
|
||||
|
||||
const createMessageLocally = this.messageLocalDataSourceService.insert(message)
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
|
||||
import { IMessage, MessageAttachmentSource, MessageEntity, MessageEntitySchema, } from '../../entity/message';
|
||||
import { z } from 'zod';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { InstanceId } from '../../../../module/chat/domain/chat-service.service';
|
||||
import { createBlobFromBase64, createDataURL } from 'src/app/utils/ToBase64';
|
||||
import { zodSafeValidation } from 'src/app/utils/zodValidation';
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
@@ -38,7 +37,8 @@ export const MessageInputDTOSchema = z.object({
|
||||
docId: z.number().optional(),
|
||||
mimeType: z.string().nullable().optional(),
|
||||
description: z.string().optional()
|
||||
}).optional()
|
||||
}).array(),
|
||||
deviceId: z.string().optional()
|
||||
});
|
||||
export type MessageInputDTO = z.infer<typeof MessageInputDTOSchema>
|
||||
|
||||
@@ -105,14 +105,11 @@ export class MessageCreateUseCaseService {
|
||||
if(validation.isOk()) {
|
||||
message.sendAttemp++;
|
||||
|
||||
message.requestId = InstanceId +'@'+ uuidv4();
|
||||
|
||||
const createMessageLocally = this.messageLocalDataSourceService.insert(message)
|
||||
|
||||
createMessageLocally.then((value) => {
|
||||
if(value.isOk()) {
|
||||
|
||||
console.log("set image")
|
||||
message.$id = value.value
|
||||
|
||||
if(message.hasAttachment) {
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import { MessageSocketRepositoryService } from 'src/app/module/chat/data/reposit
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { IMessageLocalRepository } from '../../repository/message/message-local-repository';
|
||||
import { IMessageSocketRepository } from '../../repository/message/message-socket-repository';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
const MessageMarkAllMessageAsReadByRoomIdInputSchema = z.object({
|
||||
roomId: z.string(),
|
||||
@@ -36,7 +37,7 @@ export class MessageMarkAllMessageAsReadByRoomIdService {
|
||||
memberId: SessionStore.user.UserId,
|
||||
messageId: message.id,
|
||||
roomId: input.roomId,
|
||||
requestId: 'uuid'
|
||||
requestId: uuidv4()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageLocalDataSourceService } from '../../../../module/chat/data/repository/message/message-local-data-source.service';
|
||||
import { MessageSocketRepositoryService } from '../../../../module/chat/data/repository/message/message-live-signalr-data-source.service';
|
||||
import { InstanceId } from '../../../../module/chat/domain/chat-service.service';
|
||||
import { MessageMapper } from '../../mapper/messageMapper';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { AttachmentLocalDataSource } from '../../../../module/chat/data/repository/attachment/attachment-local-repository.service';
|
||||
@@ -65,8 +64,6 @@ export class SendLocalMessagesUseCaseService {
|
||||
description: e.description,
|
||||
file: e.base64.split(',')[1]
|
||||
}))
|
||||
console.log('to upload', messages)
|
||||
const requestId = InstanceId +'@'+ uuidv4();
|
||||
|
||||
await this.messageLocalDataSourceService.update(message.$id, { sending: true })
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import { IMessageSocketRepository } from 'src/app/core/chat/repository/message/m
|
||||
import { MessageEntity } from 'src/app/core/chat/entity/message';
|
||||
import { IBoldLocalRepository } from 'src/app/core/chat/repository/bold/bold-local-repository';
|
||||
import { IMessageLocalRepository } from 'src/app/core/chat/repository/message/message-local-repository';
|
||||
import { InstanceId } from '../../../../module/chat/domain/chat-service.service';
|
||||
import { HttpAdapter } from 'src/app/infra/http/adapter';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
|
||||
import { IMessageGetAllByRoomIdOutPut } from 'src/app/core/chat/usecase/message/message-get-all-by-room-Id';
|
||||
import { getInstanceId } from 'src/app/module/chat/domain/chat-service.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
@@ -37,7 +37,7 @@ export class RoomBoldSyncUseCaseService {
|
||||
private listenToIncomingMessage() {
|
||||
return this.MessageSocketRepositoryService.listenToMessages().pipe(
|
||||
map(message => message.data),
|
||||
filter((message) => !message?.requestId?.startsWith(InstanceId)),
|
||||
filter((message) => message.deviceId != getInstanceId()),
|
||||
map(message => Object.assign(new MessageEntity(), message)),
|
||||
filter((message) => !message.meSender())
|
||||
).subscribe(async (message) => {
|
||||
@@ -59,7 +59,7 @@ export class RoomBoldSyncUseCaseService {
|
||||
*/
|
||||
private listenToUpdateMessages() {
|
||||
return this.MessageSocketRepositoryService.listenToUpdateMessages().pipe(
|
||||
filter((message) => !message?.requestId?.startsWith(InstanceId)),
|
||||
filter((message) => message.deviceId != getInstanceId()),
|
||||
map(message => Object.assign(new MessageEntity(), message))
|
||||
).subscribe(async (message) => {
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export const RoomOutPutDTOSchema = z.object({
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
roomName: z.string().nullable(),
|
||||
createdBy: z.any().nullable(),
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(),
|
||||
|
||||
@@ -30,7 +30,7 @@ export const RoomByIdOutputDTOSchema = z.object({
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
roomName: z.string().nullable(),
|
||||
createdBy: UserSchema,
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(),
|
||||
|
||||
@@ -21,7 +21,7 @@ const CreatedBySchema = z.object({
|
||||
|
||||
const roomListItemSchema = z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
roomName: z.string().nullable(),
|
||||
createdBy: CreatedBySchema,
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(), // api check
|
||||
|
||||
@@ -31,7 +31,7 @@ export const RoomUpdateOutputDTOSchema = z.object({
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
roomName: z.string().nullable(),
|
||||
createdBy: UserSchema,
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(),
|
||||
|
||||
Reference in New Issue
Block a user