Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebBack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websystem
WebBack
Commits
55dfe7b7
Commit
55dfe7b7
authored
3 months ago
by
심재엽
Browse files
Options
Downloads
Patches
Plain Diff
refactor: 참가한 채팅방 목록만 조회
parent
212c7018
No related branches found
Branches containing commit
No related tags found
1 merge request
!43
배포코드 master브랜치로
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
controllers/chatController.js
+6
-1
6 additions, 1 deletion
controllers/chatController.js
routes/chatRoute.js
+1
-1
1 addition, 1 deletion
routes/chatRoute.js
services/chatService.js
+5
-2
5 additions, 2 deletions
services/chatService.js
with
12 additions
and
4 deletions
controllers/chatController.js
+
6
−
1
View file @
55dfe7b7
...
...
@@ -13,7 +13,12 @@ exports.createChatRoom = async (params) => {
// 채팅방 목록 조회
exports
.
getChatRooms
=
async
(
req
,
res
)
=>
{
try
{
const
roomData
=
await
chatService
.
getChatRooms
();
const
name
=
req
.
user
.
name
;
// Google 로그인에서 가져온 email
console
.
log
(
"
name
"
,
name
);
// 본인이 참가자로 포함된 채팅방만 가져오기
const
roomData
=
await
chatService
.
getChatRooms
(
name
);
res
.
json
(
roomData
);
}
catch
(
err
)
{
console
.
error
(
'
Error fetching rooms:
'
,
err
);
...
...
This diff is collapsed.
Click to expand it.
routes/chatRoute.js
+
1
−
1
View file @
55dfe7b7
...
...
@@ -4,7 +4,6 @@ const chatController = require('../controllers/chatController');
const
{
isLoggedIn
}
=
require
(
'
../middlewares/auth
'
);
router
.
post
(
'
/create-room
'
,
chatController
.
createChatRoom
);
router
.
get
(
'
/rooms
'
,
chatController
.
getChatRooms
);
router
.
post
(
'
/update-status
'
,
chatController
.
updateStatus
);
router
.
post
(
'
/update-read-status
'
,
chatController
.
updateReadStatus
);
router
.
get
(
'
/unread-messages/:nickname
'
,
chatController
.
getUnreadMessages
);
...
...
@@ -13,6 +12,7 @@ router.post('/update-status-and-logid', chatController.updateStatusAndLogId);
router
.
post
(
'
/update-read-log-id
'
,
chatController
.
updateReadLogId
);
router
.
use
(
isLoggedIn
);
router
.
get
(
'
/rooms
'
,
chatController
.
getChatRooms
);
router
.
post
(
'
/:chatRoomId/notices
'
,
chatController
.
addNotice
);
router
.
get
(
'
/:chatRoomId/notices/latest
'
,
chatController
.
getLatestNotice
);
...
...
This diff is collapsed.
Click to expand it.
services/chatService.js
+
5
−
2
View file @
55dfe7b7
...
...
@@ -30,8 +30,11 @@ class ChatService {
}
// 채팅방 목록 조회
async
getChatRooms
()
{
const
rooms
=
await
ChatRooms
.
find
({},
{
chatRoomId
:
1
,
chatRoomName
:
1
,
messages
:
{
$slice
:
-
1
}
});
async
getChatRooms
(
name
)
{
const
rooms
=
await
ChatRooms
.
find
(
{
"
participants.name
"
:
name
},
{
chatRoomId
:
1
,
chatRoomName
:
1
,
messages
:
{
$slice
:
-
1
}
}
);
return
rooms
.
map
(
room
=>
{
const
lastMessage
=
room
.
messages
[
0
]
||
{};
return
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment