feat(shared): add KMP me.php client and delegate Android fetchMe
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user