diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/UserRegisterHomeTimelineApplicationService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/UserRegisterHomeTimelineApplicationService.kt index 5394e998..6119370b 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/UserRegisterHomeTimelineApplicationService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/application/domainevent/subscribers/UserRegisterHomeTimelineApplicationService.kt @@ -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.domain.model.support.principal.Principal 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.UserDetailRepository import dev.usbharu.hideout.core.domain.shared.id.IdGenerateService @@ -15,6 +19,7 @@ class UserRegisterHomeTimelineApplicationService( private val userDetailRepository: UserDetailRepository, private val timelineRepository: TimelineRepository, private val idGenerateService: IdGenerateService, transaction: Transaction, + private val timelineRelationshipRepository: TimelineRelationshipRepository ) : AbstractApplicationService(transaction, logger) { override suspend fun internalExecute(command: RegisterHomeTimeline, principal: Principal) { @@ -31,6 +36,15 @@ class UserRegisterHomeTimelineApplicationService( timelineRepository.save(timeline) userDetail.homeTimelineId = timeline.id + val timelineRelationship = TimelineRelationship( + TimelineRelationshipId(idGenerateService.generateId()), + timeline.id, + userDetail.actorId, + Visible.DIRECT + ) + + timelineRelationshipRepository.save(timelineRelationship) + userDetailRepository.save(userDetail) } diff --git a/hideout-core/src/main/resources/application.yml b/hideout-core/src/main/resources/application.yml index c4bcecdd..371565d4 100644 --- a/hideout-core/src/main/resources/application.yml +++ b/hideout-core/src/main/resources/application.yml @@ -20,6 +20,12 @@ hideout: spring: + data: + mongodb: + auto-index-creation: true + host: localhost + port: 27017 + database: hideout jmx: enabled: false jackson: @@ -31,12 +37,6 @@ spring: url: "jdbc:postgresql:hideout" username: "postgres" password: "password" - data: - mongodb: - auto-index-creation: true - host: localhost - port: 27017 - database: hideout servlet: multipart: max-file-size: 40MB diff --git a/hideout-core/src/main/resources/db/migration/V1__Init_DB.sql b/hideout-core/src/main/resources/db/migration/V1__Init_DB.sql index e7330e1b..dd9dfa5c 100644 --- a/hideout-core/src/main/resources/db/migration/V1__Init_DB.sql +++ b/hideout-core/src/main/resources/db/migration/V1__Init_DB.sql @@ -81,7 +81,7 @@ create table timelines ); create table if not exists user_details ( - id bigserial primary key, + id bigint primary key, actor_id bigint not null unique, password varchar(255) 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), 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 -); \ No newline at end of file +); + +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 +) \ No newline at end of file