mirror of
https://github.com/DreamExposure/DisCal-Discord-Bot.git
synced 2026-02-05 19:09:35 -06:00
Start work on APIv3 with an invite endpoint
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.dreamexposure.discal.server.endpoints.v2.account
|
||||
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.crypto.KeyGenerator
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
@@ -18,6 +19,7 @@ import reactor.core.publisher.Mono
|
||||
@RestController
|
||||
@RequestMapping("/v2/account/key")
|
||||
class KeyRequestEndpoint {
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
@PostMapping("/readonly/get", produces = ["application/json"])
|
||||
fun getReadOnlyKey(swe: ServerWebExchange, response: ServerHttpResponse): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dreamexposure.discal.server.endpoints.v2.account
|
||||
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.crypto.KeyGenerator
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
@@ -18,6 +19,7 @@ import reactor.core.publisher.Mono
|
||||
@RestController
|
||||
@RequestMapping("/v2/account")
|
||||
class LoginEndpoint {
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
@PostMapping("/login", produces = ["application/json"])
|
||||
fun loginForKey(swe: ServerWebExchange, response: ServerHttpResponse): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dreamexposure.discal.server.endpoints.v2.account
|
||||
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
import org.dreamexposure.discal.server.utils.Authentication
|
||||
@@ -16,6 +17,7 @@ import reactor.core.publisher.Mono
|
||||
@RestController
|
||||
@RequestMapping("/v2/account")
|
||||
class LogoutEndpoint {
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
@GetMapping("/logout", produces = ["application/json"])
|
||||
fun logoutOfAccount(swe: ServerWebExchange, response: ServerHttpResponse): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
|
||||
@@ -4,6 +4,7 @@ import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.`object`.announcement.Announcement
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.enums.announcement.AnnouncementModifier
|
||||
import org.dreamexposure.discal.core.enums.announcement.AnnouncementType
|
||||
import org.dreamexposure.discal.core.enums.event.EventColor
|
||||
@@ -26,6 +27,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/announcement")
|
||||
class CreateAnnouncementEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/create", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun create(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.announcement
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.deleteAnnouncement
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
@@ -22,6 +23,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/announcement")
|
||||
class DeleteAnnouncementEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/delete", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun delete(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.announcement
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getAnnouncement
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
@@ -22,6 +23,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/announcement")
|
||||
class GetAnnouncementEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/get", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun get(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.announcement
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getAllAnnouncements
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
@@ -23,6 +24,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/announcement")
|
||||
class ListAnnouncementEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/list", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun list(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.announcement
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.enums.announcement.AnnouncementModifier
|
||||
import org.dreamexposure.discal.core.enums.announcement.AnnouncementType
|
||||
import org.dreamexposure.discal.core.enums.event.EventColor
|
||||
@@ -25,6 +26,7 @@ import reactor.core.publisher.Mono
|
||||
@RestController
|
||||
@RequestMapping("/v2/announcement")
|
||||
class UpdateAnnouncementEndpoint(val client: DiscordClient) {
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
@PostMapping("/update", produces = ["application/json"])
|
||||
fun update(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.calendar
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.Calendar
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getCalendar
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
@@ -23,6 +24,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/calendar")
|
||||
class DeleteCalendarEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/delete", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun deleteCalendar(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.calendar
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.Calendar
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getCalendar
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
@@ -23,6 +24,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/calendar")
|
||||
class GetCalendarEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/get", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun getCalendar(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.calendar
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.Calendar
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getAllCalendars
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
@@ -24,6 +25,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/calendar")
|
||||
class ListCalendarEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/list", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun listCalendars(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.calendar
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.spec.update.UpdateCalendarSpec
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getCalendar
|
||||
import org.dreamexposure.discal.core.extensions.isValidTimezone
|
||||
@@ -25,6 +26,7 @@ import java.time.ZoneId
|
||||
@RequestMapping("/v2/calendar")
|
||||
class UpdateCalendarEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/update", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun updateCalendar(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.`object`.event.Recurrence
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.Event
|
||||
import org.dreamexposure.discal.core.entities.spec.create.CreateEventSpec
|
||||
import org.dreamexposure.discal.core.enums.event.EventColor
|
||||
@@ -27,6 +28,7 @@ import java.time.Instant
|
||||
@RequestMapping("/v2/event")
|
||||
class CreateEventEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/create", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun create(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.event
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.Event
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getCalendar
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
@@ -23,6 +24,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/event")
|
||||
class DeleteEventEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/delete", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun delete(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.event
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.Event
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getCalendar
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
@@ -23,6 +24,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/event")
|
||||
class GetEventEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/get", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun get(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.`object`.event.Recurrence
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.*
|
||||
import org.dreamexposure.discal.core.entities.spec.update.UpdateEventSpec
|
||||
import org.dreamexposure.discal.core.enums.event.EventColor
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getCalendar
|
||||
@@ -26,6 +27,7 @@ import java.time.Instant
|
||||
@RequestMapping("/v2/event")
|
||||
class UpdateEventEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/update", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun update(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.event.list
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.Event
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getCalendar
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
@@ -25,6 +26,7 @@ import java.time.Instant
|
||||
@RequestMapping("/v2/events/list")
|
||||
class ListEventDateEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/date", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun listByDate(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.event.list
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.Event
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getCalendar
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
@@ -25,6 +26,7 @@ import java.time.Instant
|
||||
@RequestMapping("/v2/events/list")
|
||||
class ListEventMonthEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/month", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun listByMonth(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.event.list
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.Calendar
|
||||
import org.dreamexposure.discal.core.entities.Event
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getCalendar
|
||||
@@ -25,6 +26,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/events/list")
|
||||
class ListEventOngoingEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/ongoing", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun listOngoing(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dreamexposure.discal.server.endpoints.v2.event.list
|
||||
import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.entities.Event
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.getCalendar
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
@@ -25,6 +26,7 @@ import java.time.Instant
|
||||
@RequestMapping("/v2/events/list")
|
||||
class ListEventRangeEndpoint(val client: DiscordClient) {
|
||||
@PostMapping("/range", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun listByRange(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.`object`.web.WebGuild
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.exceptions.BotNotInGuildException
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.hasControlRole
|
||||
import org.dreamexposure.discal.core.extensions.discord4j.hasElevatedPermissions
|
||||
@@ -26,6 +27,7 @@ import reactor.function.TupleUtils
|
||||
@RequestMapping("/v2/guild")
|
||||
class GetWebGuildEndpoint(val client: DiscordClient) {
|
||||
@PostMapping(value = ["/get"], produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun getSettings(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import discord4j.discordjson.json.ImmutableNicknameModifyData
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.*
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
import org.dreamexposure.discal.server.utils.Authentication
|
||||
@@ -23,6 +24,7 @@ import java.util.*
|
||||
@RequestMapping("/v2/guild")
|
||||
class UpdateWebGuildEndpoint(val client: DiscordClient) {
|
||||
@PostMapping(value = ["/update"], produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun updateGuild(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.dreamexposure.discal.server.endpoints.v2.guild.settings
|
||||
|
||||
import discord4j.common.util.Snowflake
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.database.DatabaseManager
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
@@ -22,6 +23,7 @@ import reactor.core.publisher.Mono
|
||||
class GetGuildSettingsEndpoint {
|
||||
|
||||
@PostMapping(value = ["/get"], produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun getSettings(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap<String?> { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.dreamexposure.discal.server.endpoints.v2.guild.settings
|
||||
|
||||
import discord4j.common.util.Snowflake
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.database.DatabaseManager
|
||||
import org.dreamexposure.discal.core.enums.announcement.AnnouncementStyle
|
||||
import org.dreamexposure.discal.core.enums.time.TimeFormat
|
||||
@@ -23,6 +24,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/guild/settings")
|
||||
class UpdateGuildSettingsEndpoint {
|
||||
@PostMapping(value = ["/update"], produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun updateSettings(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.dreamexposure.discal.server.endpoints.v2.rsvp
|
||||
|
||||
import discord4j.common.util.Snowflake
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.database.DatabaseManager
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
@@ -21,6 +22,7 @@ import reactor.core.publisher.Mono
|
||||
@RequestMapping("/v2/rsvp")
|
||||
class GetRsvpEndpoint {
|
||||
@PostMapping("/get", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun getRsvp(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import discord4j.common.util.Snowflake
|
||||
import discord4j.core.DiscordClient
|
||||
import discord4j.rest.http.client.ClientException
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.*
|
||||
import org.dreamexposure.discal.core.database.DatabaseManager
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
@@ -25,6 +26,7 @@ import reactor.function.TupleUtils
|
||||
@RequestMapping("/v2/rsvp")
|
||||
class UpdateRsvpEndpoint(val client: DiscordClient) {
|
||||
@PostMapping(value = ["/update"], produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun updateRsvp(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.dreamexposure.discal.server.endpoints.v2.status
|
||||
|
||||
import kotlinx.serialization.SerializationException
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.AccessLevel
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
import org.dreamexposure.discal.server.network.discal.NetworkManager
|
||||
@@ -19,6 +20,7 @@ import reactor.core.publisher.Mono
|
||||
class GetStatusEndpoint(val networkManager: NetworkManager) {
|
||||
|
||||
@PostMapping("/get", produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun getStatus(swe: ServerWebExchange, response: ServerHttpResponse): Mono<String> {
|
||||
return Authentication.authenticate(swe).map { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.dreamexposure.discal.core.`object`.rest.HeartbeatRequest
|
||||
import org.dreamexposure.discal.core.`object`.rest.HeartbeatType
|
||||
import org.dreamexposure.discal.core.annotations.Authentication.*
|
||||
import org.dreamexposure.discal.core.logger.LOGGER
|
||||
import org.dreamexposure.discal.core.utils.GlobalVal
|
||||
import org.dreamexposure.discal.server.network.discal.NetworkManager
|
||||
@@ -23,6 +24,7 @@ import reactor.core.publisher.Mono
|
||||
class HeartbeatEndpoint(val networkManager: NetworkManager) {
|
||||
|
||||
@PostMapping(value = ["/heartbeat"], produces = ["application/json"])
|
||||
@org.dreamexposure.discal.core.annotations.Authentication(access = AccessLevel.PUBLIC)
|
||||
fun heartbeat(swe: ServerWebExchange, response: ServerHttpResponse, @RequestBody rBody: String): Mono<String> {
|
||||
return Authentication.authenticate(swe).flatMap { authState ->
|
||||
if (!authState.success) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.dreamexposure.discal.server.endpoints.v3
|
||||
|
||||
import org.dreamexposure.discal.core.`object`.BotSettings
|
||||
import org.dreamexposure.discal.core.annotations.Authentication
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v3/")
|
||||
class InviteEndpoint {
|
||||
@Authentication(access = Authentication.AccessLevel.PUBLIC)
|
||||
@GetMapping("invite", produces = ["application/json"])
|
||||
fun get(): Mono<String> {
|
||||
return Mono.just(BotSettings.INVITE_URL.get())
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
spring.application.name=DisCal Server
|
||||
server.port=8080
|
||||
spring.session.store-type=redis
|
||||
discal.security.enabled=true
|
||||
|
||||
Reference in New Issue
Block a user