feat: 自分自身をホームタイムラインに追加するように

This commit is contained in:
usbharu 2024-08-16 15:02:32 +09:00
parent e9d776f71a
commit e1787423e8
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
3 changed files with 52 additions and 8 deletions

View File

@ -4,6 +4,10 @@ import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
import dev.usbharu.hideout.core.application.shared.Transaction import dev.usbharu.hideout.core.application.shared.Transaction
import dev.usbharu.hideout.core.domain.model.support.principal.Principal import dev.usbharu.hideout.core.domain.model.support.principal.Principal
import dev.usbharu.hideout.core.domain.model.timeline.* import dev.usbharu.hideout.core.domain.model.timeline.*
import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationship
import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationshipId
import dev.usbharu.hideout.core.domain.model.timelinerelationship.TimelineRelationshipRepository
import dev.usbharu.hideout.core.domain.model.timelinerelationship.Visible
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailRepository
import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService
@ -15,6 +19,7 @@ class UserRegisterHomeTimelineApplicationService(
private val userDetailRepository: UserDetailRepository, private val userDetailRepository: UserDetailRepository,
private val timelineRepository: TimelineRepository, private val timelineRepository: TimelineRepository,
private val idGenerateService: IdGenerateService, transaction: Transaction, private val idGenerateService: IdGenerateService, transaction: Transaction,
private val timelineRelationshipRepository: TimelineRelationshipRepository
) : AbstractApplicationService<RegisterHomeTimeline, Unit>(transaction, logger) { ) : AbstractApplicationService<RegisterHomeTimeline, Unit>(transaction, logger) {
override suspend fun internalExecute(command: RegisterHomeTimeline, principal: Principal) { override suspend fun internalExecute(command: RegisterHomeTimeline, principal: Principal) {
@ -31,6 +36,15 @@ class UserRegisterHomeTimelineApplicationService(
timelineRepository.save(timeline) timelineRepository.save(timeline)
userDetail.homeTimelineId = timeline.id userDetail.homeTimelineId = timeline.id
val timelineRelationship = TimelineRelationship(
TimelineRelationshipId(idGenerateService.generateId()),
timeline.id,
userDetail.actorId,
Visible.DIRECT
)
timelineRelationshipRepository.save(timelineRelationship)
userDetailRepository.save(userDetail) userDetailRepository.save(userDetail)
} }

View File

@ -20,6 +20,12 @@ hideout:
spring: spring:
data:
mongodb:
auto-index-creation: true
host: localhost
port: 27017
database: hideout
jmx: jmx:
enabled: false enabled: false
jackson: jackson:
@ -31,12 +37,6 @@ spring:
url: "jdbc:postgresql:hideout" url: "jdbc:postgresql:hideout"
username: "postgres" username: "postgres"
password: "password" password: "password"
data:
mongodb:
auto-index-creation: true
host: localhost
port: 27017
database: hideout
servlet: servlet:
multipart: multipart:
max-file-size: 40MB max-file-size: 40MB

View File

@ -81,7 +81,7 @@ create table timelines
); );
create table if not exists user_details create table if not exists user_details
( (
id bigserial primary key, id bigint 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_followee_follow_request boolean not null, auto_accept_followee_follow_request boolean not null,
@ -286,4 +286,34 @@ create table if not exists actor_instance_relationships
PRIMARY KEY (actor_id, instance_id), PRIMARY KEY (actor_id, instance_id),
constraint fk_actor_instance_relationships_actor_id__id foreign key (actor_id) references actors (id) on delete cascade on update cascade, constraint fk_actor_instance_relationships_actor_id__id foreign key (actor_id) references actors (id) on delete cascade on update cascade,
constraint fk_actor_instance_relationships_instance_id__id foreign key (instance_id) references instance (id) on delete cascade on update cascade constraint fk_actor_instance_relationships_instance_id__id foreign key (instance_id) references instance (id) on delete cascade on update cascade
); );
create table if not exists timeline_relationships
(
id bigint primary key,
timeline_id bigint not null,
actor_id bigint not null,
visible varchar(100) not null,
constraint fk_timeline_relationships_timeline_id__id foreign key (timeline_id) references timelines (id) on delete cascade on update cascade,
constraint fk_timeline_relationships_actor_id__id foreign key (actor_id) references actors (id) on delete cascade on update cascade
);
create table if not exists filters
(
id bigint primary key,
user_id bigint not null,
name varchar(255) not null,
context varchar(500) not null,
action varchar(255) not null,
constraint fk_filters_user_id__id foreign key (user_id) references user_details (id) on delete cascade on update cascade
);
create table if not exists filter_keywords
(
id bigint primary key,
filter_id bigint not null,
keyword varchar(1000) not null,
mode varchar(100) not null,
constraint fk_filter_keywords_filter_id__id foreign key (filter_id) references filters (id) on delete cascade on update cascade
)