Merge pull request #539 from usbharu/ci-gradle

chore: ciを改善
This commit is contained in:
usbharu 2024-08-13 21:20:33 +09:00 committed by GitHub
commit 60d71e1eb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
47 changed files with 174 additions and 165 deletions

View File

@ -46,7 +46,7 @@ jobs:
gradle-home-cache-cleanup: true gradle-home-cache-cleanup: true
- name: Build - name: Build
run: ./gradlew :hideout-core:classes run: ./hideout-core/gradlew :hideout-core:classes --no-daemon
unit-test: unit-test:
name: Unit Test name: Unit Test
@ -69,7 +69,7 @@ jobs:
gradle-home-cache-cleanup: true gradle-home-cache-cleanup: true
- name: Unit Test - name: Unit Test
run: ./gradlew :hideout-core:koverXmlReport run: ./hideout-core/gradlew :hideout-core:koverXmlReport
- name: Add coverage report to PR - name: Add coverage report to PR
if: always() if: always()
@ -94,9 +94,13 @@ jobs:
name: Lint name: Lint
needs: [ setup ] needs: [ setup ]
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up JDK 21 - name: Set up JDK 21
uses: actions/setup-java@v4 uses: actions/setup-java@v4
@ -111,7 +115,7 @@ jobs:
gradle-home-cache-cleanup: true gradle-home-cache-cleanup: true
- name: Build with Gradle - name: Build with Gradle
run: ./gradlew :hideout-core:detektMain run: ./hideout-core/gradlew :hideout-core:detektMain
- name: Auto Commit - name: Auto Commit
if: ${{ always() }} if: ${{ always() }}

View File

@ -1,4 +1,4 @@
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.configureondemand=true org.gradle.configureondemand=true
org.gradle.caching=true org.gradle.caching=true
org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED -XX:TieredStopAtLevel=1 -noverify org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED

View File

@ -103,7 +103,7 @@ dependencies {
implementation(libs.flyway.core) implementation(libs.flyway.core)
runtimeOnly(libs.flyway.postgresql) runtimeOnly(libs.flyway.postgresql)
implementation("dev.usbharu:owl-common-serialize-jackson:0.0.1") implementation(libs.owl.common.serialize.jackson)
implementation(libs.javacv) { implementation(libs.javacv) {
exclude(module = "opencv") exclude(module = "opencv")
@ -122,8 +122,8 @@ dependencies {
implementation(variantOf(libs.javacv.ffmpeg) { classifier("linux-x86_64") }) implementation(variantOf(libs.javacv.ffmpeg) { classifier("linux-x86_64") })
} }
implementation("dev.usbharu:http-signature:1.0.0") implementation(libs.http.signature)
implementation("dev.usbharu:emoji-kt:2.0.0") implementation(libs.emoji.kt)
@ -132,16 +132,13 @@ dependencies {
testImplementation(libs.coroutines.test) testImplementation(libs.coroutines.test)
testImplementation(libs.ktor.client.mock) testImplementation(libs.ktor.client.mock)
testImplementation(libs.h2db) testImplementation(libs.h2db)
testImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0") testImplementation(libs.mockito.kotlin)
testImplementation("org.mockito:mockito-inline:5.2.0")
testImplementation("nl.jqno.equalsverifier:equalsverifier:3.16.1")
testImplementation("com.jparams:to-string-verifier:1.4.8")
} }
detekt { detekt {
parallel = true parallel = true
config = files("../detekt.yml") config.setFrom(files("../detekt.yml"))
buildUponDefaultConfig = true buildUponDefaultConfig = true
basePath = "${rootDir.absolutePath}/src/main/kotlin" basePath = "${rootDir.absolutePath}/src/main/kotlin"
autoCorrect = true autoCorrect = true

0
hideout-core/gradlew vendored Normal file → Executable file
View File

View File

@ -58,13 +58,15 @@ class MigrationLocalActorApplicationService(
if (canAccountMigration.canMigration) { if (canAccountMigration.canMigration) {
fromActor.moveTo = toActorId fromActor.moveTo = toActorId
actorRepository.save(fromActor) actorRepository.save(fromActor)
} else when (canAccountMigration) { } else {
is AlreadyMoved -> throw IllegalArgumentException(canAccountMigration.message) when (canAccountMigration) {
is CanAccountMigration -> throw InternalServerException() is AlreadyMoved -> throw IllegalArgumentException(canAccountMigration.message)
is CircularReferences -> throw IllegalArgumentException(canAccountMigration.message) is CanAccountMigration -> throw InternalServerException()
is SelfReferences -> throw IllegalArgumentException("Self references are not supported") is CircularReferences -> throw IllegalArgumentException(canAccountMigration.message)
is AlsoKnownAsNotFound -> throw IllegalArgumentException(canAccountMigration.message) is SelfReferences -> throw IllegalArgumentException("Self references are not supported")
is MigrationCoolDown -> throw IllegalArgumentException(canAccountMigration.message) is AlsoKnownAsNotFound -> throw IllegalArgumentException(canAccountMigration.message)
is MigrationCoolDown -> throw IllegalArgumentException(canAccountMigration.message)
}
} }
} }

View File

@ -91,7 +91,6 @@ class RegisterApplicationApplicationService(
) )
} }
companion object { companion object {
private val logger = LoggerFactory.getLogger(RegisterApplicationApplicationService::class.java) private val logger = LoggerFactory.getLogger(RegisterApplicationApplicationService::class.java)
} }

View File

@ -36,15 +36,13 @@ class TimelineRelationshipFollowSubscriber(
relationship.targetActorId, relationship.targetActorId,
Visible.FOLLOWERS Visible.FOLLOWERS
) )
), it.body.principal ),
it.body.principal
) )
} }
} }
companion object { companion object {
private val logger = LoggerFactory.getLogger(TimelineRelationshipFollowSubscriber::class.java) private val logger = LoggerFactory.getLogger(TimelineRelationshipFollowSubscriber::class.java)
} }
}
}

View File

@ -11,4 +11,4 @@ class InternalServerException : RuntimeException {
enableSuppression, enableSuppression,
writableStackTrace writableStackTrace
) )
} }

View File

@ -11,4 +11,4 @@ class PermissionDeniedException : RuntimeException {
enableSuppression, enableSuppression,
writableStackTrace writableStackTrace
) )
} }

View File

@ -37,7 +37,6 @@ class UserRegisterFilterApplicationService(
) { ) {
override suspend fun internalExecute(command: RegisterFilter, principal: LocalUser): Filter { override suspend fun internalExecute(command: RegisterFilter, principal: LocalUser): Filter {
val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create( val filter = dev.usbharu.hideout.core.domain.model.filter.Filter.create(
id = FilterId(idGenerateService.generateId()), id = FilterId(idGenerateService.generateId()),
userDetailId = principal.userDetailId, userDetailId = principal.userDetailId,

View File

@ -16,18 +16,20 @@ class GetLocalInstanceApplicationService(
transaction: Transaction transaction: Transaction
) : ) :
AbstractApplicationService<Unit, Instance>( AbstractApplicationService<Unit, Instance>(
transaction, logger transaction,
logger
) { ) {
var cachedInstance: Instance? = null var cachedInstance: Instance? = null
override suspend fun internalExecute(command: Unit, principal: Principal): Instance { override suspend fun internalExecute(command: Unit, principal: Principal): Instance {
if (cachedInstance != null) { if (cachedInstance != null) {
return cachedInstance!! return cachedInstance!!
} }
val instance = (instanceRepository.findByUrl(applicationConfig.url.toURI()) val instance = (
?: throw InternalServerException("Local instance not found.")) instanceRepository.findByUrl(applicationConfig.url.toURI())
?: throw InternalServerException("Local instance not found.")
)
cachedInstance = Instance.of(instance) cachedInstance = Instance.of(instance)
return cachedInstance!! return cachedInstance!!
@ -36,4 +38,4 @@ class GetLocalInstanceApplicationService(
companion object { companion object {
private val logger = LoggerFactory.getLogger(GetLocalInstanceApplicationService::class.java) private val logger = LoggerFactory.getLogger(GetLocalInstanceApplicationService::class.java)
} }
} }

View File

@ -7,7 +7,10 @@ data class Instance(val id: Long, val name: String, val url: URI, val descriptio
companion object { companion object {
fun of(instance: Instance): dev.usbharu.hideout.core.application.instance.Instance { fun of(instance: Instance): dev.usbharu.hideout.core.application.instance.Instance {
return Instance( return Instance(
instance.id.instanceId, instance.name.name, instance.url, instance.description.description instance.id.instanceId,
instance.name.name,
instance.url,
instance.description.description
) )
} }
} }

View File

@ -1,6 +1,5 @@
package dev.usbharu.hideout.core.application.post package dev.usbharu.hideout.core.application.post
import dev.usbharu.hideout.core.domain.model.actor.Actor import dev.usbharu.hideout.core.domain.model.actor.Actor
import dev.usbharu.hideout.core.domain.model.instance.Instance import dev.usbharu.hideout.core.domain.model.instance.Instance
import dev.usbharu.hideout.core.domain.model.media.Media import dev.usbharu.hideout.core.domain.model.media.Media
@ -32,4 +31,4 @@ data class ActorDetail(
) )
} }
} }
} }

View File

@ -29,7 +29,8 @@ import org.springframework.stereotype.Service
@Service @Service
class DeleteLocalPostApplicationService( class DeleteLocalPostApplicationService(
private val postRepository: PostRepository, private val postRepository: PostRepository,
private val actorRepository: ActorRepository, transaction: Transaction, private val actorRepository: ActorRepository,
transaction: Transaction,
) : LocalUserAbstractApplicationService<DeleteLocalPost, Unit>(transaction, logger) { ) : LocalUserAbstractApplicationService<DeleteLocalPost, Unit>(transaction, logger) {
override suspend fun internalExecute(command: DeleteLocalPost, principal: LocalUser) { override suspend fun internalExecute(command: DeleteLocalPost, principal: LocalUser) {

View File

@ -25,7 +25,8 @@ class GetPostDetailApplicationService(
private val mediaRepository: MediaRepository, private val mediaRepository: MediaRepository,
private val iPostReadAccessControl: IPostReadAccessControl private val iPostReadAccessControl: IPostReadAccessControl
) : AbstractApplicationService<GetPostDetail, PostDetail>( ) : AbstractApplicationService<GetPostDetail, PostDetail>(
transaction, logger transaction,
logger
) { ) {
override suspend fun internalExecute(command: GetPostDetail, principal: Principal): PostDetail { override suspend fun internalExecute(command: GetPostDetail, principal: Principal): PostDetail {
val post = postRepository.findById(PostId(command.postId)) val post = postRepository.findById(PostId(command.postId))
@ -79,12 +80,15 @@ class GetPostDetailApplicationService(
val mediaList = mediaRepository.findByIds(post.mediaIds) val mediaList = mediaRepository.findByIds(post.mediaIds)
return PostDetail.of( return PostDetail.of(
post, first, second, third, mediaList post,
first,
second,
third,
mediaList
) )
} }
companion object { companion object {
private val logger = LoggerFactory.getLogger(GetPostDetailApplicationService::class.java) private val logger = LoggerFactory.getLogger(GetPostDetailApplicationService::class.java)
} }
} }

View File

@ -25,4 +25,4 @@ data class MediaDetail(
) )
} }
} }
} }

View File

@ -35,7 +35,6 @@ class UserAcceptFollowRequestApplicationService(
) : ) :
LocalUserAbstractApplicationService<AcceptFollowRequest, Unit>(transaction, logger) { LocalUserAbstractApplicationService<AcceptFollowRequest, Unit>(transaction, logger) {
override suspend fun internalExecute(command: AcceptFollowRequest, principal: LocalUser) { override suspend fun internalExecute(command: AcceptFollowRequest, principal: LocalUser) {
val actor = actorRepository.findById(principal.actorId) val actor = actorRepository.findById(principal.actorId)
?: throw InternalServerException("Actor ${principal.actorId} not found") ?: throw InternalServerException("Actor ${principal.actorId} not found")

View File

@ -36,8 +36,6 @@ class UserBlockApplicationService(
) : ) :
LocalUserAbstractApplicationService<Block, Unit>(transaction, logger) { LocalUserAbstractApplicationService<Block, Unit>(transaction, logger) {
override suspend fun internalExecute(command: Block, principal: LocalUser) { override suspend fun internalExecute(command: Block, principal: LocalUser) {
val actor = actorRepository.findById(principal.actorId) val actor = actorRepository.findById(principal.actorId)
?: throw IllegalStateException("Actor ${principal.actorId} not found") ?: throw IllegalStateException("Actor ${principal.actorId} not found")

View File

@ -46,14 +46,14 @@ class GetRelationshipApplicationService(
val target = actorRepository.findById(targetId) val target = actorRepository.findById(targetId)
?: throw IllegalArgumentException("Actor ${command.targetActorId} not found.") ?: throw IllegalArgumentException("Actor ${command.targetActorId} not found.")
val relationship = ( val relationship = (
relationshipRepository.findByActorIdAndTargetId(actor.id, targetId) relationshipRepository.findByActorIdAndTargetId(actor.id, targetId)
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(actor.id, targetId) ?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(actor.id, targetId)
) )
val relationship1 = ( val relationship1 = (
relationshipRepository.findByActorIdAndTargetId(targetId, actor.id) relationshipRepository.findByActorIdAndTargetId(targetId, actor.id)
?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(targetId, actor.id) ?: dev.usbharu.hideout.core.domain.model.relationship.Relationship.default(targetId, actor.id)
) )
val actorInstanceRelationship = val actorInstanceRelationship =
actorInstanceRelationshipRepository.findByActorIdAndInstanceId(actor.id, target.instance) actorInstanceRelationshipRepository.findByActorIdAndInstanceId(actor.id, target.instance)

View File

@ -15,4 +15,4 @@ abstract class LocalUserAbstractApplicationService<T : Any, R>(transaction: Tran
} }
protected abstract suspend fun internalExecute(command: T, principal: LocalUser): R protected abstract suspend fun internalExecute(command: T, principal: LocalUser): R
} }

View File

@ -13,7 +13,8 @@ class UserAddTimelineRelationshipApplicationService(
transaction: Transaction transaction: Transaction
) : ) :
LocalUserAbstractApplicationService<AddTimelineRelationship, Unit>( LocalUserAbstractApplicationService<AddTimelineRelationship, Unit>(
transaction, logger transaction,
logger
) { ) {
override suspend fun internalExecute(command: AddTimelineRelationship, principal: LocalUser) { override suspend fun internalExecute(command: AddTimelineRelationship, principal: LocalUser) {
timelineRelationshipRepository.save(command.timelineRelationship) timelineRelationshipRepository.save(command.timelineRelationship)
@ -22,4 +23,4 @@ class UserAddTimelineRelationshipApplicationService(
companion object { companion object {
private val logger = LoggerFactory.getLogger(UserAddTimelineRelationshipApplicationService::class.java) private val logger = LoggerFactory.getLogger(UserAddTimelineRelationshipApplicationService::class.java)
} }
} }

View File

@ -24,4 +24,4 @@ data class ApplicationConfig(
val url: URL, val url: URL,
val private: Boolean = true, val private: Boolean = true,
val keySize: Int = 2048, val keySize: Int = 2048,
) )

View File

@ -69,7 +69,6 @@ class Filter(
return id.hashCode() return id.hashCode()
} }
companion object { companion object {
fun isAllow(user: UserDetail, action: Action, resource: Filter): Boolean { fun isAllow(user: UserDetail, action: Action, resource: Filter): Boolean {
return when (action) { return when (action) {

View File

@ -241,25 +241,25 @@ class Post(
override fun toString(): String { override fun toString(): String {
return "Post(" + return "Post(" +
"id=$id, " + "id=$id, " +
"createdAt=$createdAt, " + "createdAt=$createdAt, " +
"url=$url, " + "url=$url, " +
"repostId=$repostId, " + "repostId=$repostId, " +
"replyId=$replyId, " + "replyId=$replyId, " +
"apId=$apId, " + "apId=$apId, " +
"actorId=$actorId, " + "actorId=$actorId, " +
"visibility=$visibility, " + "visibility=$visibility, " +
"visibleActors=$visibleActors, " + "visibleActors=$visibleActors, " +
"content=$content, " + "content=$content, " +
"overview=$overview, " + "overview=$overview, " +
"sensitive=$sensitive, " + "sensitive=$sensitive, " +
"text='$text', " + "text='$text', " +
"emojiIds=$emojiIds, " + "emojiIds=$emojiIds, " +
"mediaIds=$mediaIds, " + "mediaIds=$mediaIds, " +
"deleted=$deleted, " + "deleted=$deleted, " +
"hide=$hide, " + "hide=$hide, " +
"moveTo=$moveTo" + "moveTo=$moveTo" +
")" ")"
} }
companion object { companion object {
@ -315,6 +315,5 @@ class Post(
post.addDomainEvent(PostDomainEventFactory(post).createEvent(PostEvent.CREATE)) post.addDomainEvent(PostDomainEventFactory(post).createEvent(PostEvent.CREATE))
return post return post
} }
} }
} }

View File

@ -2,4 +2,4 @@ package dev.usbharu.hideout.core.domain.model.support.principal
import dev.usbharu.hideout.core.domain.model.actor.ActorId import dev.usbharu.hideout.core.domain.model.actor.ActorId
data object Anonymous : Principal(ActorId.ghost, null, null) data object Anonymous : Principal(ActorId.ghost, null, null)

View File

@ -12,4 +12,4 @@ class LocalUser(
actorId, actorId,
userDetailId, userDetailId,
acct acct
) )

View File

@ -4,4 +4,4 @@ import dev.usbharu.hideout.core.domain.model.actor.ActorId
import dev.usbharu.hideout.core.domain.model.support.acct.Acct import dev.usbharu.hideout.core.domain.model.support.acct.Acct
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
sealed class Principal(open val actorId: ActorId, open val userDetailId: UserDetailId?, open val acct: Acct?) sealed class Principal(open val actorId: ActorId, open val userDetailId: UserDetailId?, open val acct: Acct?)

View File

@ -2,4 +2,4 @@ package dev.usbharu.hideout.core.domain.model.support.principal
interface PrincipalContextHolder { interface PrincipalContextHolder {
suspend fun getPrincipal(): Principal suspend fun getPrincipal(): Principal
} }

View File

@ -33,7 +33,7 @@ class TimelineObject(
lastUpdatedAt: Instant, lastUpdatedAt: Instant,
var warnFilters: List<TimelineObjectWarnFilter>, var warnFilters: List<TimelineObjectWarnFilter>,
) { ) {
var isPureRepost = isPureRepost var isPureRepost = isPureRepost
private set private set
var visibleActors = visibleActors var visibleActors = visibleActors
@ -125,9 +125,9 @@ class TimelineObject(
repostActorId = repost.actorId, repostActorId = repost.actorId,
visibility = post.visibility, visibility = post.visibility,
isPureRepost = repost.mediaIds.isEmpty() && isPureRepost = repost.mediaIds.isEmpty() &&
repost.overview == null && repost.overview == null &&
repost.content == PostContent.empty && repost.content == PostContent.empty &&
repost.replyId == null, repost.replyId == null,
mediaIds = post.mediaIds, mediaIds = post.mediaIds,
emojiIds = post.emojiIds, emojiIds = post.emojiIds,
visibleActors = post.visibleActors.toList(), visibleActors = post.visibleActors.toList(),

View File

@ -16,36 +16,37 @@ interface IPostReadAccessControl {
class DefaultPostReadAccessControl(private val relationshipRepository: RelationshipRepository) : class DefaultPostReadAccessControl(private val relationshipRepository: RelationshipRepository) :
IPostReadAccessControl { IPostReadAccessControl {
override suspend fun isAllow(post: Post, principal: Principal): Boolean { override suspend fun isAllow(post: Post, principal: Principal): Boolean {
// ポスト主は無条件で見れる
//ポスト主は無条件で見れる
if (post.actorId == principal.actorId) { if (post.actorId == principal.actorId) {
return true return true
} }
val relationship = (relationshipRepository.findByActorIdAndTargetId(post.actorId, principal.actorId) val relationship = (
?: Relationship.default(post.actorId, principal.actorId)) relationshipRepository.findByActorIdAndTargetId(post.actorId, principal.actorId)
?: Relationship.default(post.actorId, principal.actorId)
)
//ブロックされてたら見れない // ブロックされてたら見れない
if (relationship.blocking) { if (relationship.blocking) {
return false return false
} }
//PublicかUnlistedなら見れる // PublicかUnlistedなら見れる
if (post.visibility == Visibility.PUBLIC || post.visibility == Visibility.UNLISTED) { if (post.visibility == Visibility.PUBLIC || post.visibility == Visibility.UNLISTED) {
return true return true
} }
//principalがAnonymousなら見れない // principalがAnonymousなら見れない
if (principal is Anonymous) { if (principal is Anonymous) {
return false return false
} }
//DirectでvisibleActorsに含まれていたら見れる // DirectでvisibleActorsに含まれていたら見れる
if (post.visibility == Visibility.DIRECT && post.visibleActors.contains(principal.actorId)) { if (post.visibility == Visibility.DIRECT && post.visibleActors.contains(principal.actorId)) {
return true return true
} }
//Followersでフォロワーなら見れる // Followersでフォロワーなら見れる
if (post.visibility == Visibility.FOLLOWERS) { if (post.visibility == Visibility.FOLLOWERS) {
val inverseRelationship = val inverseRelationship =
relationshipRepository.findByActorIdAndTargetId(principal.actorId, post.actorId) ?: return false relationshipRepository.findByActorIdAndTargetId(principal.actorId, post.actorId) ?: return false
@ -53,8 +54,7 @@ class DefaultPostReadAccessControl(private val relationshipRepository: Relations
return inverseRelationship.following return inverseRelationship.following
} }
//その他の場合は見れない // その他の場合は見れない
return false return false
} }
}
}

View File

@ -34,4 +34,4 @@ class ExposedPrincipalQueryService : PrincipalQueryService, AbstractRepository()
companion object { companion object {
private val logger: Logger = LoggerFactory.getLogger(ExposedPrincipalQueryService::class.java) private val logger: Logger = LoggerFactory.getLogger(ExposedPrincipalQueryService::class.java)
} }
} }

View File

@ -22,7 +22,6 @@ class SpringSecurityFormLoginPrincipalContextHolder(
SecurityContextHolder.getContext().authentication?.principal as? HideoutUserDetails ?: return Anonymous SecurityContextHolder.getContext().authentication?.principal as? HideoutUserDetails ?: return Anonymous
return transaction.transaction { return transaction.transaction {
val userDetail = principalQueryService.findByUserDetailId(UserDetailId(hideoutUserDetails.userDetailsId)) val userDetail = principalQueryService.findByUserDetailId(UserDetailId(hideoutUserDetails.userDetailsId))
LocalUser( LocalUser(
userDetail.actorId, userDetail.actorId,
@ -30,6 +29,5 @@ class SpringSecurityFormLoginPrincipalContextHolder(
Acct(userDetail.username, userDetail.host) Acct(userDetail.username, userDetail.host)
) )
} }
} }
} }

View File

@ -33,4 +33,4 @@ class SpringSecurityOauth2PrincipalContextHolder(
) )
} }
} }
} }

View File

@ -30,4 +30,4 @@ data class InternalTimelineObjectOption(
val localOnly: Boolean? = null, val localOnly: Boolean? = null,
val remoteOnly: Boolean? = null, val remoteOnly: Boolean? = null,
val mediaOnly: Boolean? = null val mediaOnly: Boolean? = null
) )

View File

@ -38,7 +38,8 @@ class AuthController(
suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, request: HttpServletRequest): String { suspend fun signUp(@Validated @ModelAttribute signUpForm: SignUpForm, request: HttpServletRequest): String {
val registerLocalActor = RegisterLocalActor(signUpForm.username, signUpForm.password) val registerLocalActor = RegisterLocalActor(signUpForm.username, signUpForm.password)
val uri = registerLocalActorApplicationService.execute( val uri = registerLocalActorApplicationService.execute(
registerLocalActor, Anonymous registerLocalActor,
Anonymous
) )
request.login(signUpForm.username, signUpForm.password) request.login(signUpForm.username, signUpForm.password)
return "redirect:$uri" return "redirect:$uri"

View File

@ -30,7 +30,6 @@ import org.springframework.web.bind.annotation.PathVariable
import java.nio.file.Path import java.nio.file.Path
import kotlin.io.path.name import kotlin.io.path.name
@Controller @Controller
@ConditionalOnProperty("hideout.storage.type", havingValue = "local", matchIfMissing = true) @ConditionalOnProperty("hideout.storage.type", havingValue = "local", matchIfMissing = true)
class LocalFileController( class LocalFileController(
@ -64,4 +63,4 @@ class LocalFileController(
.contentLength(pathResource.contentLength()) .contentLength(pathResource.contentLength())
.body(pathResource) .body(pathResource)
} }
} }

View File

@ -31,4 +31,4 @@ class PostsController(
return "postById" return "postById"
} }
} }

View File

@ -55,6 +55,6 @@ class PublishController(
) )
val id = userRegisterLocalPostApplicationService.execute(command, principal) val id = userRegisterLocalPostApplicationService.execute(command, principal)
return "redirect:/users/${principal.acct?.userpart}/posts/${id}" return "redirect:/users/${principal.acct?.userpart}/posts/$id"
} }
} }

View File

@ -3,4 +3,4 @@ package dev.usbharu.hideout.core.query.principal
import dev.usbharu.hideout.core.domain.model.actor.ActorId import dev.usbharu.hideout.core.domain.model.actor.ActorId
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
data class PrincipalDTO(val userDetailId: UserDetailId, val actorId: ActorId, val username: String, val host: String) data class PrincipalDTO(val userDetailId: UserDetailId, val actorId: ActorId, val username: String, val host: String)

View File

@ -4,4 +4,4 @@ import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
interface PrincipalQueryService { interface PrincipalQueryService {
suspend fun findByUserDetailId(userDetailId: UserDetailId): PrincipalDTO suspend fun findByUserDetailId(userDetailId: UserDetailId): PrincipalDTO
} }

View File

@ -7,11 +7,12 @@ javacv-ffmpeg = "6.1.1-1.5.10"
detekt = "1.23.6" detekt = "1.23.6"
coroutines = "1.8.1" coroutines = "1.8.1"
swagger = "2.2.22" swagger = "2.2.22"
serialization = "1.7.1"
kjob = "0.6.0"
tika = "2.9.2" tika = "2.9.2"
owl = "0.0.1" owl = "0.0.1"
jackson = "2.17.2" jackson = "2.17.2"
protobuf = "4.27.3"
grpc-java = "1.66.0"
grpc-kotlin = "1.4.1"
[libraries] [libraries]
@ -20,9 +21,9 @@ exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "e
exposed-spring = { module = "org.jetbrains.exposed:exposed-spring-boot-starter", version.ref = "exposed" } exposed-spring = { module = "org.jetbrains.exposed:exposed-spring-boot-starter", version.ref = "exposed" }
exposed-java-time = { module = "org.jetbrains.exposed:exposed-java-time", version.ref = "exposed" } exposed-java-time = { module = "org.jetbrains.exposed:exposed-java-time", version.ref = "exposed" }
cotoutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
cotoutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor", version.ref = "coroutines" } coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor", version.ref = "coroutines" }
cotoutines-slf4j = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", version.ref = "coroutines" } coroutines-slf4j = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", version.ref = "coroutines" }
coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
javacv = { module = "org.bytedeco:javacv", version = "1.5.10" } javacv = { module = "org.bytedeco:javacv", version = "1.5.10" }
@ -49,20 +50,15 @@ jakarta-annotation = { module = "jakarta.annotation:jakarta.annotation-api", ver
swagger-annotations = { module = "io.swagger.core.v3:swagger-annotations", version.ref = "swagger" } swagger-annotations = { module = "io.swagger.core.v3:swagger-annotations", version.ref = "swagger" }
swagger-models = { module = "io.swagger.core.v3:swagger-models", version.ref = "swagger" } swagger-models = { module = "io.swagger.core.v3:swagger-models", version.ref = "swagger" }
serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialization" }
serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
apache-tika-core = { module = "org.apache.tika:tika-core", version.ref = "tika" } apache-tika-core = { module = "org.apache.tika:tika-core", version.ref = "tika" }
apache-tika-parsers = { module = "org.apache.tika:tika-parsers", version.ref = "tika" } apache-tika-parsers = { module = "org.apache.tika:tika-parsers", version.ref = "tika" }
kjon-core = { module = "org.drewcarlson:kjob-core", version.ref = "kjob" }
kjon-mongo = { module = "org.drewcarlson:kjob-mongo", version.ref = "kjob" }
owl-producer-api = { module = "dev.usbharu:owl-producer-api", version.ref = "owl" } owl-producer-api = { module = "dev.usbharu:owl-producer-api", version.ref = "owl" }
owl-producer-default = { module = "dev.usbharu:owl-producer-default", version.ref = "owl" } owl-producer-default = { module = "dev.usbharu:owl-producer-default", version.ref = "owl" }
owl-producer-embedded = { module = "dev.usbharu:owl-producer-embedded", version.ref = "owl" } owl-producer-embedded = { module = "dev.usbharu:owl-producer-embedded", version.ref = "owl" }
owl-broker = { module = "dev.usbharu:owl-broker", version.ref = "owl" } owl-broker = { module = "dev.usbharu:owl-broker", version.ref = "owl" }
owl-broker-mongodb = { module = "dev.usbharu:owl-broker-mongodb", version.ref = "owl" } owl-broker-mongodb = { module = "dev.usbharu:owl-broker-mongodb", version.ref = "owl" }
owl-common-serialize-jackson = { module = "dev.usbharu:owl-common-serialize-jackson", version.ref = "owl" }
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" } jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" } jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
@ -88,20 +84,40 @@ h2db = { module = "com.h2database:h2", version = "2.3.232" }
kotlin-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } kotlin-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
grpc-kotlin-stub = { module = "io.grpc:grpc-kotlin-stub", version.ref = "grpc-kotlin" }
grpc-protobuf = { module = "io.grpc:grpc-protobuf", version.ref = "grpc-java" }
grpc-netty = { module = "io.grpc:grpc-netty", version.ref = "grpc-java" }
protoc-gen-grpc-java = { module = "io.grpc:protoc-gen-grpc-java", version.ref = "grpc-java" }
protoc-gen-grpc-kotlin = { module = "io.grpc:protoc-gen-grpc-kotlin", version.ref = "grpc-kotlin" }
protobuf-kotlin = { module = "com.google.protobuf:protobuf-kotlin", version.ref = "protobuf" }
protoc = { module = "com.google.protobuf:protoc", version.ref = "protobuf" }
koin-bom = { module = "io.insert-koin:koin-bom", version = "3.5.6" }
koin-core = { module = "io.insert-koin:koin-core" }
log4j2-slf4j = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version = "2.23.1" }
mongodb-kotlin-coroutine = { module = "org.mongodb:mongodb-driver-kotlin-coroutine", version = "5.1.3" }
mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version = "5.4.0" }
http-signature = { module = "dev.usbharu:http-signature", version = "1.0.0" }
emoji-kt = { module = "dev.usbharu:emoji-kt", version = "2.0.0" }
[bundles] [bundles]
exposed = ["exposed-core", "exposed-java-time", "exposed-jdbc", "exposed-spring"] exposed = ["exposed-core", "exposed-java-time", "exposed-jdbc", "exposed-spring"]
coroutines = ["cotoutines-core", "cotoutines-reactor", "cotoutines-slf4j"] coroutines = ["coroutines-core", "coroutines-reactor", "coroutines-slf4j"]
ktor-client = ["ktor-client-cio", "ktor-client-content-negotiation", "ktor-client-core", "ktor-client-logging-jvm", "ktor-serialization-jackson"] ktor-client = ["ktor-client-cio", "ktor-client-content-negotiation", "ktor-client-core", "ktor-client-logging-jvm", "ktor-serialization-jackson"]
spring-boot-oauth2 = ["spring-boot-oauth2-authorization", "spring-boot-oauth2-jose", "spring-boot-oauth2-resource"] spring-boot-oauth2 = ["spring-boot-oauth2-authorization", "spring-boot-oauth2-jose", "spring-boot-oauth2-resource"]
spring-boot-data-mongodb = ["spring-boot-data-mongodb", "spring-boot-data-mongodb-reactive"] spring-boot-data-mongodb = ["spring-boot-data-mongodb", "spring-boot-data-mongodb-reactive"]
openapi = ["jakarta-annotation", "jakarta-validation", "swagger-annotations", "swagger-models"] openapi = ["jakarta-annotation", "jakarta-validation", "swagger-annotations", "swagger-models"]
serialization = ["serialization-core", "serialization-json"]
apache-tika = ["apache-tika-core", "apache-tika-parsers"] apache-tika = ["apache-tika-core", "apache-tika-parsers"]
kjob = ["kjon-core", "kjon-mongo"]
owl-producer = ["owl-producer-api", "owl-producer-default", "owl-producer-embedded"] owl-producer = ["owl-producer-api", "owl-producer-default", "owl-producer-embedded"]
owl-broker = ["owl-broker", "owl-broker-mongodb"] owl-broker = ["owl-broker", "owl-broker-mongodb"]
jackson = ["jackson-databind", "jackson-module-kotlin"] jackson = ["jackson-databind", "jackson-module-kotlin"]
grpc-kotlin = ["grpc-kotlin-stub", "grpc-netty", "grpc-protobuf", "protobuf-kotlin"]
[plugins] [plugins]
@ -111,4 +127,5 @@ detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" } kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version = "0.8.3" } kover = { id = "org.jetbrains.kotlinx.kover", version = "0.8.3" }
openapi-generator = { id = "org.openapi.generator", version = "7.7.0" } openapi-generator = { id = "org.openapi.generator", version = "7.7.0" }
license-report = { id = "com.github.jk1.dependency-license-report", version = "2.8" } license-report = { id = "com.github.jk1.dependency-license-report", version = "2.8" }
protobuf-plugin = { id = "com.google.protobuf", version = "0.9.4" }

View File

@ -1,6 +1,6 @@
plugins { plugins {
alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlin.jvm)
id("com.google.protobuf") version "0.9.4" alias(libs.plugins.protobuf.plugin)
} }
@ -11,15 +11,12 @@ repositories {
} }
dependencies { dependencies {
implementation("io.grpc:grpc-kotlin-stub:1.4.1") implementation(libs.bundles.grpc.kotlin)
implementation("io.grpc:grpc-protobuf:1.66.0") implementation(libs.coroutines.core)
implementation("com.google.protobuf:protobuf-kotlin:4.27.3")
implementation("io.grpc:grpc-netty:1.66.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
implementation(project(":owl-common")) implementation(project(":owl-common"))
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.23.1") implementation(libs.log4j2.slf4j)
implementation(platform("io.insert-koin:koin-bom:3.5.6")) implementation(platform(libs.koin.bom))
implementation("io.insert-koin:koin-core") implementation(libs.koin.core)
} }
tasks.test { tasks.test {
@ -31,14 +28,14 @@ kotlin {
protobuf { protobuf {
protoc { protoc {
artifact = "com.google.protobuf:protoc:4.27.3" artifact = libs.protoc.asProvider().get().toString()
} }
plugins { plugins {
create("grpc") { create("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.66.0" artifact = libs.protoc.gen.grpc.java.get().toString()
} }
create("grpckt") { create("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.4.1:jdk8@jar" artifact = libs.protoc.gen.grpc.kotlin.get().toString() + "jdk8@jar"
} }
} }
generateProtoTasks { generateProtoTasks {

View File

@ -10,12 +10,11 @@ repositories {
} }
dependencies { dependencies {
implementation("org.mongodb:mongodb-driver-kotlin-coroutine:5.1.3") implementation(libs.mongodb.kotlin.coroutine)
implementation(project(":owl-broker")) implementation(project(":owl-broker"))
implementation(project(":owl-common")) implementation(project(":owl-common"))
implementation(platform("io.insert-koin:koin-bom:3.5.6")) implementation(platform(libs.koin.bom))
implementation(platform("io.insert-koin:koin-annotations-bom:1.3.1")) implementation(libs.koin.core)
implementation("io.insert-koin:koin-core")
} }
tasks.test { tasks.test {

View File

@ -9,7 +9,7 @@ repositories {
} }
dependencies { dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test") testImplementation(libs.kotlin.junit)
} }
tasks.test { tasks.test {

View File

@ -1,6 +1,6 @@
plugins { plugins {
alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlin.jvm)
id("com.google.protobuf") version "0.9.4" alias(libs.plugins.protobuf.plugin)
} }
group = "dev.usbharu" group = "dev.usbharu"
@ -10,12 +10,9 @@ repositories {
} }
dependencies { dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test") testImplementation(libs.kotlin.junit)
implementation("io.grpc:grpc-kotlin-stub:1.4.1") implementation(libs.bundles.grpc.kotlin)
implementation("io.grpc:grpc-protobuf:1.66.0") implementation(libs.coroutines.core)
implementation("com.google.protobuf:protobuf-kotlin:4.27.3")
implementation("io.grpc:grpc-netty:1.66.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
implementation(project(":owl-common")) implementation(project(":owl-common"))
protobuf(files(project(":owl-broker").dependencyProject.projectDir.toString() + "/src/main/proto")) protobuf(files(project(":owl-broker").dependencyProject.projectDir.toString() + "/src/main/proto"))
} }
@ -29,14 +26,14 @@ kotlin {
protobuf { protobuf {
protoc { protoc {
artifact = "com.google.protobuf:protoc:4.27.3" artifact = libs.protoc.asProvider().get().toString()
} }
plugins { plugins {
create("grpc") { create("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.66.0" artifact = libs.protoc.gen.grpc.java.get().toString()
} }
create("grpckt") { create("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.4.1:jdk8@jar" artifact = libs.protoc.gen.grpc.kotlin.get().toString() + "jdk8@jar"
} }
} }
generateProtoTasks { generateProtoTasks {

View File

@ -1,6 +1,6 @@
plugins { plugins {
alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlin.jvm)
id("com.google.protobuf") version "0.9.4" alias(libs.plugins.protobuf.plugin)
} }
group = "dev.usbharu" group = "dev.usbharu"
@ -10,13 +10,10 @@ repositories {
} }
dependencies { dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test") testImplementation(libs.kotlin.junit)
api(project(":owl-producer:owl-producer-api")) api(project(":owl-producer:owl-producer-api"))
implementation("io.grpc:grpc-kotlin-stub:1.4.1") implementation(libs.bundles.grpc.kotlin)
implementation("io.grpc:grpc-protobuf:1.66.0") implementation(libs.coroutines.core)
implementation("com.google.protobuf:protobuf-kotlin:4.27.3")
implementation("io.grpc:grpc-netty:1.66.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
implementation(project(":owl-common")) implementation(project(":owl-common"))
protobuf(files(project(":owl-broker").dependencyProject.projectDir.toString() + "/src/main/proto")) protobuf(files(project(":owl-broker").dependencyProject.projectDir.toString() + "/src/main/proto"))
} }
@ -30,14 +27,14 @@ kotlin {
protobuf { protobuf {
protoc { protoc {
artifact = "com.google.protobuf:protoc:4.27.3" artifact = libs.protoc.asProvider().get().toString()
} }
plugins { plugins {
create("grpc") { create("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.66.0" artifact = libs.protoc.gen.grpc.java.get().toString()
} }
create("grpckt") { create("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.4.1:jdk8@jar" artifact = libs.protoc.gen.grpc.kotlin.get().toString() + "jdk8@jar"
} }
} }
generateProtoTasks { generateProtoTasks {

View File

@ -12,9 +12,9 @@ dependencies {
testImplementation(kotlin("test")) testImplementation(kotlin("test"))
implementation(project(":owl-producer:owl-producer-api")) implementation(project(":owl-producer:owl-producer-api"))
implementation(project(":owl-broker")) implementation(project(":owl-broker"))
implementation(platform("io.insert-koin:koin-bom:3.5.6")) implementation(platform(libs.koin.bom))
implementation("io.insert-koin:koin-core") implementation(libs.koin.core)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") implementation(libs.coroutines.core)
} }
tasks.test { tasks.test {