mirror of https://github.com/usbharu/Hideout.git
Apply suggestions from code review
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
31240b8797
commit
4c15be67f7
|
@ -12,11 +12,15 @@ interface PostId {
|
|||
}
|
||||
|
||||
data class MentionNotificationRequest(
|
||||
override val userId: Long, override val sourceActorId: Long, override val postId: Long
|
||||
override val userId: Long,
|
||||
override val sourceActorId: Long,
|
||||
override val postId: Long
|
||||
) : NotificationRequest(
|
||||
userId, sourceActorId,
|
||||
userId,
|
||||
sourceActorId,
|
||||
"mention"
|
||||
), PostId {
|
||||
),
|
||||
PostId {
|
||||
override fun buildNotification(id: Long, createdAt: Instant): Notification = Notification(
|
||||
id,
|
||||
type,
|
||||
|
@ -30,7 +34,9 @@ data class MentionNotificationRequest(
|
|||
}
|
||||
|
||||
data class PostNotificationRequest(
|
||||
override val userId: Long, override val sourceActorId: Long, override val postId: Long
|
||||
override val userId: Long,
|
||||
override val sourceActorId: Long,
|
||||
override val postId: Long
|
||||
|
||||
) : NotificationRequest(userId, sourceActorId, "post"), PostId {
|
||||
override fun buildNotification(id: Long, createdAt: Instant): Notification = Notification(
|
||||
|
@ -46,7 +52,9 @@ data class PostNotificationRequest(
|
|||
}
|
||||
|
||||
data class RepostNotificationRequest(
|
||||
override val userId: Long, override val sourceActorId: Long, override val postId: Long
|
||||
override val userId: Long,
|
||||
override val sourceActorId: Long,
|
||||
override val postId: Long
|
||||
) : NotificationRequest(userId, sourceActorId, "repost"), PostId {
|
||||
override fun buildNotification(id: Long, createdAt: Instant): Notification = Notification(
|
||||
id,
|
||||
|
@ -61,7 +69,8 @@ data class RepostNotificationRequest(
|
|||
}
|
||||
|
||||
data class FollowNotificationRequest(
|
||||
override val userId: Long, override val sourceActorId: Long
|
||||
override val userId: Long,
|
||||
override val sourceActorId: Long
|
||||
) : NotificationRequest(userId, sourceActorId, "follow") {
|
||||
override fun buildNotification(id: Long, createdAt: Instant): Notification = Notification(
|
||||
id,
|
||||
|
@ -76,7 +85,8 @@ data class FollowNotificationRequest(
|
|||
}
|
||||
|
||||
data class FollowRequestNotificationRequest(
|
||||
override val userId: Long, override val sourceActorId: Long
|
||||
override val userId: Long,
|
||||
override val sourceActorId: Long
|
||||
) : NotificationRequest(userId, sourceActorId, "follow-request") {
|
||||
override fun buildNotification(id: Long, createdAt: Instant): Notification = Notification(
|
||||
id,
|
||||
|
@ -91,7 +101,10 @@ data class FollowRequestNotificationRequest(
|
|||
}
|
||||
|
||||
data class ReactionNotificationRequest(
|
||||
override val userId: Long, override val sourceActorId: Long, override val postId: Long, val reactionId: Long
|
||||
override val userId: Long,
|
||||
override val sourceActorId: Long,
|
||||
override val postId: Long,
|
||||
val reactionId: Long
|
||||
|
||||
) : NotificationRequest(userId, sourceActorId, "reaction"), PostId {
|
||||
override fun buildNotification(id: Long, createdAt: Instant): Notification = Notification(
|
||||
|
|
|
@ -15,7 +15,6 @@ enum class NotificationType {
|
|||
|
||||
companion object {
|
||||
fun parse(string: String): NotificationType? = when (string) {
|
||||
|
||||
"mention" -> mention
|
||||
"status" -> status
|
||||
"reblog" -> reblog
|
||||
|
|
|
@ -72,7 +72,6 @@ class ExposedMastodonNotificationRepository : MastodonNotificationRepository, Ab
|
|||
MastodonNotifications.userId eq loginUser
|
||||
}
|
||||
|
||||
|
||||
if (maxId != null) {
|
||||
query.andWhere { MastodonNotifications.id lessEq maxId }
|
||||
}
|
||||
|
|
|
@ -5,9 +5,7 @@ import org.springframework.data.mongodb.repository.MongoRepository
|
|||
|
||||
interface MongoMastodonNotificationRepository : MongoRepository<MastodonNotification, Long> {
|
||||
|
||||
|
||||
fun deleteByUserId(userId: Long): Long
|
||||
|
||||
|
||||
fun deleteByIdAndUserId(id: Long, userId: Long): Long
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ class NotificationApiServiceImpl(
|
|||
excludeTypes: List<NotificationType>,
|
||||
accountId: List<Long>
|
||||
): List<Notification> = transaction.transaction {
|
||||
|
||||
val typesTmp = mutableListOf<NotificationType>()
|
||||
|
||||
typesTmp.addAll(types)
|
||||
|
@ -44,9 +43,11 @@ class NotificationApiServiceImpl(
|
|||
accountId
|
||||
)
|
||||
|
||||
val accounts = accountService.findByIds(mastodonNotifications.map {
|
||||
val accounts = accountService.findByIds(
|
||||
mastodonNotifications.map {
|
||||
it.accountId
|
||||
}).associateBy { it.id.toLong() }
|
||||
}
|
||||
).associateBy { it.id.toLong() }
|
||||
|
||||
val statuses = statusQueryService.findByPostIds(mastodonNotifications.mapNotNull { it.statusId })
|
||||
.associateBy { it.id.toLong() }
|
||||
|
@ -93,7 +94,6 @@ class NotificationApiServiceImpl(
|
|||
mastodonNotificationRepository.deleteByUserIdAndId(loginUser, notificationId)
|
||||
}
|
||||
|
||||
|
||||
private fun convertNotificationType(notificationType: NotificationType): Notification.Type =
|
||||
when (notificationType) {
|
||||
mention -> Notification.Type.mention
|
||||
|
|
Loading…
Reference in New Issue