[+] Data support APIs (#151)

This commit is contained in:
Menci
2025-07-04 12:01:32 +08:00
committed by GitHub
parent 068b6179e5
commit d79a4e5499
9 changed files with 273 additions and 4 deletions

View File

@@ -14,6 +14,9 @@ import jakarta.servlet.http.HttpServletRequest
import org.springframework.web.bind.annotation.*
import java.time.format.DateTimeFormatter
import kotlin.reflect.full.declaredMemberProperties
import icu.samnyan.aqua.net.Fedy
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Lazy
/**
* @author samnyan (privateamusement@protonmail.com)
@@ -37,6 +40,8 @@ class Maimai2ServletController(
val net: Maimai2,
): MeowApi(serialize = { _, resp -> if (resp is String) resp else resp.toJson() }) {
@Autowired(required = false) @Lazy var fedy: Fedy? = null
companion object {
private val log = logger()
private val empty = listOf<Any>()
@@ -89,6 +94,9 @@ class Maimai2ServletController(
val ctx = RequestContext(req, data.mut)
serialize(api, handlers[api]!!(ctx) ?: noop).also {
log.info("$token : $api > ${it.truncate(500)}")
if (api == "UpsertUserAllApi") {
fedy?.onUpserted("mai2", data["userId"])
}
}
}
} catch (e: Exception) {