66import konkuk .thip .notification .application .service .template .room .*;
77import konkuk .thip .notification .domain .value .MessageRoute ;
88import konkuk .thip .notification .domain .value .NotificationRedirectSpec ;
9+ import konkuk .thip .post .domain .PostType ;
910import lombok .RequiredArgsConstructor ;
1011import org .springframework .transaction .annotation .Propagation ;
1112import org .springframework .transaction .annotation .Transactional ;
@@ -30,18 +31,10 @@ public class RoomNotificationOrchestratorSyncImpl implements RoomNotificationOrc
3031 @ Override
3132 @ Transactional (propagation = Propagation .MANDATORY )
3233 public void notifyRoomPostCommented (Long targetUserId , Long actorUserId , String actorUsername ,
33- Long roomId , Integer page , Long postId , String postType ) {
34+ Long roomId , Integer page , Long postId , PostType postType ) {
3435 var args = new RoomPostCommentedTemplate .Args (actorUsername );
3536
36- NotificationRedirectSpec redirectSpec = new NotificationRedirectSpec (
37- MessageRoute .ROOM_POST_DETAIL ,
38- Map .of (
39- "roomId" , roomId ,
40- "page" , page ,
41- "postId" , postId ,
42- "postType" , postType
43- )
44- );
37+ NotificationRedirectSpec redirectSpec = createRoomPostWithCommentsRedirectSpec (roomId , page , postId , postType );
4538
4639 notificationSyncExecutor .execute (
4740 RoomPostCommentedTemplate .INSTANCE ,
@@ -59,15 +52,7 @@ public void notifyRoomPostCommented(Long targetUserId, Long actorUserId, String
5952 public void notifyRoomVoteStarted (Long targetUserId , Long roomId , String roomTitle , Integer page , Long postId ) {
6053 var args = new RoomVoteStartedTemplate .Args (roomTitle );
6154
62- NotificationRedirectSpec redirectSpec = new NotificationRedirectSpec (
63- MessageRoute .ROOM_VOTE_DETAIL ,
64- Map .of (
65- "roomId" , roomId ,
66- "page" , page ,
67- "postId" , postId ,
68- "postType" , "VOTE"
69- )
70- );
55+ NotificationRedirectSpec redirectSpec = createRoomPostRedirectSpec (roomId , page , postId , PostType .VOTE );
7156
7257 notificationSyncExecutor .execute (
7358 RoomVoteStartedTemplate .INSTANCE ,
@@ -86,15 +71,7 @@ public void notifyRoomRecordCreated(Long targetUserId, Long actorUserId, String
8671 Long roomId , String roomTitle , Integer page , Long postId ) {
8772 var args = new RoomRecordCreatedTemplate .Args (roomTitle , actorUsername );
8873
89- NotificationRedirectSpec redirectSpec = new NotificationRedirectSpec (
90- MessageRoute .ROOM_RECORD_DETAIL ,
91- Map .of (
92- "roomId" , roomId ,
93- "page" , page ,
94- "postId" , postId ,
95- "postType" , "RECORD"
96- )
97- );
74+ NotificationRedirectSpec redirectSpec = createRoomPostRedirectSpec (roomId , page , postId , PostType .RECORD );
9875
9976 notificationSyncExecutor .execute (
10077 RoomRecordCreatedTemplate .INSTANCE ,
@@ -173,18 +150,10 @@ public void notifyRoomJoinToHost(Long hostUserId, Long roomId, String roomTitle,
173150 @ Override
174151 @ Transactional (propagation = Propagation .MANDATORY )
175152 public void notifyRoomCommentLiked (Long targetUserId , Long actorUserId , String actorUsername ,
176- Long roomId , Integer page , Long postId , String postType ) {
153+ Long roomId , Integer page , Long postId , PostType postType ) {
177154 var args = new RoomCommentLikedTemplate .Args (actorUsername );
178155
179- NotificationRedirectSpec redirectSpec = new NotificationRedirectSpec (
180- MessageRoute .ROOM_POST_DETAIL ,
181- Map .of (
182- "roomId" , roomId ,
183- "page" , page ,
184- "postId" , postId ,
185- "postType" , postType
186- )
187- );
156+ NotificationRedirectSpec redirectSpec = createRoomPostWithCommentsRedirectSpec (roomId , page , postId , postType );
188157
189158 notificationSyncExecutor .execute (
190159 RoomCommentLikedTemplate .INSTANCE ,
@@ -200,18 +169,10 @@ public void notifyRoomCommentLiked(Long targetUserId, Long actorUserId, String a
200169 @ Override
201170 @ Transactional (propagation = Propagation .MANDATORY )
202171 public void notifyRoomPostLiked (Long targetUserId , Long actorUserId , String actorUsername ,
203- Long roomId , Integer page , Long postId , String postType ) {
172+ Long roomId , Integer page , Long postId , PostType postType ) {
204173 var args = new RoomPostLikedTemplate .Args (actorUsername );
205174
206- NotificationRedirectSpec redirectSpec = new NotificationRedirectSpec (
207- MessageRoute .ROOM_POST_DETAIL ,
208- Map .of (
209- "roomId" , roomId ,
210- "page" , page ,
211- "postId" , postId ,
212- "postType" , postType
213- )
214- );
175+ NotificationRedirectSpec redirectSpec = createRoomPostRedirectSpec (roomId , page , postId , postType );
215176
216177 notificationSyncExecutor .execute (
217178 RoomPostLikedTemplate .INSTANCE ,
@@ -227,18 +188,10 @@ public void notifyRoomPostLiked(Long targetUserId, Long actorUserId, String acto
227188 @ Override
228189 @ Transactional (propagation = Propagation .MANDATORY )
229190 public void notifyRoomPostCommentReplied (Long targetUserId , Long actorUserId , String actorUsername ,
230- Long roomId , Integer page , Long postId , String postType ) {
191+ Long roomId , Integer page , Long postId , PostType postType ) {
231192 var args = new RoomPostCommentRepliedTemplate .Args (actorUsername );
232193
233- NotificationRedirectSpec redirectSpec = new NotificationRedirectSpec (
234- MessageRoute .ROOM_POST_DETAIL ,
235- Map .of (
236- "roomId" , roomId ,
237- "page" , page ,
238- "postId" , postId ,
239- "postType" , postType
240- )
241- );
194+ NotificationRedirectSpec redirectSpec = createRoomPostWithCommentsRedirectSpec (roomId , page , postId , postType );
242195
243196 notificationSyncExecutor .execute (
244197 RoomPostCommentRepliedTemplate .INSTANCE ,
@@ -250,4 +203,30 @@ public void notifyRoomPostCommentReplied(Long targetUserId, Long actorUserId, St
250203 )
251204 );
252205 }
206+
207+ private NotificationRedirectSpec createRoomPostWithCommentsRedirectSpec (Long roomId , Integer page , Long postId , PostType postType ) {
208+ return new NotificationRedirectSpec (
209+ MessageRoute .ROOM_POST_DETAIL ,
210+ Map .of (
211+ "roomId" , roomId ,
212+ "page" , page ,
213+ "postId" , postId ,
214+ "postType" , postType ,
215+ "openComments" , true
216+ )
217+ );
218+ }
219+
220+ private NotificationRedirectSpec createRoomPostRedirectSpec (Long roomId , Integer page , Long postId , PostType postType ) {
221+ return new NotificationRedirectSpec (
222+ MessageRoute .ROOM_POST_DETAIL ,
223+ Map .of (
224+ "roomId" , roomId ,
225+ "page" , page ,
226+ "postId" , postId ,
227+ "postType" , postType ,
228+ "openComments" , false
229+ )
230+ );
231+ }
253232}
0 commit comments