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
983b0b1e
Commit
983b0b1e
authored
3 months ago
by
심재엽
Browse files
Options
Downloads
Patches
Plain Diff
feat: 번개모임 참가시, 다른 참가자들한테 푸시 알림
parent
298bd0dd
No related branches found
Branches containing commit
No related tags found
1 merge request
!43
배포코드 master브랜치로
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pushServer.js
+31
-13
31 additions, 13 deletions
pushServer.js
services/meetingService.js
+31
-3
31 additions, 3 deletions
services/meetingService.js
with
62 additions
and
16 deletions
pushServer.js
+
31
−
13
View file @
983b0b1e
...
...
@@ -71,24 +71,42 @@ async function startPushServer() {
channel
.
consume
(
meetingQueue
,
async
(
msg
)
=>
{
if
(
msg
!==
null
)
{
const
event
=
JSON
.
parse
(
msg
.
content
.
toString
());
const
{
meetingTitle
,
inviterName
,
inviteeTokens
}
=
event
;
const
{
meetingTitle
,
inviterName
,
inviteeTokens
,
type
}
=
event
;
console
.
log
(
'
Meeting 푸시 알림 요청 수신:
'
,
event
);
console
.
log
(
"
푸시 알림 보내는 fcmToken
"
,
inviteeTokens
);
if
(
inviteeTokens
.
length
>
0
)
{
const
message
=
{
tokens
:
inviteeTokens
,
notification
:
{
title
:
'
번개 모임 초대
'
,
body
:
`
${
inviterName
}
님이
${
meetingTitle
}
모임에 초대했습니다.`
,
},
data
:
{
click_action
:
`
${
process
.
env
.
FRONT_URL
}
/meeting`
,
// 클릭 시 이동할 URL
},
android
:
{
priority
:
'
high
'
},
apns
:
{
payload
:
{
aps
:
{
sound
:
'
default
'
}
}
},
};
let
message
;
// 이벤트 타입에 따라 알림 내용 구성
if
(
type
===
'
invite
'
)
{
message
=
{
tokens
:
inviteeTokens
,
notification
:
{
title
:
'
번개 모임 초대
'
,
body
:
`
${
inviterName
}
님이
${
meetingTitle
}
번개모임에 초대했습니다.`
,
},
data
:
{
click_action
:
`
${
process
.
env
.
FRONT_URL
}
/meeting`
,
// 클릭 시 이동할 URL
},
android
:
{
priority
:
'
high
'
},
apns
:
{
payload
:
{
aps
:
{
sound
:
'
default
'
}
}
},
};
}
else
if
(
type
===
'
join
'
)
{
message
=
{
tokens
:
inviteeTokens
,
notification
:
{
title
:
`
${
meetingTitle
}
`
,
body
:
`
${
inviterName
}
님이
${
meetingTitle
}
모임에 참가했습니다.`
,
},
data
:
{
click_action
:
`
${
process
.
env
.
FRONT_URL
}
/meeting`
,
// 클릭 시 이동할 URL
},
android
:
{
priority
:
'
high
'
},
apns
:
{
payload
:
{
aps
:
{
sound
:
'
default
'
}
}
},
};
}
try
{
const
response
=
await
admin
.
messaging
().
sendEachForMulticast
(
message
);
...
...
This diff is collapsed.
Click to expand it.
services/meetingService.js
+
31
−
3
View file @
983b0b1e
...
...
@@ -39,13 +39,22 @@ class MeetingService {
return
totalIdx
;
}
async
sendMeetingPushNotificationRequest
(
meetingTitle
,
inviterName
,
inviteeTokens
)
{
// async sendMeetingPushNotificationRequest(meetingTitle, inviterName, inviteeTokens) {
// const event = {
// meetingTitle,
// inviterName,
// inviteeTokens,
// };
// await this.publishToQueue('meeting_push_notifications', event); // meeting_push_notifications 큐에 메시지 발행
// }
async
sendMeetingPushNotificationRequest
(
meetingTitle
,
inviterName
,
inviteeTokens
,
type
)
{
const
event
=
{
meetingTitle
,
inviterName
,
inviteeTokens
,
type
,
// 이벤트 타입 ('invite' 또는 'join')
};
await
this
.
publishToQueue
(
'
meeting_push_notifications
'
,
event
);
//
meeting_push_notifications
큐에 메시지 발행
await
this
.
publishToQueue
(
'
meeting_push_notifications
'
,
event
);
// 큐에 메시지 발행
}
...
...
@@ -147,7 +156,12 @@ class MeetingService {
// RabbitMQ 메시지 발행 (푸시 알림 요청)
if
(
inviteeTokens
.
length
>
0
)
{
await
this
.
sendMeetingPushNotificationRequest
(
title
,
user
.
name
,
inviteeTokens
);
await
this
.
sendMeetingPushNotificationRequest
(
title
,
user
.
name
,
inviteeTokens
,
'
invite
'
);
}
const
chatRoom
=
await
ChatRooms
.
findOne
({
chatRoomId
:
chatRoomId
});
...
...
@@ -312,6 +326,20 @@ class MeetingService {
chatRoom
.
messages
.
push
(
joinMessage
);
// 기존 참가자 FCM 토큰 가져오기
const
otherParticipants
=
chatRoom
.
participants
.
filter
(
participant
=>
participant
.
name
!==
user
.
name
);
const
otherParticipantTokens
=
otherParticipants
.
flatMap
(
participant
=>
participant
.
fcmTokens
);
if
(
otherParticipantTokens
.
length
>
0
)
{
// RabbitMQ 메시지 발행
await
this
.
sendMeetingPushNotificationRequest
(
meeting
.
title
,
user
.
name
,
otherParticipantTokens
,
'
join
'
);
}
await
chatRoom
.
save
();
}
...
...
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