feat(shared): add KMP me.php client and delegate Android fetchMe

This commit is contained in:
2025-09-06 19:16:20 +02:00
parent 477b1cb022
commit 799e562f31
3 changed files with 71 additions and 3 deletions

View File

@@ -473,10 +473,28 @@ suspend fun fetchNoteDetail(id: Long, lat: Double, lon: Double): NoteDetailDTO?
/** Anropa me.php – null vid nätverksfel/ej 200 */
/** Anropa me.php via delad KMP-klient – null vid nätverksfel/ej 200 */
suspend fun fetchMe(): MeResp? {
val resp = try { Api.svc.me() } catch (_: Throwable) { return null }
if (!resp.isSuccessful) return null
return resp.body()
val sh = try {
KlottrApiShared.me(
baseUrl = ApiConfig.SERVER_API_BASE_URL,
apiKey = ApiConfig.SERVER_API_KEY,
bearerToken = app.klottr.util.Auth.idToken
)
} catch (_: Throwable) {
return null
} ?: return null
return MeResp(
ok = sh.ok,
id = sh.id,
email = sh.email,
username = sh.username,
firstLogin = sh.firstLogin,
lastLogin = sh.lastLogin,
isSuspended = sh.isSuspended
)
}
/** Anropa username_check.php – null vid fel; annars svar med ok/reason */