2024-06-22 05:04:21 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
2024-07-16 10:09:18 +00:00
|
|
|
func MapAPIs(app *fiber.App, baseURL string) {
|
2024-06-22 05:04:21 +00:00
|
|
|
app.Get("/.well-known/openid-configuration", getOidcConfiguration)
|
2024-11-23 05:07:49 +00:00
|
|
|
app.Get("/.well-known/jwks", getJwk)
|
2024-06-22 05:04:21 +00:00
|
|
|
|
2024-07-16 10:09:18 +00:00
|
|
|
api := app.Group(baseURL).Name("API")
|
2024-06-22 05:04:21 +00:00
|
|
|
{
|
2024-11-27 13:57:10 +00:00
|
|
|
checkIn := api.Group("/check-in").Name("Daily Check In API")
|
2024-09-01 08:38:09 +00:00
|
|
|
{
|
2024-11-27 13:57:10 +00:00
|
|
|
checkIn.Get("/", listCheckInRecord)
|
|
|
|
checkIn.Get("/today", getTodayCheckIn)
|
|
|
|
checkIn.Post("/", doCheckIn)
|
2024-09-01 08:38:09 +00:00
|
|
|
}
|
|
|
|
|
2024-06-22 05:04:21 +00:00
|
|
|
notify := api.Group("/notifications").Name("Notifications API")
|
|
|
|
{
|
2024-10-13 04:53:47 +00:00
|
|
|
notify.Get("/", getNotifications)
|
|
|
|
notify.Get("/subscription", getNotifySubscriber)
|
|
|
|
notify.Post("/subscription", addNotifySubscriber)
|
|
|
|
notify.Delete("/subscription/:deviceId", removeNotifySubscriber)
|
2024-07-23 13:25:13 +00:00
|
|
|
notify.Put("/read", markNotificationReadBatch)
|
|
|
|
notify.Put("/read/:notificationId", markNotificationRead)
|
2024-06-22 05:04:21 +00:00
|
|
|
}
|
|
|
|
|
2024-09-17 06:50:05 +00:00
|
|
|
preferences := api.Group("/preferences").Name("Preferences API")
|
|
|
|
{
|
2024-10-13 04:36:51 +00:00
|
|
|
preferences.Get("/auth", getAuthPreference)
|
|
|
|
preferences.Put("/auth", updateAuthPreference)
|
2024-09-17 06:50:05 +00:00
|
|
|
preferences.Get("/notifications", getNotificationPreference)
|
|
|
|
preferences.Put("/notifications", updateNotificationPreference)
|
|
|
|
}
|
|
|
|
|
2024-09-19 13:02:21 +00:00
|
|
|
reports := api.Group("/reports").Name("Reports API")
|
|
|
|
{
|
|
|
|
abuse := reports.Group("/abuse").Name("Abuse Reports")
|
|
|
|
{
|
|
|
|
abuse.Get("/", listAbuseReports)
|
|
|
|
abuse.Get("/:id", getAbuseReport)
|
|
|
|
abuse.Put("/:id/status", updateAbuseReportStatus)
|
|
|
|
abuse.Post("/", createAbuseReport)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-30 09:20:05 +00:00
|
|
|
api.Get("/users/lookup", lookupAccount)
|
2024-07-30 10:20:45 +00:00
|
|
|
api.Get("/users/search", searchAccount)
|
2024-06-30 09:20:05 +00:00
|
|
|
|
2024-06-22 05:04:21 +00:00
|
|
|
me := api.Group("/users/me").Name("Myself Operations")
|
|
|
|
{
|
|
|
|
|
2024-06-26 09:07:20 +00:00
|
|
|
me.Get("/avatar", getAvatar)
|
|
|
|
me.Get("/banner", getBanner)
|
2024-06-22 05:04:21 +00:00
|
|
|
me.Put("/avatar", setAvatar)
|
|
|
|
me.Put("/banner", setBanner)
|
|
|
|
|
|
|
|
me.Get("/", getUserinfo)
|
|
|
|
me.Put("/", editUserinfo)
|
|
|
|
me.Get("/events", getEvents)
|
|
|
|
me.Get("/tickets", getTickets)
|
2024-06-26 06:47:34 +00:00
|
|
|
me.Delete("/tickets/:ticketId", killTicket)
|
2024-06-22 05:04:21 +00:00
|
|
|
|
|
|
|
me.Post("/confirm", doRegisterConfirm)
|
|
|
|
|
2024-06-26 12:53:11 +00:00
|
|
|
me.Get("/status", getMyselfStatus)
|
2024-06-26 12:05:28 +00:00
|
|
|
me.Post("/status", setStatus)
|
2024-06-26 12:41:20 +00:00
|
|
|
me.Put("/status", editStatus)
|
|
|
|
me.Delete("/status", clearStatus)
|
2024-06-26 12:05:28 +00:00
|
|
|
|
2024-07-23 13:25:13 +00:00
|
|
|
relations := me.Group("/relations").Name("Relations")
|
2024-06-22 05:04:21 +00:00
|
|
|
{
|
2024-09-26 14:09:39 +00:00
|
|
|
relations.Post("/", makeFriendship)
|
|
|
|
relations.Post("/block", makeBlockship)
|
|
|
|
|
2024-07-23 13:25:13 +00:00
|
|
|
relations.Get("/", listRelationship)
|
|
|
|
relations.Get("/:relatedId", getRelationship)
|
2024-07-23 16:04:21 +00:00
|
|
|
relations.Put("/:relatedId", editRelationship)
|
2024-07-23 13:25:13 +00:00
|
|
|
relations.Delete("/:relatedId", deleteRelationship)
|
2024-07-23 15:50:05 +00:00
|
|
|
|
|
|
|
relations.Post("/:relatedId", makeFriendship)
|
2024-07-23 16:04:21 +00:00
|
|
|
relations.Post("/:relatedId/accept", acceptFriend)
|
|
|
|
relations.Post("/:relatedId/decline", declineFriend)
|
2024-06-22 05:04:21 +00:00
|
|
|
}
|
2024-09-19 14:18:22 +00:00
|
|
|
|
2024-09-21 14:50:01 +00:00
|
|
|
me.Post("/password-reset", requestResetPassword)
|
|
|
|
me.Patch("/password-reset", confirmResetPassword)
|
|
|
|
|
2024-09-19 14:18:22 +00:00
|
|
|
me.Post("/deletion", requestDeleteAccount)
|
2024-09-21 14:50:01 +00:00
|
|
|
me.Patch("/deletion", confirmDeleteAccount)
|
2024-06-22 05:04:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
directory := api.Group("/users/:alias").Name("User Directory")
|
|
|
|
{
|
|
|
|
directory.Get("/", getOtherUserinfo)
|
2024-06-26 12:05:28 +00:00
|
|
|
directory.Get("/status", getStatus)
|
2024-09-21 14:50:01 +00:00
|
|
|
|
2024-11-27 13:57:10 +00:00
|
|
|
directory.Get("/check-in", listOtherUserCheckInRecord)
|
2024-06-22 05:04:21 +00:00
|
|
|
}
|
|
|
|
|
2024-07-30 12:28:38 +00:00
|
|
|
api.Get("/users", getOtherUserinfoBatch)
|
2024-06-22 05:04:21 +00:00
|
|
|
api.Post("/users", doRegister)
|
|
|
|
|
2024-06-26 06:47:34 +00:00
|
|
|
auth := api.Group("/auth").Name("Auth")
|
|
|
|
{
|
|
|
|
auth.Post("/", doAuthenticate)
|
2024-09-15 18:37:02 +00:00
|
|
|
auth.Patch("/", doAuthTicketCheck)
|
2024-06-26 06:47:34 +00:00
|
|
|
auth.Post("/token", getToken)
|
|
|
|
|
2024-06-26 10:18:04 +00:00
|
|
|
auth.Get("/tickets/:ticketId", getTicket)
|
|
|
|
|
2024-06-26 06:47:34 +00:00
|
|
|
auth.Get("/factors", getAvailableFactors)
|
|
|
|
auth.Post("/factors/:factorId", requestFactorToken)
|
2024-06-24 15:54:45 +00:00
|
|
|
|
2024-06-26 06:47:34 +00:00
|
|
|
auth.Get("/o/authorize", tryAuthorizeThirdClient)
|
|
|
|
auth.Post("/o/authorize", authorizeThirdClient)
|
|
|
|
}
|
2024-06-22 05:04:21 +00:00
|
|
|
|
|
|
|
realms := api.Group("/realms").Name("Realms API")
|
|
|
|
{
|
|
|
|
realms.Get("/", listCommunityRealm)
|
|
|
|
realms.Get("/me", listOwnedRealm)
|
|
|
|
realms.Get("/me/available", listAvailableRealm)
|
|
|
|
realms.Get("/:realm", getRealm)
|
|
|
|
realms.Get("/:realm/members", listRealmMembers)
|
|
|
|
realms.Get("/:realm/members/me", getMyRealmMember)
|
|
|
|
realms.Post("/", createRealm)
|
|
|
|
realms.Put("/:realmId", editRealm)
|
|
|
|
realms.Delete("/:realmId", deleteRealm)
|
|
|
|
realms.Post("/:realm/members", addRealmMember)
|
|
|
|
realms.Delete("/:realm/members", removeRealmMember)
|
|
|
|
realms.Delete("/:realm/members/me", leaveRealm)
|
|
|
|
}
|
|
|
|
|
|
|
|
developers := api.Group("/dev").Name("Developers API")
|
|
|
|
{
|
|
|
|
developers.Post("/notify", notifyUser)
|
2024-08-24 12:28:10 +00:00
|
|
|
|
2024-08-24 15:49:19 +00:00
|
|
|
bots := developers.Group("/bots").Name("Bots")
|
|
|
|
{
|
|
|
|
bots.Get("/", listBots)
|
|
|
|
bots.Post("/", createBot)
|
2024-08-25 12:51:58 +00:00
|
|
|
bots.Delete("/:botId", deleteBot)
|
|
|
|
|
2024-08-25 13:35:22 +00:00
|
|
|
keys := bots.Group("/:botId/keys").Name("Bots' Keys")
|
2024-08-25 12:51:58 +00:00
|
|
|
{
|
|
|
|
keys.Get("/", listBotKeys)
|
|
|
|
keys.Post("/", createBotKey)
|
2024-08-25 16:44:10 +00:00
|
|
|
keys.Post("/:id/roll", rollBotKey)
|
|
|
|
keys.Put("/:id", editBotKey)
|
|
|
|
keys.Delete("/:id", revokeBotKey)
|
2024-08-25 12:51:58 +00:00
|
|
|
}
|
2024-08-24 15:49:19 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 12:51:58 +00:00
|
|
|
keys := developers.Group("/keys").Name("Own Bots' Keys")
|
2024-08-24 12:28:10 +00:00
|
|
|
{
|
|
|
|
keys.Get("/", listBotKeys)
|
|
|
|
keys.Get("/:id", getBotKey)
|
|
|
|
keys.Post("/", createBotKey)
|
|
|
|
keys.Post("/:id/roll", rollBotKey)
|
|
|
|
keys.Put("/:id", editBotKey)
|
|
|
|
keys.Delete("/:id", revokeBotKey)
|
|
|
|
}
|
2024-06-22 05:04:21 +00:00
|
|
|
}
|
|
|
|
|
2024-06-24 15:06:20 +00:00
|
|
|
api.All("/*", func(c *fiber.Ctx) error {
|
|
|
|
return fiber.ErrNotFound
|
|
|
|
})
|
2024-06-22 05:04:21 +00:00
|
|
|
}
|
|
|
|
}
|