diff --git a/src/main/kotlin/dev/usbharu/hideout/controller/InboxController.kt b/src/main/kotlin/dev/usbharu/hideout/controller/InboxController.kt new file mode 100644 index 00000000..0cba64e3 --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/controller/InboxController.kt @@ -0,0 +1,21 @@ +package dev.usbharu.hideout.controller + +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestMethod +import org.springframework.web.bind.annotation.RestController + +@RestController +interface InboxController { + @RequestMapping( + "/inbox", + "/users/{username}/inbox", + produces = ["application/activity+json", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""], + method = [RequestMethod.GET, RequestMethod.POST] + ) + suspend fun inbox(@RequestBody string: String): ResponseEntity { + return ResponseEntity(HttpStatus.ACCEPTED) + } +} diff --git a/src/main/kotlin/dev/usbharu/hideout/controller/InboxControllerImpl.kt b/src/main/kotlin/dev/usbharu/hideout/controller/InboxControllerImpl.kt new file mode 100644 index 00000000..002dee31 --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/controller/InboxControllerImpl.kt @@ -0,0 +1,15 @@ +package dev.usbharu.hideout.controller + +import dev.usbharu.hideout.service.ap.APService +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.RestController + +@RestController +class InboxControllerImpl(private val apService: APService) : InboxController { + override suspend fun inbox(string: String): ResponseEntity { + val parseActivity = apService.parseActivity(string) + apService.processActivity(string, parseActivity) + return ResponseEntity(HttpStatus.ACCEPTED) + } +} diff --git a/src/main/kotlin/dev/usbharu/hideout/controller/OutboxController.kt b/src/main/kotlin/dev/usbharu/hideout/controller/OutboxController.kt new file mode 100644 index 00000000..ee003682 --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/controller/OutboxController.kt @@ -0,0 +1,16 @@ +package dev.usbharu.hideout.controller + +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestMethod +import org.springframework.web.bind.annotation.RestController + +@RestController +interface OutboxController { + @RequestMapping("/outbox", "/users/{username}/outbox", method = [RequestMethod.POST, RequestMethod.GET]) + fun outbox(@RequestBody string: String): ResponseEntity { + return ResponseEntity(HttpStatus.ACCEPTED) + } +} diff --git a/src/main/kotlin/dev/usbharu/hideout/controller/OutboxControllerImpl.kt b/src/main/kotlin/dev/usbharu/hideout/controller/OutboxControllerImpl.kt new file mode 100644 index 00000000..04dc227f --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/controller/OutboxControllerImpl.kt @@ -0,0 +1,13 @@ +package dev.usbharu.hideout.controller + +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RestController + +@RestController +class OutboxControllerImpl : OutboxController { + override fun outbox(@RequestBody string: String): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } +} diff --git a/src/main/kotlin/dev/usbharu/hideout/controller/UserAPController.kt b/src/main/kotlin/dev/usbharu/hideout/controller/UserAPController.kt new file mode 100644 index 00000000..5390fff2 --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/controller/UserAPController.kt @@ -0,0 +1,13 @@ +package dev.usbharu.hideout.controller + +import dev.usbharu.hideout.domain.model.ap.Person +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RestController + +@RestController +interface UserAPController { + @GetMapping("/users/{username}") + suspend fun userAp(@PathVariable("username") username: String): ResponseEntity +} diff --git a/src/main/kotlin/dev/usbharu/hideout/controller/UserAPControllerImpl.kt b/src/main/kotlin/dev/usbharu/hideout/controller/UserAPControllerImpl.kt new file mode 100644 index 00000000..90fb6155 --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/controller/UserAPControllerImpl.kt @@ -0,0 +1,15 @@ +package dev.usbharu.hideout.controller + +import dev.usbharu.hideout.domain.model.ap.Person +import dev.usbharu.hideout.service.ap.APUserService +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.RestController + +@RestController +class UserAPControllerImpl(private val apUserService: APUserService) : UserAPController { + override suspend fun userAp(username: String): ResponseEntity { + val person = apUserService.getPersonByName(username) + return ResponseEntity(person, HttpStatus.OK) + } +}