diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/StateCode.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/StateCode.kt index 51766c1cb..9777d5144 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/StateCode.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/StateCode.kt @@ -1,9 +1,10 @@ package net.mamoe.mirai.api.http.data import kotlinx.serialization.Serializable +import net.mamoe.mirai.api.http.data.common.DTO @Serializable -open class StateCode(val code: Int, var msg: String) { +open class StateCode(val code: Int, var msg: String) : DTO { object Success : StateCode(0, "success") // 成功 object NoBot : StateCode(2, "指定Bot不存在") object IllegalSession : StateCode(3, "Session失效或不存在") diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/MessageRouteModule.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/MessageRouteModule.kt index 8c0c69472..8e3fa1647 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/MessageRouteModule.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/MessageRouteModule.kt @@ -11,9 +11,11 @@ package net.mamoe.mirai.api.http.route import io.ktor.application.Application import io.ktor.application.call +import io.ktor.http.HttpStatusCode import io.ktor.http.content.readAllParts import io.ktor.http.content.streamProvider import io.ktor.request.receiveMultipart +import io.ktor.response.respond import io.ktor.response.respondText import io.ktor.routing.post import io.ktor.routing.routing @@ -45,14 +47,12 @@ fun Application.messageModule() { it.session.bot.getFriend(it.target).apply { sendMessage(it.messageChain.toMessageChain(this)) // this aka QQ } - call.respondStateCode(StateCode.Success) } miraiVerify("/sendGroupMessage") { it.session.bot.getGroup(it.target).apply { sendMessage(it.messageChain.toMessageChain(this)) // this aka Group } - call.respondStateCode(StateCode.Success) } miraiVerify("/quoteMessage") { @@ -100,6 +100,11 @@ fun Application.messageModule() { } ?: throw IllegalAccessException("图片上传错误") } ?: throw IllegalAccessException("未知错误") } + + miraiVerify("recall") { + // TODO + call.respond(HttpStatusCode.NotFound, "未完成") + } } } @@ -121,6 +126,13 @@ private data class SendImageDTO( @Serializable private class SendRetDTO( - @Transient val stateCode: StateCode = StateCode.Success, - val messageId: Long + val messageId: Long, + @Transient val stateCode: StateCode = Success ) : StateCode(stateCode.code, stateCode.msg) + +@Serializable +private data class RecallDTO( + override val sessionKey: String, + val target: Long, + val sender: Long +) : VerifyDTO()