-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): check if user can acceed to live masterclass
- Loading branch information
1 parent
965c450
commit 76c18e0
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/fr/sweetiez/api/core/events/use_case/streaming/AttendMasterClassRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package fr.sweetiez.api.core.events.use_case.streaming; | ||
|
||
import java.util.UUID; | ||
|
||
public record AttendMasterClassRequest(UUID eventID, String participantID) {} |
31 changes: 31 additions & 0 deletions
31
src/main/java/fr/sweetiez/api/core/events/use_case/streaming/AttendMasterclass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package fr.sweetiez.api.core.events.use_case.streaming; | ||
|
||
import fr.sweetiez.api.core.events.events.streaming_event.StreamingEvents; | ||
|
||
public class AttendMasterclass { | ||
|
||
private final StreamingEvents streamingEvents; | ||
|
||
public AttendMasterclass(StreamingEvents streamingEvents) { | ||
this.streamingEvents = streamingEvents; | ||
} | ||
|
||
public boolean attendMasterclass(AttendMasterClassRequest request) { | ||
var canAttend = false; | ||
var optionalEvent = streamingEvents.findById(request.eventID()); | ||
|
||
if (optionalEvent.isPresent()) { | ||
var subscribersID = optionalEvent.get() | ||
.subscribers() | ||
.stream() | ||
.map(customer -> customer.id().value()) | ||
.toList(); | ||
|
||
if (subscribersID.contains(request.participantID())) { | ||
canAttend = true; | ||
} | ||
} | ||
|
||
return canAttend; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters