mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
change room name for direct room
This commit is contained in:
@@ -9,6 +9,7 @@ import { z } from 'zod';
|
||||
import { IRoomRemoteRepository } from 'src/app/core/chat/repository/room/room-remote-repository';
|
||||
import { IMemberLocalRepository } from 'src/app/core/chat/repository/member/member-local-repository';
|
||||
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
|
||||
import { GetRoomByIdMapper } from 'src/app/core/chat/mapper/getRoomByIdMapper';
|
||||
|
||||
const UserSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
@@ -72,6 +73,7 @@ export class GetRoomByIdUseCaseService {
|
||||
const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges([object], localListRoom.value)
|
||||
|
||||
for( const roomData of roomsToUpdate) {
|
||||
// const room = GetRoomByIdMapper.toDomain(roomData)
|
||||
this.roomLocalDataSourceService.update(roomData.chatRoom.id, roomData.chatRoom)
|
||||
}
|
||||
|
||||
@@ -81,6 +83,7 @@ export class GetRoomByIdUseCaseService {
|
||||
const { membersToInsert, membersToUpdate, membersToDelete } = roomMemberListDetermineChanges(result.value.data.members, localList, id)
|
||||
|
||||
for (const user of membersToInsert) {
|
||||
|
||||
await this.MemberListLocalRepository.addMember(MemberListMapper(user, id))
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ import { CronJobService } from 'src/app/utils/task-scheduler'
|
||||
import { z } from "zod";
|
||||
import { IRoomRemoteRepository } from 'src/app/core/chat/repository/room/room-remote-repository';
|
||||
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
|
||||
import { MessageEntitySchema } from 'src/app/core/chat/entity/message';
|
||||
import { RoomEntity, RoomType } from 'src/app/core/chat/entity/group';
|
||||
import { GetRoomListMapper } from 'src/app/core/chat/mapper/getRoomListMapper';
|
||||
|
||||
|
||||
const CreatedBySchema = z.object({
|
||||
@@ -15,14 +18,16 @@ const CreatedBySchema = z.object({
|
||||
});
|
||||
|
||||
const RoomListItemOutPutDTOSchema = z.object({
|
||||
|
||||
chatRoom: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: CreatedBySchema,
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(), // api check
|
||||
roomType: z.number()
|
||||
roomType: z.number(),
|
||||
messages: MessageEntitySchema.array(),
|
||||
user1: CreatedBySchema.nullable(),
|
||||
user2: CreatedBySchema.nullable()
|
||||
}),
|
||||
joinAt: z.string()
|
||||
})
|
||||
@@ -60,29 +65,31 @@ export class GetRoomListUseCaseService {
|
||||
|
||||
if(localList.isOk()) {
|
||||
if(result.isOk()) {
|
||||
|
||||
const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges(result.value.data, localList.value)
|
||||
|
||||
for( const roomData of roomsToInsert) {
|
||||
this.roomLocalDataSourceService.insert(roomData.chatRoom)
|
||||
|
||||
if(roomData.chatRoom.expirationDate) {
|
||||
if(roomsToInsert) {
|
||||
const roomsToInsertEntity = GetRoomListMapper.toDomain(roomsToInsert)
|
||||
for( const room of roomsToInsertEntity) {
|
||||
this.roomLocalDataSourceService.insert(room)
|
||||
if(room.expirationDate) {
|
||||
console.log('room expiration date schedule')
|
||||
this.CronJobService.createCronJob('remove expired room', new Date(roomData.chatRoom.expirationDate), this.execute)
|
||||
this.CronJobService.createCronJob('remove expired room', new Date(room.expirationDate), this.execute)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const roomsToUpdateEntity = GetRoomListMapper.toDomain(roomsToUpdate)
|
||||
for( const room of roomsToUpdateEntity) {
|
||||
this.roomLocalDataSourceService.update(room.id, room)
|
||||
}
|
||||
|
||||
for( const roomData of roomsToUpdate) {
|
||||
this.roomLocalDataSourceService.update(roomData.chatRoom.id, roomData.chatRoom)
|
||||
}
|
||||
|
||||
for( const roomData of roomsToDelete) {
|
||||
this.roomLocalDataSourceService.delete(roomData.id)
|
||||
}
|
||||
for( const room of roomsToDelete) {
|
||||
this.roomLocalDataSourceService.delete(room.id)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user