Skip to content

Commit

Permalink
chore: update notification format
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiin Kim authored and Jiin Kim committed Jan 21, 2025
1 parent 58691df commit 6dc55fd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class MeController @Autowired constructor(
schema = Schema(implementation = Notification::class)
))],
)]
) fun getNotification(
) fun getNotifications(
paginationRequest: PaginationRequest
): ResponseEntity<*> = run {
val me = userService.findCurrentUser()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class PostController @Autowired constructor(
sender = user,
eventType = EventType.LIKE_TO_POST,
message = NotificationMessage(
title = "New Like",
title = post.content.take(50) + if (post.content.length > 50) "..." else "",
body = "${user.username} liked your post",
dataType = DataType.POST,
data = post
Expand Down Expand Up @@ -259,8 +259,8 @@ class PostController @Autowired constructor(
sender = user,
eventType = EventType.LIKE_TO_COMMENT,
message = NotificationMessage(
title = "New Like",
body = "${user.username} liked your comment: ${comment.content}",
title = comment.content.take(50) + if (comment.content.length > 50) "..." else "",
body = "${user.username} liked your comment",
dataType = DataType.COMMENT,
data = comment
)
Expand Down Expand Up @@ -324,8 +324,8 @@ class PostController @Autowired constructor(
sender = user,
eventType = EventType.LIKE_TO_REPLY,
message = NotificationMessage(
title = "New Like",
body = "${user.username} liked your reply: ${reply.content}",
title = reply.content.take(50) + if (reply.content.length > 50) "..." else "",
body = "${user.username} liked your reply",
dataType = DataType.REPLY,
data = reply
)
Expand Down Expand Up @@ -407,8 +407,8 @@ class PostController @Autowired constructor(
eventType = EventType.CREATE_COMMENT_TO_POST,
sender = author,
message = NotificationMessage(
title = "New Comment",
body = "${author.username} commented: ${newComment.content}",
title = commentDto.content.take(50) + if (commentDto.content.length > 50) "..." else "",
body = "${author.username} commented on your post",
dataType = DataType.COMMENT,
data = newComment
)
Expand Down Expand Up @@ -529,8 +529,8 @@ class PostController @Autowired constructor(
sender = author,
eventType = EventType.CREATE_REPLY_TO_COMMENT,
message = NotificationMessage(
title = "New Reply",
body = "${author.username} replied: ${newReply.content}",
title = commentDto.content.take(50) + if (commentDto.content.length > 50) "..." else "",
body = "${author.username} replied to your comment",
dataType = DataType.REPLY,
data = newReply
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.kogo.content.storage.repository

import com.kogo.content.endpoint.common.PaginationRequest
import com.kogo.content.endpoint.common.PaginationSlice
import com.kogo.content.endpoint.common.SortDirection
import com.kogo.content.storage.pagination.MongoPaginationQueryBuilder
import com.kogo.content.storage.model.Notification
import org.springframework.beans.factory.annotation.Autowired
Expand All @@ -21,7 +22,9 @@ class NotificationRepositoryCustomImpl : NotificationRepositoryCustom {
override fun findAllByRecipientId(recipientId:String, paginationRequest: PaginationRequest): PaginationSlice<Notification> {
return mongoPaginationQueryBuilder.getPage(
Notification::class,
paginationRequest = paginationRequest.withFilter("recipientId", recipientId)
paginationRequest = paginationRequest
.withFilter("recipientId", recipientId)
.withSort("createdAt", SortDirection.DESC)
)
}
}

0 comments on commit 6dc55fd

Please sign in to comment.