mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
add atribute to message
This commit is contained in:
@@ -4,7 +4,6 @@ import { MessageInputDTO, MessageInputDTOSchema } from '../../dto/message/messag
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { APIReturn } from 'src/app/services/decorators/api-validate-schema.decorator';
|
||||
import { MessageOutPutDTO, MessageOutPutDTOSchema } from '../../dto/message/messageOutputDTO';
|
||||
import { MessageListOutput } from '../../dto/message/messageListOutputDTO';
|
||||
import { DataSourceReturn } from 'src/app/services/Repositorys/type';
|
||||
|
||||
@Injectable({
|
||||
@@ -26,7 +25,7 @@ export class MessageRemoteDataSourceService {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Messages/${id}/React`, reaction);
|
||||
}
|
||||
|
||||
async getMessagesFromRoom(id: string): DataSourceReturn<MessageListOutput> {
|
||||
async getMessagesFromRoom(id: string): DataSourceReturn<MessageOutPutDTO> {
|
||||
return await this.httpService.get(`${this.baseUrl}/Room/${id}/Messages`);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { z } from "zod"
|
||||
|
||||
const SenderSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string()
|
||||
});
|
||||
|
||||
const DataSchema = z.object({
|
||||
id: z.string(),
|
||||
sender: SenderSchema,
|
||||
message: z.string(),
|
||||
messageType: z.number(),
|
||||
sentAt: z.string().datetime(),
|
||||
deliverAt: z.string().datetime().nullable(),
|
||||
canEdit: z.boolean(),
|
||||
oneShot: z.boolean(),
|
||||
requireUnlock: z.boolean()
|
||||
});
|
||||
|
||||
const MessageListOutputSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string().nullable(),
|
||||
data: z.array(DataSchema)
|
||||
});
|
||||
|
||||
|
||||
export type MessageListOutput = z.infer<typeof MessageListOutputSchema>
|
||||
@@ -2,7 +2,7 @@ import { z } from "zod"
|
||||
|
||||
const DataSchema = z.object({
|
||||
id: z.string(),
|
||||
chatRoomId: z.string(),
|
||||
roomId: z.string(),
|
||||
wxUserId: z.number(),
|
||||
sender: z.object({
|
||||
wxUserId: z.number(),
|
||||
@@ -17,14 +17,17 @@ const DataSchema = z.object({
|
||||
canEdit: z.boolean(),
|
||||
oneShot: z.boolean(),
|
||||
requireUnlock: z.boolean(),
|
||||
requestId: z.string()
|
||||
requestId: z.string(),
|
||||
reactions: z.array(z.object({})),
|
||||
info: z.array(z.object({})),
|
||||
attachments: z.array(z.object({}))
|
||||
});
|
||||
|
||||
|
||||
export const MessageOutPutDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: DataSchema
|
||||
data: DataSchema.array()
|
||||
});
|
||||
|
||||
export type MessageOutPutDataDTO = z.infer<typeof DataSchema>
|
||||
|
||||
+1
-2
@@ -17,8 +17,7 @@ export class SocketMessageUpdateUseCaseService {
|
||||
|
||||
const incomingMessage = {
|
||||
...data,
|
||||
sending: false,
|
||||
roomId:data.chatRoomId
|
||||
sending: false
|
||||
}
|
||||
|
||||
// delete data.chatRoomId
|
||||
|
||||
@@ -18,12 +18,14 @@ export const MessageTable = z.object({
|
||||
userPhoto: z.string(),
|
||||
}),
|
||||
sending: z.boolean().optional(),
|
||||
reaction: z.object({
|
||||
reactions: z.object({
|
||||
id: z.string(),
|
||||
reactedAt: z.string(),
|
||||
reaction: z.string(),
|
||||
sender: z.object({}),
|
||||
}).array()
|
||||
}).array().optional(),
|
||||
info: z.array(z.object({})).optional(),
|
||||
attachments: z.array(z.object({})).optional()
|
||||
})
|
||||
|
||||
export type MessageTable = z.infer<typeof MessageTable>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { DexieMembersTableSchema, MemberTableColumn } from './schema/members';
|
||||
import { DexieRoomsTableSchema, RoomTableColumn } from './schema/room';
|
||||
import { DexieTypingsTableSchema, TypingTableColumn } from './schema/typing';
|
||||
import { MessageEntity } from '../../../domain/entity/message';
|
||||
// import DexieMemory from 'dexie-in-memory';
|
||||
|
||||
// Database declaration (move this to its own module also)
|
||||
export const chatDatabase = new Dexie('chat-database-infra') as Dexie & {
|
||||
@@ -22,3 +23,4 @@ chatDatabase.version(1).stores({
|
||||
});
|
||||
|
||||
chatDatabase.message.mapToClass(MessageEntity)
|
||||
// Apply in-memory storage
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SignalRService } from './signal-r.service';
|
||||
|
||||
describe('SignalRService', () => {
|
||||
let service: SignalRService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(SignalRService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user