mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-31 13:48:20 +01:00
[API/Mobidziennik] Implement getting email for push registration.
This commit is contained in:
parent
10c57d2272
commit
8e5a10f6d8
@ -90,7 +90,7 @@ val mobidziennikLoginMethods = listOf(
|
|||||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED },
|
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED },
|
||||||
|
|
||||||
LoginMethod(LOGIN_TYPE_MOBIDZIENNIK, LOGIN_METHOD_MOBIDZIENNIK_API2, MobidziennikLoginApi2::class.java)
|
LoginMethod(LOGIN_TYPE_MOBIDZIENNIK, LOGIN_METHOD_MOBIDZIENNIK_API2, MobidziennikLoginApi2::class.java)
|
||||||
.withIsPossible { profile, _ -> profile?.hasStudentData("email") == true }
|
.withIsPossible { profile, _ -> profile?.getStudentData("email", null) != null }
|
||||||
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED }
|
.withRequiredLoginMethod { _, _ -> LOGIN_METHOD_NOT_NEEDED }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -56,7 +56,11 @@ object Regexes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val MOBIDZIENNIK_MESSAGE_RECIPIENTS_JSON by lazy {
|
val MOBIDZIENNIK_MESSAGE_RECIPIENTS_JSON by lazy {
|
||||||
"""odbiorcy: (\[.+?\]),${'$'}""".toRegex(RegexOption.MULTILINE)
|
"""odbiorcy: (\[.+?]),${'$'}""".toRegex(RegexOption.MULTILINE)
|
||||||
|
}
|
||||||
|
|
||||||
|
val MOBIDZIENNIK_ACCOUNT_EMAIL by lazy {
|
||||||
|
"""name="email" value="(.+?@.+?\..+?)"""".toRegex(DOT_MATCHES_ALL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,14 +22,14 @@ const val ENDPOINT_MOBIDZIENNIK_API2_MAIN = 3000
|
|||||||
val MobidziennikFeatures = listOf(
|
val MobidziennikFeatures = listOf(
|
||||||
// always synced
|
// always synced
|
||||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_ALWAYS_NEEDED, listOf(
|
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_ALWAYS_NEEDED, listOf(
|
||||||
ENDPOINT_MOBIDZIENNIK_API_MAIN to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
ENDPOINT_MOBIDZIENNIK_API_MAIN to LOGIN_METHOD_MOBIDZIENNIK_WEB,
|
||||||
|
ENDPOINT_MOBIDZIENNIK_WEB_ACCOUNT_EMAIL to LOGIN_METHOD_MOBIDZIENNIK_WEB
|
||||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB)), // TODO divide features into separate view IDs (all with API_MAIN)
|
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB)), // TODO divide features into separate view IDs (all with API_MAIN)
|
||||||
|
|
||||||
// push config
|
// push config
|
||||||
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_PUSH_CONFIG, listOf(
|
Feature(LOGIN_TYPE_MOBIDZIENNIK, FEATURE_PUSH_CONFIG, listOf(
|
||||||
ENDPOINT_MOBIDZIENNIK_WEB_ACCOUNT_EMAIL to LOGIN_METHOD_MOBIDZIENNIK_WEB,
|
|
||||||
ENDPOINT_MOBIDZIENNIK_API2_MAIN to LOGIN_METHOD_MOBIDZIENNIK_API2
|
ENDPOINT_MOBIDZIENNIK_API2_MAIN to LOGIN_METHOD_MOBIDZIENNIK_API2
|
||||||
), listOf(LOGIN_METHOD_MOBIDZIENNIK_WEB, LOGIN_METHOD_MOBIDZIENNIK_API2)).withShouldSync { data ->
|
), listOf(LOGIN_METHOD_MOBIDZIENNIK_API2)).withShouldSync { data ->
|
||||||
!data.app.config.sync.tokenMobidziennikList.contains(data.profileId)
|
!data.app.config.sync.tokenMobidziennikList.contains(data.profileId)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -8,10 +8,7 @@ import pl.szczodrzynski.edziennik.R
|
|||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.*
|
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.*
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.api.MobidziennikApi
|
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.api.MobidziennikApi
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.api2.MobidziennikApi2Main
|
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.api2.MobidziennikApi2Main
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.web.MobidziennikWebCalendar
|
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.web.*
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.web.MobidziennikWebGrades
|
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.web.MobidziennikWebMessagesAll
|
|
||||||
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.web.MobidziennikWebMessagesInbox
|
|
||||||
import pl.szczodrzynski.edziennik.utils.Utils
|
import pl.szczodrzynski.edziennik.utils.Utils
|
||||||
|
|
||||||
class MobidziennikData(val data: DataMobidziennik, val onSuccess: () -> Unit) {
|
class MobidziennikData(val data: DataMobidziennik, val onSuccess: () -> Unit) {
|
||||||
@ -64,6 +61,10 @@ class MobidziennikData(val data: DataMobidziennik, val onSuccess: () -> Unit) {
|
|||||||
ENDPOINT_MOBIDZIENNIK_WEB_GRADES -> {
|
ENDPOINT_MOBIDZIENNIK_WEB_GRADES -> {
|
||||||
data.startProgress(R.string.edziennik_progress_endpoint_grades)
|
data.startProgress(R.string.edziennik_progress_endpoint_grades)
|
||||||
MobidziennikWebGrades(data) { onSuccess() }
|
MobidziennikWebGrades(data) { onSuccess() }
|
||||||
|
}
|
||||||
|
ENDPOINT_MOBIDZIENNIK_WEB_ACCOUNT_EMAIL -> {
|
||||||
|
data.startProgress(R.string.edziennik_progress_endpoint_account_details)
|
||||||
|
MobidziennikWebAccountEmail(data) { onSuccess() }
|
||||||
}/*
|
}/*
|
||||||
ENDPOINT_MOBIDZIENNIK_WEB_NOTICES -> {
|
ENDPOINT_MOBIDZIENNIK_WEB_NOTICES -> {
|
||||||
data.startProgress(R.string.edziennik_progress_endpoint_behaviour)
|
data.startProgress(R.string.edziennik_progress_endpoint_behaviour)
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Kuba Szczodrzyński 2020-1-21.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.web
|
||||||
|
|
||||||
|
import pl.szczodrzynski.edziennik.DAY
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.Regexes
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.DataMobidziennik
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.ENDPOINT_MOBIDZIENNIK_WEB_ACCOUNT_EMAIL
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.mobidziennik.data.MobidziennikWeb
|
||||||
|
import pl.szczodrzynski.edziennik.get
|
||||||
|
|
||||||
|
class MobidziennikWebAccountEmail(override val data: DataMobidziennik,
|
||||||
|
val onSuccess: () -> Unit) : MobidziennikWeb(data) {
|
||||||
|
companion object {
|
||||||
|
private const val TAG = "MobidziennikWebAccountEmail"
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
webGet(TAG, "/dziennik/edytujprofil") { text ->
|
||||||
|
MobidziennikLuckyNumberExtractor(data, text)
|
||||||
|
|
||||||
|
val email = Regexes.MOBIDZIENNIK_ACCOUNT_EMAIL.find(text)?.let { it[1] }
|
||||||
|
data.loginEmail = email
|
||||||
|
|
||||||
|
data.setSyncNext(ENDPOINT_MOBIDZIENNIK_WEB_ACCOUNT_EMAIL, if (email == null) 3*DAY else 7*DAY)
|
||||||
|
onSuccess()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1166,4 +1166,5 @@
|
|||||||
<string name="notification_type_removed_shared_event">Usunięto wydarzenie</string>
|
<string name="notification_type_removed_shared_event">Usunięto wydarzenie</string>
|
||||||
<string name="notification_click_to_see_all">Kliknij, aby zobaczyć wszystkie powiadomienia</string>
|
<string name="notification_click_to_see_all">Kliknij, aby zobaczyć wszystkie powiadomienia</string>
|
||||||
<string name="notification_cant_check_update">Nie udało się sprawdzić aktualizacji</string>
|
<string name="notification_cant_check_update">Nie udało się sprawdzić aktualizacji</string>
|
||||||
|
<string name="edziennik_progress_endpoint_account_details">Pobieranie szczegółów konta...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user