refactor: Hideoutユーザー側の設定もActivityPubと合わせるように

This commit is contained in:
usbharu 2023-12-12 12:02:54 +09:00
parent fe74d1e30b
commit 4e8cffdbe2
6 changed files with 4 additions and 10 deletions

View File

@ -3,6 +3,5 @@ package dev.usbharu.hideout.core.domain.model.userdetails
data class UserDetail( data class UserDetail(
val actorId: Long, val actorId: Long,
val password: String, val password: String,
val autoAcceptFollowRequest: Boolean,
val autoAcceptFolloweeFollowRequest: Boolean val autoAcceptFolloweeFollowRequest: Boolean
) )

View File

@ -18,13 +18,11 @@ class UserDetailRepositoryImpl : UserDetailRepository {
UserDetails.insert { UserDetails.insert {
it[actorId] = userDetail.actorId it[actorId] = userDetail.actorId
it[password] = userDetail.password it[password] = userDetail.password
it[autoAcceptFollowRequest] = userDetail.autoAcceptFollowRequest
it[autoAcceptFolloweeFollowRequest] = userDetail.autoAcceptFolloweeFollowRequest it[autoAcceptFolloweeFollowRequest] = userDetail.autoAcceptFolloweeFollowRequest
} }
} else { } else {
UserDetails.update({ UserDetails.actorId eq userDetail.actorId }) { UserDetails.update({ UserDetails.actorId eq userDetail.actorId }) {
it[password] = userDetail.password it[password] = userDetail.password
it[autoAcceptFollowRequest] = userDetail.autoAcceptFollowRequest
it[autoAcceptFolloweeFollowRequest] = userDetail.autoAcceptFolloweeFollowRequest it[autoAcceptFolloweeFollowRequest] = userDetail.autoAcceptFolloweeFollowRequest
} }
} }
@ -43,7 +41,6 @@ class UserDetailRepositoryImpl : UserDetailRepository {
UserDetail( UserDetail(
it[UserDetails.actorId], it[UserDetails.actorId],
it[UserDetails.password], it[UserDetails.password],
it[UserDetails.autoAcceptFollowRequest],
it[UserDetails.autoAcceptFolloweeFollowRequest] it[UserDetails.autoAcceptFolloweeFollowRequest]
) )
} }
@ -55,6 +52,5 @@ class UserDetailRepositoryImpl : UserDetailRepository {
object UserDetails : LongIdTable("user_details") { object UserDetails : LongIdTable("user_details") {
val actorId = long("actor_id").references(Actors.id) val actorId = long("actor_id").references(Actors.id)
val password = varchar("password", 255) val password = varchar("password", 255)
val autoAcceptFollowRequest = bool("auto_accept_follow_request")
val autoAcceptFolloweeFollowRequest = bool("auto_accept_followee_follow_request") val autoAcceptFolloweeFollowRequest = bool("auto_accept_followee_follow_request")
} }

View File

@ -7,6 +7,6 @@ data class UpdateUserDto(
val description: String, val description: String,
val avatarMedia: Media?, val avatarMedia: Media?,
val headerMedia: Media?, val headerMedia: Media?,
val autoAcceptFollowRequest: Boolean, val locked: Boolean,
val autoAcceptFolloweeFollowRequest: Boolean val autoAcceptFolloweeFollowRequest: Boolean
) )

View File

@ -53,7 +53,7 @@ class UserServiceImpl(
locked = false locked = false
) )
val save = actorRepository.save(userEntity) val save = actorRepository.save(userEntity)
userDetailRepository.save(UserDetail(nextId, hashedPassword, true, true)) userDetailRepository.save(UserDetail(nextId, hashedPassword, true))
return save return save
} }
@ -106,12 +106,12 @@ class UserServiceImpl(
actor.copy( actor.copy(
screenName = updateUserDto.screenName, screenName = updateUserDto.screenName,
description = updateUserDto.description, description = updateUserDto.description,
locked = updateUserDto.locked
) )
) )
userDetailRepository.save( userDetailRepository.save(
userDetail.copy( userDetail.copy(
autoAcceptFollowRequest = updateUserDto.autoAcceptFollowRequest,
autoAcceptFolloweeFollowRequest = updateUserDto.autoAcceptFolloweeFollowRequest autoAcceptFolloweeFollowRequest = updateUserDto.autoAcceptFolloweeFollowRequest
) )
) )

View File

@ -195,7 +195,7 @@ class AccountApiServiceImpl(
description = updateCredentials?.note ?: account.note, description = updateCredentials?.note ?: account.note,
avatarMedia = avatarMedia, avatarMedia = avatarMedia,
headerMedia = headerMedia, headerMedia = headerMedia,
autoAcceptFollowRequest = updateCredentials?.locked ?: account.locked, locked = updateCredentials?.locked ?: account.locked,
autoAcceptFolloweeFollowRequest = false autoAcceptFolloweeFollowRequest = false
) )
userService.updateUser(userid, updateUserDto) userService.updateUser(userid, updateUserDto)

View File

@ -40,7 +40,6 @@ create table if not exists user_details
id bigserial primary key, id bigserial primary key,
actor_id bigint not null unique, actor_id bigint not null unique,
password varchar(255) not null, password varchar(255) not null,
auto_accept_follow_request boolean not null,
auto_accept_followee_follow_request boolean not null, auto_accept_followee_follow_request boolean not null,
constraint fk_user_details_actor_id__id foreign key (actor_id) references actors (id) on delete restrict on update restrict constraint fk_user_details_actor_id__id foreign key (actor_id) references actors (id) on delete restrict on update restrict
); );