refactor: 一部のAPのJSONマッピング用のPOJOをNull-safeに

This commit is contained in:
usbharu 2023-11-28 10:44:54 +09:00
parent e2f355f4d3
commit 6c2d5dae94
2 changed files with 8 additions and 9 deletions

View File

@ -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<Document> = emptyList()
var content: String? = null
var published: String? = null
lateinit var content: String
lateinit var published: String
var to: List<String> = emptyList()
var cc: List<String> = emptyList()
var sensitive: Boolean = false
@ -19,9 +19,9 @@ open class Note : Object {
type: List<String> = emptyList(),
name: String,
id: String?,
attributedTo: String?,
content: String?,
published: String?,
attributedTo: String,
content: String,
published: String,
to: List<String> = emptyList(),
cc: List<String> = emptyList(),
sensitive: Boolean = false,

View File

@ -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,