Simplify code
This commit is contained in:
parent
4e2e73637a
commit
2d664c423d
|
@ -253,25 +253,15 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
||||||
* Try to create an event from the FCM data
|
* Try to create an event from the FCM data
|
||||||
*
|
*
|
||||||
* @param data the FCM data
|
* @param data the FCM data
|
||||||
* @return the event
|
* @return the event or null if required data are missing
|
||||||
*/
|
*/
|
||||||
private fun parseEvent(data: Map<String, String>?): Event? {
|
private fun parseEvent(data: Map<String, String>?): Event? {
|
||||||
// accept only event with room id.
|
return Event(
|
||||||
if (null == data || !data.containsKey("room_id") || !data.containsKey("event_id")) {
|
eventId = data?.get("event_id") ?: return null,
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return Event(eventId = data["event_id"],
|
|
||||||
senderId = data["sender"],
|
senderId = data["sender"],
|
||||||
roomId = data["room_id"],
|
roomId = data["room_id"] ?: return null,
|
||||||
type = data.getValue("type"),
|
type = data["type"] ?: return null,
|
||||||
// TODO content = data.getValue("content"),
|
originServerTs = System.currentTimeMillis()
|
||||||
originServerTs = System.currentTimeMillis())
|
)
|
||||||
} catch (e: Exception) {
|
|
||||||
Timber.e(e, "buildEvent fails ")
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue