diff --git a/backend/src/main/java/org/gdglille/devfest/backend/events/EventRepository.kt b/backend/src/main/java/org/gdglille/devfest/backend/events/EventRepository.kt index 411990ae2..33df47e3a 100644 --- a/backend/src/main/java/org/gdglille/devfest/backend/events/EventRepository.kt +++ b/backend/src/main/java/org/gdglille/devfest/backend/events/EventRepository.kt @@ -163,7 +163,10 @@ class EventRepository( openPlanner.event.formats .map { async { formatDao.createOrUpdate(eventId, it.convertToDb()) } } .awaitAll() + val allSpeakers = openPlanner.sessions + .map { it.speakerIds }.flatten() openPlanner.speakers + .filter { allSpeakers.contains(it.id) } .map { async { speakerDao.createOrUpdate(eventId, it.convertToDb()) } } .awaitAll() openPlanner.sessions @@ -176,7 +179,7 @@ class EventRepository( it.value.forEachIndexed { index, sessionOP -> scheduleItemDao.createOrUpdate( eventId, - sessionOP.convertToScheduleDb(index) + sessionOP.convertToScheduleDb(index, openPlanner.event.tracks) ) } } diff --git a/backend/src/main/java/org/gdglille/devfest/backend/events/EventRouting.kt b/backend/src/main/java/org/gdglille/devfest/backend/events/EventRouting.kt index 26fe26f4d..0b9f108b3 100644 --- a/backend/src/main/java/org/gdglille/devfest/backend/events/EventRouting.kt +++ b/backend/src/main/java/org/gdglille/devfest/backend/events/EventRouting.kt @@ -157,7 +157,7 @@ fun Route.registerEventRoutes( } post("/events/{eventId}/openplanner") { val eventId = call.parameters["eventId"]!! - val apiKey = call.parameters["api_key"] ?: throw NotAuthorized + val apiKey = call.request.queryParameters["api_key"] ?: throw NotAuthorized call.respond(HttpStatusCode.Created, repository.openPlanner(eventId, apiKey)) } } diff --git a/backend/src/main/java/org/gdglille/devfest/backend/third/parties/openplanner/OpenPlannerMappers.kt b/backend/src/main/java/org/gdglille/devfest/backend/third/parties/openplanner/OpenPlannerMappers.kt index 6570a4fed..4dc33008f 100644 --- a/backend/src/main/java/org/gdglille/devfest/backend/third/parties/openplanner/OpenPlannerMappers.kt +++ b/backend/src/main/java/org/gdglille/devfest/backend/third/parties/openplanner/OpenPlannerMappers.kt @@ -54,12 +54,13 @@ fun SessionOP.convertToTalkDb() = TalkDb( linkReplay = null ) -fun SessionOP.convertToScheduleDb(order: Int) = ScheduleDb( +fun SessionOP.convertToScheduleDb(order: Int, tracks: List) = ScheduleDb( order = order, startTime = dateStart?.split("+")?.first() ?: error("Can't schedule a talk without a start time"), endTime = dateEnd?.split("+")?.first() ?: error("Can't schedule a talk without a end time"), - room = trackId ?: error("Can't schedule a talk without a room"), + room = trackId?.let { tracks.find { it.id == trackId }?.name } + ?: error("Can't schedule a talk without a room"), talkId = id )