Files
elder-scrolls-legends/src/main/java/ch/gtache/elderscrollslegends/service/pubsub/PubSubAuthEndpoints.java
2025-04-30 18:18:21 +02:00

37 lines
1.3 KiB
Java

package ch.gtache.elderscrollslegends.service.pubsub;
import ch.gtache.elderscrollslegends.service.BaseEndpoints;
import ch.gtache.elderscrollslegends.service.ResultCode;
import ch.gtache.elderscrollslegends.service.account.AccountService;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import org.jboss.logging.Logger;
import java.util.Objects;
@Path("pubsubauth")
public class PubSubAuthEndpoints extends BaseEndpoints {
private static final Logger logger = Logger.getLogger(PubSubAuthEndpoints.class);
private final PubSubService pubSubService;
@Inject
PubSubAuthEndpoints(final AccountService accountService, final PubSubService pubSubService) {
super(accountService);
this.pubSubService = Objects.requireNonNull(pubSubService);
}
@GET
@Produces("application/json")
public PubSubResponse get(@HeaderParam("Authorization") final String authentication) {
final var steamID = authenticateOrThrow(authentication);
logger.info("get called by " + steamID);
final var chatRooms = pubSubService.getChatRooms(steamID);
return new PubSubResponse(ResultCode.Ok, "", authentication.replace("Bearer ", ""), chatRooms);
}
}