@@ -23,25 +23,6 @@ export class MatchingService {
23
23
private readonly chatMessageService : ChatMessageService ,
24
24
private readonly dataSource : DataSource ,
25
25
) { }
26
- async getMatchingByUserId (
27
- requesterId : number ,
28
- targetId : number ,
29
- ) : Promise < Matching > {
30
- return await this . matchingRepository . findOne ( {
31
- where : [
32
- {
33
- requester : { id : requesterId } ,
34
- target : { id : targetId } ,
35
- status : StatusEnum . ACTIVATED ,
36
- } ,
37
- {
38
- requester : { id : targetId } ,
39
- target : { id : requesterId } ,
40
- status : StatusEnum . ACTIVATED ,
41
- } ,
42
- ] ,
43
- } ) ;
44
- }
45
26
46
27
async getMatchingsByCurrentId ( currentUserId : number ) : Promise < Matching [ ] > {
47
28
return await this . matchingRepository . find ( {
@@ -61,6 +42,7 @@ export class MatchingService {
61
42
const matching = await queryRunner . manager . save ( Matching , {
62
43
requester : { id : body . requesterId } ,
63
44
target : { id : body . targetId } ,
45
+ message : body . message ,
64
46
} ) ;
65
47
66
48
const chatRoom = await this . chatRoomService . createChatRoom (
@@ -179,10 +161,7 @@ export class MatchingService {
179
161
} ) ;
180
162
}
181
163
182
- async existsMatching (
183
- requesterId : number ,
184
- targetId : number ,
185
- ) : Promise < boolean > {
164
+ async isMatching ( requesterId : number , targetId : number ) : Promise < boolean > {
186
165
const count = await this . matchingRepository . count ( {
187
166
where : [
188
167
{
@@ -202,4 +181,33 @@ export class MatchingService {
202
181
203
182
return count > 0 ;
204
183
}
184
+
185
+ async existsMatching (
186
+ requesterId : number ,
187
+ targetId : number ,
188
+ ) : Promise < boolean > {
189
+ const matching = await this . matchingRepository . findOne ( {
190
+ where : [
191
+ {
192
+ requester : { id : requesterId } ,
193
+ target : { id : targetId } ,
194
+ status : StatusEnum . ACTIVATED ,
195
+ } ,
196
+ {
197
+ requester : { id : targetId } ,
198
+ target : { id : requesterId } ,
199
+ status : StatusEnum . ACTIVATED ,
200
+ } ,
201
+ ] ,
202
+ } ) ;
203
+
204
+ // 매칭이 없거나 REJECTED 상태이면 false
205
+ if (
206
+ ! matching ||
207
+ matching . requestStatus === MatchingRequestStatusEnum . REJECTED
208
+ ) {
209
+ return false ;
210
+ }
211
+ return true ;
212
+ }
205
213
}
0 commit comments