From 4dfb01505746136250611be847c192eb4bd15d92 Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Sun, 19 Jan 2020 01:17:33 +0100 Subject: [PATCH] [Firebase/Librus] Implement basic push integration. --- .../data/firebase/SzkolnyLibrusFirebase.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyLibrusFirebase.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyLibrusFirebase.kt index 34c0f220..5bb6d1cf 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyLibrusFirebase.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/firebase/SzkolnyLibrusFirebase.kt @@ -5,7 +5,10 @@ package pl.szczodrzynski.edziennik.data.firebase import pl.szczodrzynski.edziennik.App +import pl.szczodrzynski.edziennik.data.api.task.EdziennikTask +import pl.szczodrzynski.edziennik.data.api.task.IApiTask import pl.szczodrzynski.edziennik.data.db.entity.Profile +import pl.szczodrzynski.edziennik.getString class SzkolnyLibrusFirebase(val app: App, val profiles: List, val message: FirebaseService.Message) { /*{ @@ -19,7 +22,15 @@ class SzkolnyLibrusFirebase(val app: App, val profiles: List, val messa "gcm.notification.icon": "notification_event.png", "objectType": "Calendars/TeacherFreeDays", }*/ - init { + init { run { + val apiLogin = message.data.getString("userId") ?: return@run - } + val tasks = profiles.filter { + it.getStudentData("accountLogin", "") == apiLogin + }.map { + EdziennikTask.syncProfile(it.id) + } + + IApiTask.enqueueAll(app, tasks) + }} }