mirror of https://github.com/usbharu/Hideout.git
fix: Createを正常に処理できていなかったのを修正
This commit is contained in:
parent
b8613e2bf1
commit
f9e47c0a31
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.core.JsonParser
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext
|
import com.fasterxml.jackson.databind.DeserializationContext
|
||||||
import com.fasterxml.jackson.databind.JsonDeserializer
|
import com.fasterxml.jackson.databind.JsonDeserializer
|
||||||
import com.fasterxml.jackson.databind.JsonNode
|
import com.fasterxml.jackson.databind.JsonNode
|
||||||
import dev.usbharu.hideout.service.activitypub.ActivityType
|
import dev.usbharu.hideout.service.activitypub.ActivityVocabulary
|
||||||
|
|
||||||
class ObjectDeserializer : JsonDeserializer<Object>() {
|
class ObjectDeserializer : JsonDeserializer<Object>() {
|
||||||
override fun deserialize(p: JsonParser?, ctxt: DeserializationContext?): Object {
|
override fun deserialize(p: JsonParser?, ctxt: DeserializationContext?): Object {
|
||||||
|
@ -22,21 +22,25 @@ class ObjectDeserializer : JsonDeserializer<Object>() {
|
||||||
val type = treeNode["type"]
|
val type = treeNode["type"]
|
||||||
val activityType = if (type.isArray) {
|
val activityType = if (type.isArray) {
|
||||||
type.firstNotNullOf { jsonNode: JsonNode ->
|
type.firstNotNullOf { jsonNode: JsonNode ->
|
||||||
ActivityType.values().firstOrNull { it.name.equals(jsonNode.asText(), true) }
|
ActivityVocabulary.values().firstOrNull { it.name.equals(jsonNode.asText(), true) }
|
||||||
}
|
}
|
||||||
} else if (type.isValueNode) {
|
} else if (type.isValueNode) {
|
||||||
ActivityType.values().first { it.name.equals(type.asText(), true) }
|
ActivityVocabulary.values().first { it.name.equals(type.asText(), true) }
|
||||||
} else {
|
} else {
|
||||||
TODO()
|
TODO()
|
||||||
}
|
}
|
||||||
|
|
||||||
return when (activityType) {
|
return when (activityType) {
|
||||||
ActivityType.Follow -> {
|
ActivityVocabulary.Follow -> {
|
||||||
val readValue = p.codec.treeToValue(treeNode, Follow::class.java)
|
val readValue = p.codec.treeToValue(treeNode, Follow::class.java)
|
||||||
println(readValue)
|
println(readValue)
|
||||||
readValue
|
readValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActivityVocabulary.Note -> {
|
||||||
|
p.codec.treeToValue(treeNode, Note::class.java)
|
||||||
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
TODO()
|
TODO()
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,6 @@ class ActivityPubCreateServiceImpl(
|
||||||
|
|
||||||
val note = value as Note
|
val note = value as Note
|
||||||
activityPubNoteService.fetchNote(note)
|
activityPubNoteService.fetchNote(note)
|
||||||
return ActivityPubStringResponse(HttpStatusCode.Created, "Created")
|
return ActivityPubStringResponse(HttpStatusCode.OK, "Created")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,3 +43,60 @@ enum class ActivityType {
|
||||||
View,
|
View,
|
||||||
Other
|
Other
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class ActivityVocabulary {
|
||||||
|
Object,
|
||||||
|
Link,
|
||||||
|
Activity,
|
||||||
|
IntransitiveActivity,
|
||||||
|
Collection,
|
||||||
|
OrderedCollection,
|
||||||
|
CollectionPage,
|
||||||
|
OrderedCollectionPage,
|
||||||
|
Accept,
|
||||||
|
Add,
|
||||||
|
Announce,
|
||||||
|
Arrive,
|
||||||
|
Block,
|
||||||
|
Create,
|
||||||
|
Delete,
|
||||||
|
Dislike,
|
||||||
|
Flag,
|
||||||
|
Follow,
|
||||||
|
Ignore,
|
||||||
|
Invite,
|
||||||
|
Join,
|
||||||
|
Leave,
|
||||||
|
Like,
|
||||||
|
Listen,
|
||||||
|
Move,
|
||||||
|
Offer,
|
||||||
|
Question,
|
||||||
|
Reject,
|
||||||
|
Read,
|
||||||
|
Remove,
|
||||||
|
TentativeReject,
|
||||||
|
TentativeAccept,
|
||||||
|
Travel,
|
||||||
|
Undo,
|
||||||
|
Update,
|
||||||
|
View,
|
||||||
|
Application,
|
||||||
|
Group,
|
||||||
|
Organization,
|
||||||
|
Person,
|
||||||
|
Service,
|
||||||
|
Article,
|
||||||
|
Audio,
|
||||||
|
Document,
|
||||||
|
Event,
|
||||||
|
Image,
|
||||||
|
Note,
|
||||||
|
Page,
|
||||||
|
Place,
|
||||||
|
Profile,
|
||||||
|
Relationship,
|
||||||
|
Tombstone,
|
||||||
|
Video,
|
||||||
|
Mention,
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue