diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/domain/model/MastodonNotificationRepository.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/domain/model/MastodonNotificationRepository.kt index a89ffdca..e1294843 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/domain/model/MastodonNotificationRepository.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/domain/model/MastodonNotificationRepository.kt @@ -8,17 +8,6 @@ interface MastodonNotificationRepository { suspend fun deleteById(id: Long) suspend fun findById(id: Long): MastodonNotification? - @Suppress("LongParameterList", "FunctionMaxLength") - suspend fun findByUserIdAndMaxIdAndMinIdAndSinceIdAndInTypesAndInSourceActorId( - loginUser: Long, - maxId: Long?, - minId: Long?, - sinceId: Long?, - limit: Int, - typesTmp: MutableList, - accountId: List - ): List - suspend fun findByUserIdAndInTypesAndInSourceActorId( loginUser: Long, types: List, diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedrepository/ExposedMastodonNotificationRepository.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedrepository/ExposedMastodonNotificationRepository.kt index 6181f3ef..bc62b656 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedrepository/ExposedMastodonNotificationRepository.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedrepository/ExposedMastodonNotificationRepository.kt @@ -62,35 +62,6 @@ class ExposedMastodonNotificationRepository : MastodonNotificationRepository, Ab MastodonNotifications.select { MastodonNotifications.id eq id }.singleOrNull()?.toMastodonNotification() } - override suspend fun findByUserIdAndMaxIdAndMinIdAndSinceIdAndInTypesAndInSourceActorId( - loginUser: Long, - maxId: Long?, - minId: Long?, - sinceId: Long?, - limit: Int, - typesTmp: MutableList, - accountId: List - ): List = query { - val query = MastodonNotifications.select { - MastodonNotifications.userId eq loginUser - } - - if (maxId != null) { - query.andWhere { MastodonNotifications.id lessEq maxId } - } - if (minId != null) { - query.andWhere { MastodonNotifications.id greaterEq minId } - } - if (sinceId != null) { - query.andWhere { MastodonNotifications.id greaterEq sinceId } - } - val result = query - .limit(limit) - .orderBy(Timelines.createdAt, SortOrder.DESC) - - return@query result.map { it.toMastodonNotification() } - } - override suspend fun findByUserIdAndInTypesAndInSourceActorId( loginUser: Long, types: List, diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/mongorepository/MongoMastodonNotificationRepositoryWrapper.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/mongorepository/MongoMastodonNotificationRepositoryWrapper.kt index 06f4dadd..fae487d5 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/mongorepository/MongoMastodonNotificationRepositoryWrapper.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/mongorepository/MongoMastodonNotificationRepositoryWrapper.kt @@ -28,37 +28,6 @@ class MongoMastodonNotificationRepositoryWrapper( override suspend fun findById(id: Long): MastodonNotification? = mongoMastodonNotificationRepository.findById(id).getOrNull() - override suspend fun findByUserIdAndMaxIdAndMinIdAndSinceIdAndInTypesAndInSourceActorId( - loginUser: Long, - maxId: Long?, - minId: Long?, - sinceId: Long?, - limit: Int, - typesTmp: MutableList, - accountId: List - ): List { - val query = Query() - - if (maxId != null) { - val criteria = Criteria.where("id").lte(maxId) - query.addCriteria(criteria) - } - - if (minId != null) { - val criteria = Criteria.where("id").gte(minId) - query.addCriteria(criteria) - } - if (sinceId != null) { - val criteria = Criteria.where("id").gte(sinceId) - query.addCriteria(criteria) - } - - query.limit(limit) - query.with(Sort.by(Sort.Direction.DESC, "createdAt")) - - return mongoTemplate.find(query, MastodonNotification::class.java) - } - override suspend fun findByUserIdAndInTypesAndInSourceActorId( loginUser: Long, types: List, diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/notification/NotificationApiService.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/notification/NotificationApiService.kt index c336ccc6..d6b312be 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/notification/NotificationApiService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/notification/NotificationApiService.kt @@ -6,17 +6,6 @@ import dev.usbharu.hideout.domain.mastodon.model.generated.Notification import dev.usbharu.hideout.mastodon.domain.model.NotificationType interface NotificationApiService { - @Suppress("LongParameterList") - suspend fun notifications( - loginUser: Long, - maxId: Long?, - minId: Long?, - sinceId: Long?, - limit: Int, - types: List, - excludeTypes: List, - accountId: List - ): List suspend fun notifications( loginUser: Long, diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/notification/NotificationApiServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/notification/NotificationApiServiceImpl.kt index 528c454c..789d164b 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/notification/NotificationApiServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/notification/NotificationApiServiceImpl.kt @@ -19,53 +19,6 @@ class NotificationApiServiceImpl( private val statusQueryService: StatusQueryService ) : NotificationApiService { - override suspend fun notifications( - loginUser: Long, - maxId: Long?, - minId: Long?, - sinceId: Long?, - limit: Int, - types: List, - excludeTypes: List, - accountId: List - ): List = transaction.transaction { - val typesTmp = mutableListOf() - - typesTmp.addAll(types) - typesTmp.removeAll(excludeTypes) - - val mastodonNotifications = - mastodonNotificationRepository.findByUserIdAndMaxIdAndMinIdAndSinceIdAndInTypesAndInSourceActorId( - loginUser, - maxId, - minId, - sinceId, - limit, - typesTmp, - accountId - ) - - val accounts = accountService.findByIds( - mastodonNotifications.map { - it.accountId - } - ).associateBy { it.id.toLong() } - - val statuses = statusQueryService.findByPostIds(mastodonNotifications.mapNotNull { it.statusId }) - .associateBy { it.id.toLong() } - - mastodonNotifications.map { - Notification( - id = it.id.toString(), - type = convertNotificationType(it.type), - createdAt = it.createdAt.toString(), - account = accounts.getValue(it.accountId), - status = statuses[it.statusId], - report = null, - relationshipSeveranceEvent = null - ) - } - } override suspend fun notifications( loginUser: Long,