Skip to content

Commit

Permalink
Merge pull request #297 from boostcampwm2023/BE-fixChat-#295
Browse files Browse the repository at this point in the history
[BE/#295] 채팅 수정
  • Loading branch information
koomin1227 authored Dec 4, 2023
2 parents dacddb8 + ed107ad commit 0e2a72a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
13 changes: 9 additions & 4 deletions BE/src/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { ChatDto } from './dto/chat.dto';
import { UserEntity } from 'src/entities/user.entity';
import { FcmHandler, PushMessage } from '../utils/fcmHandler';

export interface ChatRoom {
room_id: number;
}

@Injectable()
export class ChatService {
constructor(
Expand All @@ -31,18 +35,19 @@ export class ChatService {
postId: number,
userId: string,
writerId: string,
): Promise<ChatRoomEntity> {
const isExist = this.chatRoomRepository.findOne({
): Promise<ChatRoom> {
const isExist = await this.chatRoomRepository.findOne({
where: { post_id: postId, user: userId, writer: writerId },
});
if (isExist) {
return isExist;
return { room_id: isExist.id };
}
const chatRoom = new ChatRoomEntity();
chatRoom.post_id = postId;
chatRoom.writer = writerId;
chatRoom.user = userId;
return await this.chatRoomRepository.save(chatRoom);
const roomId = (await this.chatRoomRepository.save(chatRoom)).id;
return { room_id: roomId };
}

async findRoomList(userId: string) {
Expand Down
8 changes: 8 additions & 0 deletions BE/src/post/dto/postUpdate.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export class UpdatePostDto {
@IsNumber() // 전화번호 형식 검증
price?: number;

@IsOptional()
@IsString()
start_date?: string;

@IsOptional()
@IsString()
end_date?: string;

@IsOptional()
@IsString({ each: true })
deleted_images: string[];
Expand Down

0 comments on commit 0e2a72a

Please sign in to comment.