From 2682165da838d9842ddacc27c11610d6954ab8d4 Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Thu, 28 Mar 2024 19:05:54 -0400 Subject: [PATCH] [+] Wacca: user/info/update --- .../icu/samnyan/aqua/sega/wacca/WaccaServer.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/icu/samnyan/aqua/sega/wacca/WaccaServer.kt b/src/main/java/icu/samnyan/aqua/sega/wacca/WaccaServer.kt index 9072edbc..f630f9e5 100644 --- a/src/main/java/icu/samnyan/aqua/sega/wacca/WaccaServer.kt +++ b/src/main/java/icu/samnyan/aqua/sega/wacca/WaccaServer.kt @@ -308,6 +308,23 @@ fun WaccaServer.init() { empty } + + "user/info/update" { _, (uid, opts, _, dates, favAdd, favRem) -> + val u = user(uid) ?: (404 - "User not found") + + // Update options + val o = rp.option.findByUser(u).associate { it.optId to it } + rp.option.saveAll((opts as List>).map { (k, v) -> o[k]?.apply { value = v } + ?: WcUserOption(k, v).apply { user = u } }) + + // Update favorite songs + rp.user.save(u.apply { favoriteSongs.apply { + addAll(favAdd as List) + removeAll(favRem as List) + } }) + + empty + } }