mirror of https://github.com/usbharu/Hideout.git
refactor: 一部のAPのJSONマッピング用のPOJOをNull-safeに
This commit is contained in:
parent
e2f355f4d3
commit
6c2d5dae94
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue