feat: Note中のHTMLをPostBuilderにいれる準備

This commit is contained in:
usbharu 2024-01-18 17:03:53 +09:00
parent a4865be4a7
commit 20012782b7
5 changed files with 12 additions and 8 deletions

View File

@ -128,7 +128,7 @@ class APNoteServiceImpl(
postBuilder.of(
id = postRepository.generateId(),
actorId = person.second.id,
text = note.content,
content = note.content,
createdAt = Instant.parse(note.published).toEpochMilli(),
visibility = visibility,
url = note.id,

View File

@ -8,6 +8,7 @@ data class Post private constructor(
val id: Long,
val actorId: Long,
val overview: String? = null,
val content: String,
val text: String,
val createdAt: Long,
val visibility: Visibility,
@ -28,7 +29,7 @@ data class Post private constructor(
id: Long,
actorId: Long,
overview: String? = null,
text: String,
content: String,
createdAt: Long,
visibility: Visibility,
url: String,
@ -49,10 +50,10 @@ data class Post private constructor(
overview
}
val limitedText = if (text.length >= characterLimit.post.text) {
text.substring(0, characterLimit.post.text)
val limitedText = if (content.length >= characterLimit.post.text) {
content.substring(0, characterLimit.post.text)
} else {
text
content
}
require(url.isNotBlank()) { "url must contain non-blank characters" }
@ -67,6 +68,7 @@ data class Post private constructor(
id = id,
actorId = actorId,
overview = limitedOverview,
content = content,
text = limitedText,
createdAt = createdAt,
visibility = visibility,
@ -94,6 +96,7 @@ data class Post private constructor(
id = id,
actorId = 0,
overview = null,
content = "",
text = "",
createdAt = Instant.EPOCH.toEpochMilli(),
visibility = visibility,
@ -113,6 +116,7 @@ data class Post private constructor(
id = this.id,
actorId = 0,
overview = null,
content = "",
text = "",
createdAt = Instant.EPOCH.toEpochMilli(),
visibility = visibility,

View File

@ -25,7 +25,7 @@ class PostResultRowMapper(private val postBuilder: Post.PostBuilder) : ResultRow
id = resultRow[Posts.id],
actorId = resultRow[Posts.actorId],
overview = resultRow[Posts.overview],
text = resultRow[Posts.text],
content = resultRow[Posts.text],
createdAt = resultRow[Posts.createdAt],
visibility = Visibility.values().first { visibility -> visibility.ordinal == resultRow[Posts.visibility] },
url = resultRow[Posts.url],

View File

@ -97,7 +97,7 @@ class PostServiceImpl(
id = id,
actorId = post.userId,
overview = post.overview,
text = post.text,
content = post.text,
createdAt = Instant.now().toEpochMilli(),
visibility = post.visibility,
url = "${user.url}/posts/$id",

View File

@ -26,7 +26,7 @@ object PostBuilder {
id = id,
actorId = userId,
overview = overview,
text = text,
content = text,
createdAt = createdAt,
visibility = visibility,
url = url,