Skip to content

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Gorzala committed Dec 27, 2023
1 parent 3021b10 commit e323caa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import net.dancier.dancer.core.ScheduleMessagePort;
import net.dancier.dancer.eventlog.service.EventlogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
Expand All @@ -16,13 +15,7 @@
public class ApplicationEventListener {

public static final Logger log = LoggerFactory.getLogger(ApplicationEventListener.class);

public static final URI FRONTEND_SOURCE = URI.create("http://dancier.net");
private static final URI BACKEND_SOURCE = URI.create("http://dancer.dancier.net");

private final EventlogService eventlogService;

private final EventCreator eventCreator;
private static final URI SOURCE = URI.create("http://dancer.dancier.net");

private final ScheduleMessagePort scheduleMessagePort;

Expand All @@ -33,7 +26,7 @@ public void handle(ProfileUpdatedEvent profileUpdatedEvent) {
scheduleMessagePort.schedule(
profileUpdatedEvent,
profileUpdatedEvent.getDancer().getId().toString(),
BACKEND_SOURCE,
SOURCE,
"profile-updated");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.net.URI;
import java.sql.SQLException;
import java.time.Instant;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

import static net.dancier.dancer.core.events.ApplicationEventListener.FRONTEND_SOURCE;

@Service
@RequiredArgsConstructor
public class EventlogService {
Expand All @@ -30,7 +29,8 @@ public class EventlogService {
private final EventlogDAO eventlogDAO;

private final ScheduleMessagePort scheduleMessagePort;
private final static Set<String> DEFAULT_AUTHENTICATED = Set.of("ROLE_USER", "ROLE_ADMIN");

public static final URI FRONTEND_SOURCE = URI.create("http://dancier.net");
private final static Set<String> AT_LEAST_HUMAN = Set.of("ROLE_HUMAN", "ROLE_USER", "ROLE_ADMIN");
private final static Set<String> NO_SPECIAL_ROLE_NEEDED = Set.of("ROLE_ANONYMOUS");
private final static Set<EventlogConfig> allowedEvents = Set.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ public KafkaAdmin.NewTopics createTopics() {
NewTopic navigatedToPage = new NewTopic("navigated-to-page", 1, (short) 1);
NewTopic humanSessionCreated = new NewTopic("human-session-created", 1, (short) 1);
NewTopic contactMessageSent = new NewTopic("contact-message-sent", 1, (short) 1);

NewTopic emailSendingRequested = new NewTopic("email-sending-requested", 1, (short) 1);
return new KafkaAdmin.NewTopics(
profileUpdated,
appInstanceIdCreated,
navigatedToPage,
humanSessionCreated,
contactMessageSent);
contactMessageSent,
emailSendingRequested);
}

}

0 comments on commit e323caa

Please sign in to comment.