From 6c2d5dae94a52306f2212e3b4258b4177c820981 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Tue, 28 Nov 2023 10:44:54 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=B8=80=E9=83=A8=E3=81=AEAP?= =?UTF-8?q?=E3=81=AEJSON=E3=83=9E=E3=83=83=E3=83=94=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E7=94=A8=E3=81=AEPOJO=E3=82=92Null-safe=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usbharu/hideout/activitypub/domain/model/Note.kt | 12 ++++++------ .../service/objects/note/APNoteService.kt | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Note.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Note.kt index ddca1d67..cc891c08 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Note.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Note.kt @@ -3,10 +3,10 @@ package dev.usbharu.hideout.activitypub.domain.model import dev.usbharu.hideout.activitypub.domain.model.objects.Object open class Note : Object { - var attributedTo: String? = null + lateinit var attributedTo: String var attachment: List = emptyList() - var content: String? = null - var published: String? = null + lateinit var content: String + lateinit var published: String var to: List = emptyList() var cc: List = emptyList() var sensitive: Boolean = false @@ -19,9 +19,9 @@ open class Note : Object { type: List = emptyList(), name: String, id: String?, - attributedTo: String?, - content: String?, - published: String?, + attributedTo: String, + content: String, + published: String, to: List = emptyList(), cc: List = emptyList(), sensitive: Boolean = false, diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt index f7300314..28bf7c01 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/service/objects/note/APNoteService.kt @@ -1,7 +1,6 @@ package dev.usbharu.hideout.activitypub.service.objects.note import dev.usbharu.hideout.activitypub.domain.exception.FailedToGetActivityPubResourceException -import dev.usbharu.hideout.activitypub.domain.exception.IllegalActivityPubObjectException import dev.usbharu.hideout.activitypub.domain.model.Note import dev.usbharu.hideout.activitypub.query.NoteQueryService import dev.usbharu.hideout.activitypub.service.common.APResourceResolveService @@ -99,7 +98,7 @@ class APNoteServiceImpl( private suspend fun saveNote(note: Note, targetActor: String?, url: String): Note { val person = apUserService.fetchPersonWithEntity( - note.attributedTo ?: throw IllegalActivityPubObjectException("note.attributedTo is null"), + note.attributedTo, targetActor ) @@ -142,7 +141,7 @@ class APNoteServiceImpl( postBuilder.of( id = postRepository.generateId(), userId = person.second.id, - text = note.content.orEmpty(), + text = note.content, createdAt = Instant.parse(note.published).toEpochMilli(), visibility = visibility, url = note.id ?: url,