Skip to content

Commit

Permalink
Various fixes for conference linkage to tickets. (#98)
Browse files Browse the repository at this point in the history
* Fix #97 and other edit problems on ticket.

* Remove conference references if conference ends.
#89

* Conference link respects "no change" with extra button and click on background.

* button to link conference is always visible.

* User cannot invite himself.

* Upgrade Node + npm

* Link invisible conferences #88
  • Loading branch information
snicki13 authored Nov 2, 2021
1 parent 1914eee commit 9b05398
Show file tree
Hide file tree
Showing 17 changed files with 17,204 additions and 113 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY build.gradle.kts /code
WORKDIR /code
RUN gradle clean build -i -x bootJar

FROM node:14.17.3-alpine AS build-node
FROM node:16.13.0-alpine AS build-node
COPY ./web-gui /web-gui
WORKDIR web-gui
RUN npm ci
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/de/thm/mni/ii/classroom/event/TicketEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ data class TicketEvent(

enum class TicketAction {
CREATE,
UPDATE,
CLOSE
ASSIGN,
CLOSE,
EDIT
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,33 @@ class DigitalClassroom(
}.map { Pair(it, this) }
}

fun updateTicket(receivedTicket: Ticket): Mono<Ticket> {
fun assignTicket(receivedTicket: Ticket): Mono<Ticket> {
return Mono.justOrEmpty(tickets.find { it == receivedTicket })
.switchIfEmpty(Mono.error(TicketNotFoundException(receivedTicket)))
.map { ticket ->
ticket.assignee = receivedTicket.assignee
ticket.description = receivedTicket.description
ticket
}
}

fun editTicket(receivedTicket: Ticket): Mono<Ticket> {
return Mono.justOrEmpty(tickets.find { it == receivedTicket })
.switchIfEmpty(Mono.error(TicketNotFoundException(receivedTicket)))
.map { ticket ->
ticket.conferenceId = receivedTicket.conferenceId
ticket.description = receivedTicket.description
ticket
}
}

fun removeConferenceReferencesFromTickets(conference: Conference): Flux<Ticket> {
return tickets.toFlux()
.filter { it.conferenceId == conference.conferenceId }
.map { ticket ->
ticket.conferenceId = null
ticket
}.flatMap { ticket ->
this.editTicket(ticket)
}
}

Expand Down Expand Up @@ -161,10 +180,7 @@ class DigitalClassroom(

fun sendToAll(event: ClassroomEvent): Mono<Void> {
return getSockets()
.filter { (user, requester) ->
if (requester != null) {
logger.trace("sending to ${user.fullName}")
}
.filter { (_, requester) ->
requester != null
}.flatMap { (_, requester) ->
fireAndForget(event, requester!!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class ClassroomEventReceiverService(
private fun ticketEventReceived(userCredentials: UserCredentials, ticketEvent: TicketEvent) {
when (ticketEvent.ticketAction) {
TicketAction.CREATE -> userService.createTicket(userCredentials, ticketEvent.ticket)
TicketAction.UPDATE -> userService.updateTicket(userCredentials, ticketEvent.ticket)
TicketAction.ASSIGN -> userService.assignTicket(userCredentials, ticketEvent.ticket)
TicketAction.EDIT -> userService.editTicket(userCredentials, ticketEvent.ticket)
TicketAction.CLOSE -> userService.closeTicket(userCredentials, ticketEvent.ticket)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ClassroomUserService(
}.subscribe()
}

fun updateTicket(userCredentials: UserCredentials, receivedTicket: Ticket) {
fun assignTicket(userCredentials: UserCredentials, receivedTicket: Ticket) {
if (!userCredentials.isPrivileged()) {
logger.warn(
"User ${userCredentials.fullName} is not authorized " +
Expand All @@ -105,11 +105,30 @@ class ClassroomUserService(
classroomInstanceService
.getClassroomInstance(userCredentials.classroomId)
.zipWhen { classroom ->
classroom.updateTicket(receivedTicket)
classroom.assignTicket(receivedTicket)
}.delayUntil { (classroom, ticket) ->
classroom.sendToAll(TicketEvent(ticket, TicketAction.UPDATE))
classroom.sendToAll(TicketEvent(ticket, TicketAction.ASSIGN))
}.doOnSuccess { (classroom, ticket) ->
logger.info("Ticket ${classroom.classroomName} / ${ticket.ticketId} assigned to ${ticket.assignee!!.fullName}!")
logger.debug("Ticket ${classroom.classroomName} / ${ticket.ticketId} assigned to ${ticket.assignee!!.fullName}!")
}.subscribe()
}

fun editTicket(userCredentials: UserCredentials, ticket: Ticket) {
if (userCredentials != ticket.creator && !userCredentials.isPrivileged()) {
logger.warn(
"User ${userCredentials.fullName} is not authorized " +
"to change ticket #${ticket.ticketId}!"
)
return
}
classroomInstanceService
.getClassroomInstance(userCredentials.classroomId)
.zipWhen { classroom ->
classroom.editTicket(ticket)
}.delayUntil { (classroom, ticket) ->
classroom.sendToAll(TicketEvent(ticket, TicketAction.ASSIGN))
}.doOnSuccess { (classroom, ticket) ->
logger.info("Ticket ${classroom.classroomName} / ${ticket.ticketId} edited with: Desc.: ${ticket.description}, Conf: ${ticket.conferenceId}!")
}.subscribe()
}

Expand All @@ -124,7 +143,7 @@ class ClassroomUserService(
}.delayUntil { classroom ->
classroom.sendToAll(TicketEvent(ticket, TicketAction.CLOSE))
}.flatMap { classroom ->
logger.info("Ticket ${classroom.classroomName} / ${ticket.ticketId} assigned to ${ticket.assignee?.fullName ?: "N/A"}!")
logger.info("Ticket ${classroom.classroomName} / ${ticket.ticketId} deleted!")
closeConferenceOfClosedTicket(ticket, classroom)
}.subscribe()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package de.thm.mni.ii.classroom.services

import de.thm.mni.ii.classroom.event.ConferenceAction
import de.thm.mni.ii.classroom.event.ConferenceEvent
import de.thm.mni.ii.classroom.event.InvitationEvent
import de.thm.mni.ii.classroom.event.*
import de.thm.mni.ii.classroom.exception.classroom.InvitationException
import de.thm.mni.ii.classroom.model.classroom.Conference
import de.thm.mni.ii.classroom.model.classroom.ConferenceInfo
Expand Down Expand Up @@ -79,12 +77,22 @@ class ConferenceService(
this.upstreamBBBService.endConference(conference)
}.delayUntil { (classroom, conference) ->
classroom.conferences.deleteConference(conference)
}.delayUntil { (classroom, conference) ->
this.removeConferenceReferences(classroom, conference)
}.flatMap { (classroom, conference) ->
val conferenceEvent = ConferenceEvent(conference.toConferenceInfo(), ConferenceAction.CLOSE)
classroom.sendToAll(conferenceEvent)
}
}

private fun removeConferenceReferences(classroom: DigitalClassroom, conference: Conference): Flux<Void> {
return classroom.removeConferenceReferencesFromTickets(conference)
.flatMap { ticket ->
val ticketEvent = TicketEvent(ticket, TicketAction.EDIT)
classroom.sendToAll(ticketEvent)
}
}

fun changeVisibility(userCredentials: UserCredentials, conferenceInfo: ConferenceInfo) {
classroomInstanceService.getClassroomInstance(userCredentials.classroomId)
.map {
Expand Down
4 changes: 2 additions & 2 deletions web-gui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repositories {
}

node {
version = '14.17.3'
npmVersion = '6.14.13'
version = '16.13.0'
npmVersion = '8.1.2'
download = true
}

Expand Down
Loading

0 comments on commit 9b05398

Please sign in to comment.