Skip to content

Commit 430fac6

Browse files
YurnYurn
Yurn
authored and
Yurn
committed
同步 satori 更新
1 parent bd1f9ea commit 430fac6

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

adapter/src/commonMain/kotlin/cn/yurn/yutori/module/satori/adapter/ActionService.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class SatoriActionService(
5757
resource: String,
5858
method: String,
5959
platform: String?,
60-
selfId: String?,
60+
userId: String?,
6161
content: Map<String, Any?>
6262
): Any = HttpClient {
6363
install(ContentNegotiation) {
@@ -80,8 +80,8 @@ class SatoriActionService(
8080
"Bearer ${properties.token}"
8181
)
8282
}
83-
platform?.let { append("X-Platform", platform) }
84-
selfId?.let { append("X-Self-ID", selfId) }
83+
platform?.let { append("Satori-Platform", platform) }
84+
userId?.let { append("Satori-User-ID", userId) }
8585
}
8686
setBody(content.entries.filter { it.value != null }
8787
.joinToString(",", "{", "}") { (key, value) ->
@@ -198,7 +198,7 @@ class SatoriActionService(
198198
resource: String,
199199
method: String,
200200
platform: String,
201-
selfId: String,
201+
userId: String,
202202
content: List<FormData>
203203
): Map<String, String> =
204204
HttpClient {
@@ -219,8 +219,8 @@ class SatoriActionService(
219219
"Bearer ${properties.token}"
220220
)
221221
}
222-
append("X-Platform", platform)
223-
append("X-Self-ID", selfId)
222+
append("Satori-Platform", platform)
223+
append("Satori-User-ID", userId)
224224
}
225225
}.buildString()
226226
val formData = formData {

adapter/src/commonMain/kotlin/cn/yurn/yutori/module/satori/adapter/EventService.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class WebSocketEventService(
9595
for (login in signal.body.logins) {
9696
val actions = RootActions(
9797
platform = login.platform!!,
98-
selfId = login.selfId!!,
98+
userId = login.user!!.id,
9999
service = service,
100100
yutori = yutori
101101
)
@@ -165,11 +165,11 @@ class WebSocketEventService(
165165
Logger.d(name) { "事件详细信息: $event" }
166166
sequence = event.id
167167
val actions = actionsList.find {
168-
actions -> actions.platform == event.platform && actions.selfId == event.selfId
168+
actions -> actions.platform == event.platform && actions.userId == event.selfId
169169
} ?: run {
170170
val actions = RootActions(
171171
platform = event.platform,
172-
selfId = event.selfId,
172+
userId = event.selfId,
173173
service = service,
174174
yutori = yutori
175175
)

core/src/commonMain/kotlin/cn/yurn/yutori/module/satori/Entity.kt

+8-9
Original file line numberDiff line numberDiff line change
@@ -255,30 +255,29 @@ data class SerializableGuild(
255255

256256
@Serializable
257257
data class SerializableLogin(
258-
val user: SerializableUser? = null,
259-
@SerialName("self_id")
260-
val selfId: String? = null,
258+
val adapter: String,
261259
val platform: String? = null,
262-
val status: Int,
260+
val user: SerializableUser? = null,
261+
val status: Int? = null,
263262
val features: List<String> = listOf(),
264263
@SerialName("proxy_urls")
265264
val proxyUrls: List<String> = listOf(),
266265
) : Convertable<Login> {
267266
override fun toUniverse(yutori: Yutori) = Login(
268-
user = user?.toUniverse(yutori),
269-
selfId = selfId,
267+
adapter = adapter,
270268
platform = platform,
269+
user = user?.toUniverse(yutori),
271270
status = status,
272271
features = features,
273272
proxyUrls = proxyUrls
274273
)
275274

276275
companion object {
277276
fun fromUniverse(universe: Login) = SerializableLogin(
278-
user = universe.user?.let { SerializableUser.fromUniverse(it) },
279-
selfId = universe.selfId,
277+
adapter = universe.adapter,
280278
platform = universe.platform,
281-
status = universe.status.toInt(),
279+
user = universe.user?.let { SerializableUser.fromUniverse(it) },
280+
status = universe.status?.toInt(),
282281
features = universe.features,
283282
proxyUrls = universe.proxyUrls
284283
)

gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ agp = "8.6.1"
44
atomicfu = "0.25.0"
55
ktor = "3.0.0-rc-1"
66
ksoup = "0.1.9"
7-
yutori = "3fcccaa1166fb9a63874bcff382170e98cc180d8"
7+
yutori = "dae7ab90aa9b5e3b3ee88a5900635c3fd4b83e83"
88

99
[libraries]
1010
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }

server/src/commonMain/kotlin/cn/yurn/yutori/module/satori/server/ServerService.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ class SatoriServerService(
139139
post("${properties.path}/${properties.version}/{api}") {
140140
val address = call.request.local.remoteAddress
141141
val api = "/" + call.pathParameters["api"]!!
142-
val platform = call.request.headers["X-Platform"]
143-
val selfId = call.request.headers["X-Self-ID"]
142+
val platform = call.request.headers["Satori-Platform"]
143+
val userId = call.request.headers["Satori-User-ID"]
144144
val content = call.receiveText()
145-
Logger.i(name) { "Action($address): $api($platform, $selfId), $content" }
145+
Logger.i(name) { "Action($address): $api($platform, $userId), $content" }
146146
val token = call.request.headers["Authorization"]
147147
if (token == null) {
148148
call.respond(HttpStatusCode.Unauthorized)
@@ -159,8 +159,8 @@ class SatoriServerService(
159159
yutori.actionsList,
160160
Request(
161161
api, mutableMapOf(
162-
"platform" to platform,
163-
"selfId" to selfId,
162+
"satoriPlatform" to platform,
163+
"satoriUserId" to userId,
164164
"channelId" to element.remove("channel_id")?.jsonPrimitive?.content,
165165
"guildId" to element.remove("guild_id")?.jsonPrimitive?.content,
166166
"next" to element.remove("next")?.jsonPrimitive?.content,

0 commit comments

Comments
 (0)