feat: Createアクティビティにactorを追加

This commit is contained in:
usbharu 2023-04-29 17:49:29 +09:00
parent c644a66071
commit a4feef5f75
3 changed files with 23 additions and 6 deletions

View File

@ -4,7 +4,16 @@ open class Create : Object {
var `object`: Object? = null
protected constructor() : super()
constructor(type: List<String> = emptyList(), name: String, `object`: Object?) : super(add(type, "Create"), name) {
constructor(
type: List<String> = emptyList(),
name: String? = null,
`object`: Object?,
actor: String? = null
) : super(
add(type, "Create"),
name,
actor
) {
this.`object` = `object`
}

View File

@ -9,9 +9,10 @@ open class Object : JsonLd {
@JsonSerialize(using = TypeSerializer::class)
private var type: List<String> = emptyList()
var name: String? = null
var actor: String? = null
protected constructor()
constructor(type: List<String>, name: String) : super() {
constructor(type: List<String>, name: String? = null,actor:String? = null) : super() {
this.type = type
this.name = name
}
@ -25,22 +26,28 @@ open class Object : JsonLd {
}
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Object) return false
if (!super.equals(other)) return false
if (type != other.type) return false
return name == other.name
if (name != other.name) return false
return actor == other.actor
}
override fun hashCode(): Int {
var result = type.hashCode()
var result = super.hashCode()
result = 31 * result + type.hashCode()
result = 31 * result + (name?.hashCode() ?: 0)
result = 31 * result + (actor?.hashCode() ?: 0)
return result
}
override fun toString(): String {
return "Object(type=$type, name=$name) ${super.toString()}"
return "Object(type=$type, name=$name, actor=$actor) ${super.toString()}"
}

View File

@ -54,7 +54,8 @@ class ActivityPubNoteServiceImpl(
username = "$actor#pubkey",
jsonLd = Create(
name = "Create Note",
`object` = note
`object` = note,
actor = note.attributedTo
)
)
}