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( postBuilder.of(
id = postRepository.generateId(), id = postRepository.generateId(),
actorId = person.second.id, actorId = person.second.id,
text = note.content, content = note.content,
createdAt = Instant.parse(note.published).toEpochMilli(), createdAt = Instant.parse(note.published).toEpochMilli(),
visibility = visibility, visibility = visibility,
url = note.id, url = note.id,

View File

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

View File

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

View File

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

View File

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