Skip to content

Commit

Permalink
#333 add valid check in from/to to offline payload
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Sep 21, 2017
1 parent 1d1c513 commit a07a72a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/alfio/manager/CheckInManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ public Predicate<Event> isOfflineCheckInAndLabelPrintingEnabled() {
}

public Map<String,String> getEncryptedAttendeesInformation(Event ev, Set<String> additionalFields, List<Integer> ids) {

Map<Integer, TicketCategory> categories = ticketCategoryRepository.findByEventIdAsMap(ev.getId());

return Optional.ofNullable(ev).filter(isOfflineCheckInEnabled()).map(event -> {
String eventKey = event.getPrivateKey();

Expand All @@ -316,6 +319,16 @@ public Map<String,String> getEncryptedAttendeesInformation(Event ev, Set<String>
Map<String, String> map = ticketFieldRepository.findValueForTicketId(ticket.getId(), additionalFields).stream().collect(Collectors.toMap(TicketFieldValue::getName, TicketFieldValue::getValue));
info.put("additionalInfoJson", Json.toJson(map));
}

//
TicketCategory tc = categories.get(ticket.getCategoryId());
if(tc.getValidCheckInTo() != null) {
info.put("validCheckInFrom", Long.toString(tc.getValidCheckInFrom(event.getZoneId()).toEpochSecond()));
}
if(tc.getValidCheckInFrom() != null) {
info.put("validCheckInTo", Long.toString(tc.getValidCheckInTo(event.getZoneId()).toEpochSecond()));
}
//
String key = ticket.ticketCode(eventKey);
return encrypt(key, Json.toJson(info));
};
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/alfio/repository/TicketCategoryRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ AffectedRowCountAndKey<Integer> insert(@Bind("inception") ZonedDateTime inceptio

@Query("select * from ticket_category where event_id = :eventId")
List<TicketCategory> findByEventId(@Bind("eventId") int eventId);

default Map<Integer, TicketCategory> findByEventIdAsMap(int eventId) {
return findByEventId(eventId).stream().collect(Collectors.toMap(TicketCategory::getId, Function.identity()));
}

@Query("select count(*) from ticket_category where event_id = :eventId and access_restricted = true")
Integer countAccessRestrictedRepositoryByEventId(@Bind("eventId") int eventId);
Expand Down

0 comments on commit a07a72a

Please sign in to comment.