summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-15 11:13:21 +0200
commit1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c (patch)
tree1035116ddbaacc5fcc5ae250a6592eb88f78f75c /src
parentDo the funny thing (make user->invite cascade delet) (diff)
parentchange dev panel path, we missed this one... (diff)
downloadserver-1a94fb1208bf0e4c669cad16aff5f57dc0bf7a3c.tar.xz
Merge branch 'dev/restructure' into staging
Diffstat (limited to '')
-rw-r--r--src/Server.ts (renamed from bundle/src/Server.ts)2
-rw-r--r--src/api/Server.ts (renamed from api/src/Server.ts)0
-rw-r--r--src/api/global.d.ts (renamed from api/src/global.d.ts)0
-rw-r--r--src/api/index.ts (renamed from api/src/index.ts)0
-rw-r--r--src/api/middlewares/Authentication.ts (renamed from api/src/middlewares/Authentication.ts)0
-rw-r--r--src/api/middlewares/BodyParser.ts (renamed from api/src/middlewares/BodyParser.ts)0
-rw-r--r--src/api/middlewares/CORS.ts (renamed from api/src/middlewares/CORS.ts)0
-rw-r--r--src/api/middlewares/ErrorHandler.ts (renamed from api/src/middlewares/ErrorHandler.ts)0
-rw-r--r--src/api/middlewares/RateLimit.ts (renamed from api/src/middlewares/RateLimit.ts)0
-rw-r--r--src/api/middlewares/TestClient.ts (renamed from api/src/middlewares/TestClient.ts)18
-rw-r--r--src/api/middlewares/Translation.ts (renamed from api/src/middlewares/Translation.ts)6
-rw-r--r--src/api/middlewares/index.ts (renamed from api/src/middlewares/index.ts)0
-rw-r--r--src/api/routes/-/healthz.ts (renamed from api/src/routes/-/healthz.ts)0
-rw-r--r--src/api/routes/-/readyz.ts (renamed from api/src/routes/-/readyz.ts)0
-rw-r--r--src/api/routes/applications/#id/bot/index.ts (renamed from api/src/routes/applications/#id/bot/index.ts)0
-rw-r--r--src/api/routes/applications/#id/entitlements.ts (renamed from api/src/routes/applications/#id/entitlements.ts)0
-rw-r--r--src/api/routes/applications/#id/index.ts (renamed from api/src/routes/applications/#id/index.ts)0
-rw-r--r--src/api/routes/applications/#id/skus.ts (renamed from api/src/routes/applications/#id/skus.ts)0
-rw-r--r--src/api/routes/applications/detectable.ts (renamed from api/src/routes/applications/detectable.ts)0
-rw-r--r--src/api/routes/applications/index.ts (renamed from api/src/routes/applications/index.ts)0
-rw-r--r--src/api/routes/auth/location-metadata.ts (renamed from api/src/routes/auth/location-metadata.ts)0
-rw-r--r--src/api/routes/auth/login.ts (renamed from api/src/routes/auth/login.ts)11
-rw-r--r--src/api/routes/auth/mfa/totp.ts (renamed from api/src/routes/auth/mfa/totp.ts)9
-rw-r--r--src/api/routes/auth/register.ts (renamed from api/src/routes/auth/register.ts)28
-rw-r--r--src/api/routes/channels/#channel_id/followers.ts (renamed from api/src/routes/channels/#channel_id/followers.ts)0
-rw-r--r--src/api/routes/channels/#channel_id/index.ts (renamed from api/src/routes/channels/#channel_id/index.ts)28
-rw-r--r--src/api/routes/channels/#channel_id/invites.ts (renamed from api/src/routes/channels/#channel_id/invites.ts)20
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/ack.ts (renamed from api/src/routes/channels/#channel_id/messages/#message_id/ack.ts)9
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts (renamed from api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts)0
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/index.ts (renamed from api/src/routes/channels/#channel_id/messages/#message_id/index.ts)4
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts (renamed from api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts)0
-rw-r--r--src/api/routes/channels/#channel_id/messages/bulk-delete.ts (renamed from api/src/routes/channels/#channel_id/messages/bulk-delete.ts)6
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts (renamed from api/src/routes/channels/#channel_id/messages/index.ts)36
-rw-r--r--src/api/routes/channels/#channel_id/permissions.ts (renamed from api/src/routes/channels/#channel_id/permissions.ts)7
-rw-r--r--src/api/routes/channels/#channel_id/pins.ts (renamed from api/src/routes/channels/#channel_id/pins.ts)0
-rw-r--r--src/api/routes/channels/#channel_id/purge.ts (renamed from api/src/routes/channels/#channel_id/purge.ts)7
-rw-r--r--src/api/routes/channels/#channel_id/recipients.ts (renamed from api/src/routes/channels/#channel_id/recipients.ts)0
-rw-r--r--src/api/routes/channels/#channel_id/typing.ts (renamed from api/src/routes/channels/#channel_id/typing.ts)0
-rw-r--r--src/api/routes/channels/#channel_id/webhooks.ts (renamed from api/src/routes/channels/#channel_id/webhooks.ts)9
-rw-r--r--src/api/routes/discoverable-guilds.ts (renamed from api/src/routes/discoverable-guilds.ts)0
-rw-r--r--src/api/routes/discovery.ts (renamed from api/src/routes/discovery.ts)0
-rw-r--r--src/api/routes/downloads.ts (renamed from api/src/routes/downloads.ts)0
-rw-r--r--src/api/routes/experiments.ts (renamed from api/src/routes/experiments.ts)0
-rw-r--r--src/api/routes/gateway/bot.ts (renamed from api/src/routes/gateway/bot.ts)0
-rw-r--r--src/api/routes/gateway/index.ts (renamed from api/src/routes/gateway/index.ts)0
-rw-r--r--src/api/routes/gifs/search.ts (renamed from api/src/routes/gifs/search.ts)0
-rw-r--r--src/api/routes/gifs/trending-gifs.ts (renamed from api/src/routes/gifs/trending-gifs.ts)0
-rw-r--r--src/api/routes/gifs/trending.ts (renamed from api/src/routes/gifs/trending.ts)0
-rw-r--r--src/api/routes/guild-recommendations.ts (renamed from api/src/routes/guild-recommendations.ts)0
-rw-r--r--src/api/routes/guilds/#guild_id/audit-logs.ts (renamed from api/src/routes/guilds/#guild_id/audit-logs.ts)3
-rw-r--r--src/api/routes/guilds/#guild_id/bans.ts (renamed from api/src/routes/guilds/#guild_id/bans.ts)24
-rw-r--r--src/api/routes/guilds/#guild_id/channels.ts (renamed from api/src/routes/guilds/#guild_id/channels.ts)5
-rw-r--r--src/api/routes/guilds/#guild_id/delete.ts (renamed from api/src/routes/guilds/#guild_id/delete.ts)0
-rw-r--r--src/api/routes/guilds/#guild_id/discovery-requirements.ts (renamed from api/src/routes/guilds/#guild_id/discovery-requirements.ts)0
-rw-r--r--src/api/routes/guilds/#guild_id/emojis.ts (renamed from api/src/routes/guilds/#guild_id/emojis.ts)14
-rw-r--r--src/api/routes/guilds/#guild_id/index.ts (renamed from api/src/routes/guilds/#guild_id/index.ts)19
-rw-r--r--src/api/routes/guilds/#guild_id/integrations.ts (renamed from api/src/routes/guilds/#guild_id/integrations.ts)1
-rw-r--r--src/api/routes/guilds/#guild_id/invites.ts (renamed from api/src/routes/guilds/#guild_id/invites.ts)0
-rw-r--r--src/api/routes/guilds/#guild_id/members/#member_id/index.ts (renamed from api/src/routes/guilds/#guild_id/members/#member_id/index.ts)6
-rw-r--r--src/api/routes/guilds/#guild_id/members/#member_id/nick.ts (renamed from api/src/routes/guilds/#guild_id/members/#member_id/nick.ts)4
-rw-r--r--src/api/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts (renamed from api/src/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts)0
-rw-r--r--src/api/routes/guilds/#guild_id/members/index.ts (renamed from api/src/routes/guilds/#guild_id/members/index.ts)0
-rw-r--r--src/api/routes/guilds/#guild_id/premium.ts (renamed from api/src/routes/guilds/#guild_id/premium.ts)0
-rw-r--r--src/api/routes/guilds/#guild_id/prune.ts (renamed from api/src/routes/guilds/#guild_id/prune.ts)7
-rw-r--r--src/api/routes/guilds/#guild_id/regions.ts (renamed from api/src/routes/guilds/#guild_id/regions.ts)0
-rw-r--r--src/api/routes/guilds/#guild_id/roles/#role_id/index.ts (renamed from api/src/routes/guilds/#guild_id/roles/#role_id/index.ts)3
-rw-r--r--src/api/routes/guilds/#guild_id/roles/index.ts (renamed from api/src/routes/guilds/#guild_id/roles/index.ts)20
-rw-r--r--src/api/routes/guilds/#guild_id/stickers.ts (renamed from api/src/routes/guilds/#guild_id/stickers.ts)17
-rw-r--r--src/api/routes/guilds/#guild_id/templates.ts (renamed from api/src/routes/guilds/#guild_id/templates.ts)10
-rw-r--r--src/api/routes/guilds/#guild_id/vanity-url.ts (renamed from api/src/routes/guilds/#guild_id/vanity-url.ts)10
-rw-r--r--src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts (renamed from api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts)14
-rw-r--r--src/api/routes/guilds/#guild_id/webhooks.ts (renamed from api/src/routes/guilds/#guild_id/webhooks.ts)1
-rw-r--r--src/api/routes/guilds/#guild_id/welcome_screen.ts (renamed from api/src/routes/guilds/#guild_id/welcome_screen.ts)13
-rw-r--r--src/api/routes/guilds/#guild_id/widget.json.ts (renamed from api/src/routes/guilds/#guild_id/widget.json.ts)0
-rw-r--r--src/api/routes/guilds/#guild_id/widget.png.ts (renamed from api/src/routes/guilds/#guild_id/widget.png.ts)2
-rw-r--r--src/api/routes/guilds/#guild_id/widget.ts (renamed from api/src/routes/guilds/#guild_id/widget.ts)7
-rw-r--r--src/api/routes/guilds/index.ts (renamed from api/src/routes/guilds/index.ts)16
-rw-r--r--src/api/routes/guilds/templates/index.ts (renamed from api/src/routes/guilds/templates/index.ts)9
-rw-r--r--src/api/routes/invites/index.ts (renamed from api/src/routes/invites/index.ts)0
-rw-r--r--src/api/routes/oauth2/tokens.ts (renamed from api/src/routes/oauth2/tokens.ts)0
-rw-r--r--src/api/routes/outbound-promotions.ts (renamed from api/src/routes/outbound-promotions.ts)0
-rw-r--r--src/api/routes/partners/#guild_id/requirements.ts (renamed from api/src/routes/partners/#guild_id/requirements.ts)0
-rw-r--r--src/api/routes/ping.ts (renamed from api/src/routes/ping.ts)0
-rw-r--r--src/api/routes/policies/instance/domains.ts (renamed from api/src/routes/policies/instance/domains.ts)0
-rw-r--r--src/api/routes/policies/instance/index.ts (renamed from api/src/routes/policies/instance/index.ts)0
-rw-r--r--src/api/routes/policies/instance/limits.ts (renamed from api/src/routes/policies/instance/limits.ts)0
-rw-r--r--src/api/routes/scheduled-maintenances/upcoming_json.ts (renamed from api/src/routes/scheduled-maintenances/upcoming_json.ts)0
-rw-r--r--src/api/routes/science.ts (renamed from api/src/routes/science.ts)0
-rw-r--r--src/api/routes/stage-instances.ts (renamed from api/src/routes/stage-instances.ts)0
-rw-r--r--src/api/routes/sticker-packs/index.ts (renamed from api/src/routes/sticker-packs/index.ts)0
-rw-r--r--src/api/routes/stickers/#sticker_id/index.ts (renamed from api/src/routes/stickers/#sticker_id/index.ts)0
-rw-r--r--src/api/routes/stop.ts (renamed from api/src/routes/stop.ts)0
-rw-r--r--src/api/routes/store/published-listings/applications.ts (renamed from api/src/routes/store/published-listings/applications.ts)0
-rw-r--r--src/api/routes/store/published-listings/applications/#id/subscription-plans.ts (renamed from api/src/routes/store/published-listings/applications/#id/subscription-plans.ts)0
-rw-r--r--src/api/routes/store/published-listings/skus.ts (renamed from api/src/routes/store/published-listings/skus.ts)0
-rw-r--r--src/api/routes/store/published-listings/skus/#sku_id/subscription-plans.ts (renamed from api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts)0
-rw-r--r--src/api/routes/teams.ts (renamed from api/src/routes/teams.ts)0
-rw-r--r--src/api/routes/template.ts.disabled (renamed from api/src/routes/template.ts.disabled)0
-rw-r--r--src/api/routes/track.ts (renamed from api/src/routes/track.ts)0
-rw-r--r--src/api/routes/updates.ts (renamed from api/src/routes/updates.ts)0
-rw-r--r--src/api/routes/users/#id/index.ts (renamed from api/src/routes/users/#id/index.ts)0
-rw-r--r--src/api/routes/users/#id/profile.ts (renamed from api/src/routes/users/#id/profile.ts)0
-rw-r--r--src/api/routes/users/#id/relationships.ts (renamed from api/src/routes/users/#id/relationships.ts)0
-rw-r--r--src/api/routes/users/@me/activities/statistics/applications.ts (renamed from api/src/routes/users/@me/activities/statistics/applications.ts)0
-rw-r--r--src/api/routes/users/@me/affinities/guilds.ts (renamed from api/src/routes/users/@me/affinities/guilds.ts)0
-rw-r--r--src/api/routes/users/@me/affinities/users.ts (renamed from api/src/routes/users/@me/affinities/users.ts)0
-rw-r--r--src/api/routes/users/@me/applications/#app_id/entitlements.ts (renamed from api/src/routes/users/@me/applications/#app_id/entitlements.ts)0
-rw-r--r--src/api/routes/users/@me/billing/country-code.ts (renamed from api/src/routes/users/@me/billing/country-code.ts)0
-rw-r--r--src/api/routes/users/@me/billing/payment-sources.ts (renamed from api/src/routes/users/@me/billing/payment-sources.ts)0
-rw-r--r--src/api/routes/users/@me/billing/subscriptions.ts (renamed from api/src/routes/users/@me/billing/subscriptions.ts)0
-rw-r--r--src/api/routes/users/@me/channels.ts (renamed from api/src/routes/users/@me/channels.ts)7
-rw-r--r--src/api/routes/users/@me/connections.ts (renamed from api/src/routes/users/@me/connections.ts)0
-rw-r--r--src/api/routes/users/@me/delete.ts (renamed from api/src/routes/users/@me/delete.ts)0
-rw-r--r--src/api/routes/users/@me/devices.ts (renamed from api/src/routes/users/@me/devices.ts)0
-rw-r--r--src/api/routes/users/@me/disable.ts (renamed from api/src/routes/users/@me/disable.ts)0
-rw-r--r--src/api/routes/users/@me/email-settings.ts (renamed from api/src/routes/users/@me/email-settings.ts)0
-rw-r--r--src/api/routes/users/@me/entitlements.ts (renamed from api/src/routes/users/@me/entitlements.ts)0
-rw-r--r--src/api/routes/users/@me/guilds.ts (renamed from api/src/routes/users/@me/guilds.ts)0
-rw-r--r--src/api/routes/users/@me/guilds/premium/subscription-slots.ts (renamed from api/src/routes/users/@me/guilds/premium/subscription-slots.ts)0
-rw-r--r--src/api/routes/users/@me/index.ts (renamed from api/src/routes/users/@me/index.ts)21
-rw-r--r--src/api/routes/users/@me/library.ts (renamed from api/src/routes/users/@me/library.ts)0
-rw-r--r--src/api/routes/users/@me/mfa/codes.ts (renamed from api/src/routes/users/@me/mfa/codes.ts)7
-rw-r--r--src/api/routes/users/@me/mfa/totp/disable.ts (renamed from api/src/routes/users/@me/mfa/totp/disable.ts)6
-rw-r--r--src/api/routes/users/@me/mfa/totp/enable.ts (renamed from api/src/routes/users/@me/mfa/totp/enable.ts)8
-rw-r--r--src/api/routes/users/@me/notes.ts (renamed from api/src/routes/users/@me/notes.ts)0
-rw-r--r--src/api/routes/users/@me/relationships.ts (renamed from api/src/routes/users/@me/relationships.ts)9
-rw-r--r--src/api/routes/users/@me/settings.ts (renamed from api/src/routes/users/@me/settings.ts)6
-rw-r--r--src/api/routes/voice/regions.ts (renamed from api/src/routes/voice/regions.ts)0
-rw-r--r--src/api/start.ts (renamed from api/src/start.ts)0
-rw-r--r--src/api/util/entities/AssetCacheItem.ts (renamed from api/src/util/entities/AssetCacheItem.ts)0
-rw-r--r--src/api/util/entities/blockedEmailDomains.txt (renamed from api/src/util/entities/blockedEmailDomains.txt)0
-rw-r--r--src/api/util/entities/trustedEmailDomains.txt (renamed from api/src/util/entities/trustedEmailDomains.txt)0
-rw-r--r--src/api/util/handlers/Instance.ts (renamed from api/src/util/handlers/Instance.ts)0
-rw-r--r--src/api/util/handlers/Message.ts (renamed from api/src/util/handlers/Message.ts)3
-rw-r--r--src/api/util/handlers/Voice.ts (renamed from api/src/util/handlers/Voice.ts)0
-rw-r--r--src/api/util/handlers/route.ts (renamed from api/src/util/handlers/route.ts)7
-rw-r--r--src/api/util/index.ts (renamed from api/src/util/index.ts)0
-rw-r--r--src/api/util/utility/Base64.ts (renamed from api/src/util/utility/Base64.ts)0
-rw-r--r--src/api/util/utility/RandomInviteID.ts (renamed from api/src/util/utility/RandomInviteID.ts)0
-rw-r--r--src/api/util/utility/String.ts (renamed from api/src/util/utility/String.ts)0
-rw-r--r--src/api/util/utility/ipAddress.ts (renamed from api/src/util/utility/ipAddress.ts)0
-rw-r--r--src/api/util/utility/passwordStrength.ts (renamed from api/src/util/utility/passwordStrength.ts)0
-rw-r--r--src/cdn/Server.ts (renamed from cdn/src/Server.ts)0
-rw-r--r--src/cdn/index.ts (renamed from cdn/src/index.ts)0
-rw-r--r--src/cdn/routes/attachments.ts (renamed from cdn/src/routes/attachments.ts)0
-rw-r--r--src/cdn/routes/avatars.ts (renamed from cdn/src/routes/avatars.ts)0
-rw-r--r--src/cdn/routes/external.ts (renamed from cdn/src/routes/external.ts)0
-rw-r--r--src/cdn/routes/ping.ts (renamed from cdn/src/routes/ping.ts)0
-rw-r--r--src/cdn/routes/role-icons.ts (renamed from cdn/src/routes/role-icons.ts)0
-rw-r--r--src/cdn/start.ts (renamed from cdn/src/start.ts)0
-rw-r--r--src/cdn/util/FileStorage.ts (renamed from cdn/src/util/FileStorage.ts)0
-rw-r--r--src/cdn/util/S3Storage.ts (renamed from cdn/src/util/S3Storage.ts)0
-rw-r--r--src/cdn/util/Storage.ts (renamed from cdn/src/util/Storage.ts)0
-rw-r--r--src/cdn/util/index.ts (renamed from cdn/src/util/index.ts)0
-rw-r--r--src/cdn/util/multer.ts (renamed from cdn/src/util/multer.ts)0
-rw-r--r--src/gateway/Server.ts (renamed from gateway/src/Server.ts)0
-rw-r--r--src/gateway/events/Close.ts (renamed from gateway/src/events/Close.ts)0
-rw-r--r--src/gateway/events/Connection.ts (renamed from gateway/src/events/Connection.ts)0
-rw-r--r--src/gateway/events/Message.ts (renamed from gateway/src/events/Message.ts)3
-rw-r--r--src/gateway/index.ts (renamed from gateway/src/index.ts)0
-rw-r--r--src/gateway/listener/listener.ts (renamed from gateway/src/listener/listener.ts)0
-rw-r--r--src/gateway/opcodes/Heartbeat.ts (renamed from gateway/src/opcodes/Heartbeat.ts)0
-rw-r--r--src/gateway/opcodes/Identify.ts (renamed from gateway/src/opcodes/Identify.ts)12
-rw-r--r--src/gateway/opcodes/LazyRequest.ts (renamed from gateway/src/opcodes/LazyRequest.ts)5
-rw-r--r--src/gateway/opcodes/PresenceUpdate.ts (renamed from gateway/src/opcodes/PresenceUpdate.ts)3
-rw-r--r--src/gateway/opcodes/RequestGuildMembers.ts (renamed from gateway/src/opcodes/RequestGuildMembers.ts)0
-rw-r--r--src/gateway/opcodes/Resume.ts (renamed from gateway/src/opcodes/Resume.ts)0
-rw-r--r--src/gateway/opcodes/VoiceStateUpdate.ts (renamed from gateway/src/opcodes/VoiceStateUpdate.ts)9
-rw-r--r--src/gateway/opcodes/experiments.json (renamed from gateway/src/opcodes/experiments.json)0
-rw-r--r--src/gateway/opcodes/index.ts (renamed from gateway/src/opcodes/index.ts)0
-rw-r--r--src/gateway/opcodes/instanceOf.ts (renamed from gateway/src/opcodes/instanceOf.ts)0
-rw-r--r--src/gateway/start.ts (renamed from gateway/src/start.ts)0
-rw-r--r--src/gateway/util/Constants.ts (renamed from gateway/src/util/Constants.ts)0
-rw-r--r--src/gateway/util/Heartbeat.ts (renamed from gateway/src/util/Heartbeat.ts)0
-rw-r--r--src/gateway/util/Send.ts (renamed from gateway/src/util/Send.ts)0
-rw-r--r--src/gateway/util/SessionUtils.ts (renamed from gateway/src/util/SessionUtils.ts)0
-rw-r--r--src/gateway/util/WebSocket.ts (renamed from gateway/src/util/WebSocket.ts)4
-rw-r--r--src/gateway/util/index.ts (renamed from gateway/src/util/index.ts)0
-rwxr-xr-xsrc/plugins/example-plugin/build.sh5
-rw-r--r--src/plugins/example-plugin/index.ts7
-rw-r--r--src/plugins/example-plugin/plugin.json9
-rw-r--r--src/plugins/example-plugin/tsconfig.json (renamed from api/tsconfig.json)160
-rw-r--r--src/start.ts (renamed from bundle/src/start.ts)0
-rw-r--r--src/stats.ts24
-rw-r--r--src/util/config/Config.ts22
-rw-r--r--src/util/config/index.ts2
-rw-r--r--src/util/config/types/ApiConfiguration.ts5
-rw-r--r--src/util/config/types/ClientConfiguration.ts8
-rw-r--r--src/util/config/types/DefaultsConfiguration.ts6
-rw-r--r--src/util/config/types/EndpointConfiguration.ts5
-rw-r--r--src/util/config/types/GeneralConfiguration.ts12
-rw-r--r--src/util/config/types/GifConfiguration.ts5
-rw-r--r--src/util/config/types/GuildConfiguration.ts6
-rw-r--r--src/util/config/types/KafkaConfiguration.ts5
-rw-r--r--src/util/config/types/LimitConfigurations.ts9
-rw-r--r--src/util/config/types/LoginConfiguration.ts3
-rw-r--r--src/util/config/types/MetricsConfiguration.ts3
-rw-r--r--src/util/config/types/RabbitMQConfiguration.ts3
-rw-r--r--src/util/config/types/RegionConfiguration.ts16
-rw-r--r--src/util/config/types/RegisterConfiguration.ts18
-rw-r--r--src/util/config/types/SecurityConfiguration.ts17
-rw-r--r--src/util/config/types/SentryConfiguration.ts8
-rw-r--r--src/util/config/types/TemplateConfiguration.ts6
-rw-r--r--src/util/config/types/index.ts18
-rw-r--r--src/util/config/types/subconfigurations/client/ClientReleaseConfiguration.ts4
-rw-r--r--src/util/config/types/subconfigurations/client/index.ts1
-rw-r--r--src/util/config/types/subconfigurations/defaults/GuildDefaults.ts8
-rw-r--r--src/util/config/types/subconfigurations/defaults/UserDefaults.ts5
-rw-r--r--src/util/config/types/subconfigurations/defaults/index.ts2
-rw-r--r--src/util/config/types/subconfigurations/guild/AutoJoin.ts5
-rw-r--r--src/util/config/types/subconfigurations/guild/Discovery.ts6
-rw-r--r--src/util/config/types/subconfigurations/guild/index.ts2
-rw-r--r--src/util/config/types/subconfigurations/index.ts8
-rw-r--r--src/util/config/types/subconfigurations/kafka/KafkaBroker.ts4
-rw-r--r--src/util/config/types/subconfigurations/kafka/index.ts1
-rw-r--r--src/util/config/types/subconfigurations/limits/ChannelLimits.ts5
-rw-r--r--src/util/config/types/subconfigurations/limits/GuildLimits.ts8
-rw-r--r--src/util/config/types/subconfigurations/limits/MessageLimits.ts8
-rw-r--r--src/util/config/types/subconfigurations/limits/RateLimits.ts18
-rw-r--r--src/util/config/types/subconfigurations/limits/UserLimits.ts5
-rw-r--r--src/util/config/types/subconfigurations/limits/index.ts6
-rw-r--r--src/util/config/types/subconfigurations/limits/ratelimits/Auth.ts12
-rw-r--r--src/util/config/types/subconfigurations/limits/ratelimits/RateLimitOptions.ts6
-rw-r--r--src/util/config/types/subconfigurations/limits/ratelimits/Route.ts19
-rw-r--r--src/util/config/types/subconfigurations/limits/ratelimits/index.ts3
-rw-r--r--src/util/config/types/subconfigurations/region/Region.ts12
-rw-r--r--src/util/config/types/subconfigurations/region/index.ts1
-rw-r--r--src/util/config/types/subconfigurations/register/DateOfBirth.ts4
-rw-r--r--src/util/config/types/subconfigurations/register/Email.ts7
-rw-r--r--src/util/config/types/subconfigurations/register/Password.ts7
-rw-r--r--src/util/config/types/subconfigurations/register/index.ts3
-rw-r--r--src/util/config/types/subconfigurations/security/Captcha.ts6
-rw-r--r--src/util/config/types/subconfigurations/security/TwoFactor.ts3
-rw-r--r--src/util/config/types/subconfigurations/security/index.ts2
-rw-r--r--src/util/dtos/DmChannelDTO.ts (renamed from util/src/dtos/DmChannelDTO.ts)0
-rw-r--r--src/util/dtos/UserDTO.ts (renamed from util/src/dtos/UserDTO.ts)0
-rw-r--r--src/util/dtos/index.ts (renamed from util/src/dtos/index.ts)0
-rw-r--r--src/util/entities/Application.ts (renamed from util/src/entities/Application.ts)0
-rw-r--r--src/util/entities/Attachment.ts (renamed from util/src/entities/Attachment.ts)0
-rw-r--r--src/util/entities/AuditLog.ts (renamed from util/src/entities/AuditLog.ts)0
-rw-r--r--src/util/entities/BackupCodes.ts (renamed from util/src/entities/BackupCodes.ts)0
-rw-r--r--src/util/entities/Ban.ts (renamed from util/src/entities/Ban.ts)0
-rw-r--r--src/util/entities/BaseClass.ts (renamed from util/src/entities/BaseClass.ts)2
-rw-r--r--src/util/entities/Categories.ts (renamed from util/src/entities/Categories.ts)0
-rw-r--r--src/util/entities/Channel.ts (renamed from util/src/entities/Channel.ts)7
-rw-r--r--src/util/entities/ClientRelease.ts (renamed from util/src/entities/ClientRelease.ts)0
-rw-r--r--src/util/entities/Config.ts11
-rw-r--r--src/util/entities/ConnectedAccount.ts (renamed from util/src/entities/ConnectedAccount.ts)0
-rw-r--r--src/util/entities/Emoji.ts (renamed from util/src/entities/Emoji.ts)0
-rw-r--r--src/util/entities/Encryption.ts (renamed from util/src/entities/Encryption.ts)0
-rw-r--r--src/util/entities/Group.ts (renamed from util/src/entities/Group.ts)0
-rw-r--r--src/util/entities/Guild.ts (renamed from util/src/entities/Guild.ts)20
-rw-r--r--src/util/entities/Invite.ts (renamed from util/src/entities/Invite.ts)0
-rw-r--r--src/util/entities/Member.ts (renamed from util/src/entities/Member.ts)0
-rw-r--r--src/util/entities/Message.ts (renamed from util/src/entities/Message.ts)0
-rw-r--r--src/util/entities/Migration.ts (renamed from util/src/entities/Migration.ts)0
-rw-r--r--src/util/entities/Note.ts (renamed from util/src/entities/Note.ts)0
-rw-r--r--src/util/entities/RateLimit.ts (renamed from util/src/entities/RateLimit.ts)0
-rw-r--r--src/util/entities/ReadState.ts (renamed from util/src/entities/ReadState.ts)0
-rw-r--r--src/util/entities/Recipient.ts (renamed from util/src/entities/Recipient.ts)0
-rw-r--r--src/util/entities/Relationship.ts (renamed from util/src/entities/Relationship.ts)0
-rw-r--r--src/util/entities/Role.ts (renamed from util/src/entities/Role.ts)0
-rw-r--r--src/util/entities/Session.ts (renamed from util/src/entities/Session.ts)0
-rw-r--r--src/util/entities/Sticker.ts (renamed from util/src/entities/Sticker.ts)0
-rw-r--r--src/util/entities/StickerPack.ts (renamed from util/src/entities/StickerPack.ts)0
-rw-r--r--src/util/entities/Team.ts (renamed from util/src/entities/Team.ts)0
-rw-r--r--src/util/entities/TeamMember.ts (renamed from util/src/entities/TeamMember.ts)0
-rw-r--r--src/util/entities/Template.ts (renamed from util/src/entities/Template.ts)0
-rw-r--r--src/util/entities/User.ts (renamed from util/src/entities/User.ts)164
-rw-r--r--src/util/entities/UserGroup.ts (renamed from util/src/entities/UserGroup.ts)0
-rw-r--r--src/util/entities/UserSettings.ts119
-rw-r--r--src/util/entities/VoiceState.ts (renamed from util/src/entities/VoiceState.ts)0
-rw-r--r--src/util/entities/Webhook.ts (renamed from util/src/entities/Webhook.ts)0
-rw-r--r--src/util/entities/index.ts (renamed from util/src/entities/index.ts)1
-rw-r--r--src/util/index.ts (renamed from util/src/index.ts)4
-rw-r--r--src/util/interfaces/Activity.ts (renamed from util/src/interfaces/Activity.ts)0
-rw-r--r--src/util/interfaces/Event.ts (renamed from util/src/interfaces/Event.ts)4
-rw-r--r--src/util/interfaces/Interaction.ts (renamed from util/src/interfaces/Interaction.ts)0
-rw-r--r--src/util/interfaces/Presence.ts (renamed from util/src/interfaces/Presence.ts)0
-rw-r--r--src/util/interfaces/Status.ts (renamed from util/src/interfaces/Status.ts)0
-rw-r--r--src/util/interfaces/index.ts (renamed from util/src/interfaces/index.ts)0
-rw-r--r--src/util/migrations/mariadb/1659901151025-initial.ts (renamed from util/src/migrations/mariadb/1659901151025-initial.ts)0
-rw-r--r--src/util/migrations/mariadb/1659921859145-premium_since_as_date.ts (renamed from util/src/migrations/mariadb/1659921859145-premium_since_as_date.ts)0
-rw-r--r--src/util/migrations/mariadb/1660130586602-updated-applications.ts (renamed from util/src/migrations/mariadb/1660130586602-updated-applications.ts)0
-rw-r--r--src/util/migrations/mariadb/1660131942703-apps_nullable_team.ts (renamed from util/src/migrations/mariadb/1660131942703-apps_nullable_team.ts)0
-rw-r--r--src/util/migrations/mariadb/1660540527213-sync_migrations.ts127
-rw-r--r--src/util/migrations/mariadb/1660549252130-fix_nullables.ts30
-rw-r--r--src/util/migrations/postgres/1659899687168-initial.ts (renamed from util/src/migrations/postgres/1659899687168-initial.ts)0
-rw-r--r--src/util/migrations/postgres/1659921826567-premium_since_as_date.ts (renamed from util/src/migrations/postgres/1659921826567-premium_since_as_date.ts)0
-rw-r--r--src/util/migrations/postgres/1660130561959-updated-applications.ts (renamed from util/src/migrations/postgres/1660130561959-updated-applications.ts)0
-rw-r--r--src/util/migrations/postgres/1660257815436-CodeCleanup2.ts59
-rw-r--r--src/util/migrations/postgres/1660258372154-CodeCleanup3.ts19
-rw-r--r--src/util/migrations/postgres/1660260565996-CodeCleanup4.ts33
-rw-r--r--src/util/migrations/postgres/1660265907544-CodeCleanup5.ts26
-rw-r--r--src/util/migrations/postgres/1660416055566-InvitersAreDeletable.ts (renamed from util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts)0
-rw-r--r--src/util/migrations/postgres/1660549242936-fix_nullables.ts30
-rw-r--r--src/util/migrations/sqlite/1659899662635-initial.ts (renamed from util/src/migrations/sqlite/1659899662635-initial.ts)0
-rw-r--r--src/util/migrations/sqlite/1659921722863-premium_since_as_date.ts (renamed from util/src/migrations/sqlite/1659921722863-premium_since_as_date.ts)0
-rw-r--r--src/util/migrations/sqlite/1660130536131-updated-applications.ts (renamed from util/src/migrations/sqlite/1660130536131-updated-applications.ts)0
-rw-r--r--src/util/migrations/sqlite/1660257576211-CodeCleanup1.ts326
-rw-r--r--src/util/migrations/sqlite/1660257795259-CodeCleanup2.ts572
-rw-r--r--src/util/migrations/sqlite/1660258351379-CodeCleanup3.ts231
-rw-r--r--src/util/migrations/sqlite/1660260672914-CodeCleanup4.ts459
-rw-r--r--src/util/migrations/sqlite/1660416010862-InvitersAreDeletable.ts (renamed from util/src/migrations/sqlite/1660416010862-InvitersAreDeletable.ts)0
-rw-r--r--src/util/migrations/sqlite/1660538628956-sync_migrations.ts172
-rw-r--r--src/util/migrations/sqlite/1660549233583-fix_nullables.ts240
-rw-r--r--src/util/schemas/ActivitySchema.ts (renamed from gateway/src/schema/Activity.ts)0
-rw-r--r--src/util/schemas/BanCreateSchema.ts5
-rw-r--r--src/util/schemas/BanModeratorSchema.ts8
-rw-r--r--src/util/schemas/BanRegistrySchema.ts9
-rw-r--r--src/util/schemas/BulkDeleteSchema.ts4
-rw-r--r--src/util/schemas/ChannelModifySchema.ts29
-rw-r--r--src/util/schemas/ChannelPermissionOverwriteSchema.ts5
-rw-r--r--src/util/schemas/ChannelReorderSchema.ts1
-rw-r--r--src/util/schemas/DmChannelCreateSchema.ts5
-rw-r--r--src/util/schemas/EmojiCreateSchema.ts7
-rw-r--r--src/util/schemas/EmojiModifySchema.ts5
-rw-r--r--src/util/schemas/GuildCreateSchema.ts14
-rw-r--r--src/util/schemas/GuildTemplateCreateSchema.ts5
-rw-r--r--src/util/schemas/GuildUpdateSchema.ts18
-rw-r--r--src/util/schemas/GuildUpdateWelcomeScreenSchema.ts11
-rw-r--r--src/util/schemas/IdentifySchema.ts (renamed from gateway/src/schema/Identify.ts)10
-rw-r--r--src/util/schemas/InviteCreateSchema.ts12
-rw-r--r--src/util/schemas/LazyRequestSchema.ts (renamed from gateway/src/schema/LazyRequest.ts)0
-rw-r--r--src/util/schemas/LoginSchema.ts9
-rw-r--r--src/util/schemas/MemberChangeSchema.ts4
-rw-r--r--src/util/schemas/MemberNickChangeSchema.ts4
-rw-r--r--src/util/schemas/MessageAcknowledgeSchema.ts8
-rw-r--r--src/util/schemas/MessageCreateSchema.ts34
-rw-r--r--src/util/schemas/MfaCodesSchema.ts5
-rw-r--r--src/util/schemas/ModifyGuildStickerSchema.ts16
-rw-r--r--src/util/schemas/PruneSchema.ts7
-rw-r--r--src/util/schemas/PurgeSchema.ts5
-rw-r--r--src/util/schemas/RegisterSchema.ts27
-rw-r--r--src/util/schemas/RelationshipPostSchema.ts5
-rw-r--r--src/util/schemas/RelationshipPutSchema.ts6
-rw-r--r--src/util/schemas/RoleModifySchema.ts11
-rw-r--r--src/util/schemas/RolePositionUpdateSchema.ts4
-rw-r--r--src/util/schemas/TemplateCreateSchema.ts5
-rw-r--r--src/util/schemas/TemplateModifySchema.ts5
-rw-r--r--src/util/schemas/TotpDisableSchema.ts4
-rw-r--r--src/util/schemas/TotpEnableSchema.ts6
-rw-r--r--src/util/schemas/TotpSchema.ts7
-rw-r--r--src/util/schemas/UserModifySchema.ts19
-rw-r--r--src/util/schemas/UserSettingsSchema.ts4
-rw-r--r--src/util/schemas/VanityUrlSchema.ts8
-rw-r--r--src/util/schemas/VoiceStateUpdateSchema.ts18
-rw-r--r--src/util/schemas/WebhookCreateSchema.ts8
-rw-r--r--src/util/schemas/WidgetModifySchema.ts5
-rw-r--r--src/util/schemas/index.ts43
-rw-r--r--src/util/util/ApiError.ts (renamed from util/src/util/ApiError.ts)0
-rw-r--r--src/util/util/Array.ts (renamed from util/src/util/Array.ts)0
-rw-r--r--src/util/util/AutoUpdate.ts (renamed from util/src/util/AutoUpdate.ts)0
-rw-r--r--src/util/util/BitField.ts (renamed from util/src/util/BitField.ts)0
-rw-r--r--src/util/util/Categories.ts (renamed from util/src/util/Categories.ts)0
-rw-r--r--src/util/util/Config.ts (renamed from util/src/util/Config.ts)38
-rw-r--r--src/util/util/Constants.ts (renamed from util/src/util/Constants.ts)0
-rw-r--r--src/util/util/Database.ts (renamed from util/src/util/Database.ts)0
-rw-r--r--src/util/util/Email.ts (renamed from util/src/util/Email.ts)0
-rw-r--r--src/util/util/Event.ts (renamed from util/src/util/Event.ts)0
-rw-r--r--src/util/util/FieldError.ts (renamed from util/src/util/FieldError.ts)0
-rw-r--r--src/util/util/Intents.ts (renamed from util/src/util/Intents.ts)0
-rw-r--r--src/util/util/InvisibleCharacters.ts (renamed from util/src/util/InvisibleCharacters.ts)0
-rw-r--r--src/util/util/MFA.ts (renamed from util/src/util/MFA.ts)0
-rw-r--r--src/util/util/MessageFlags.ts (renamed from util/src/util/MessageFlags.ts)0
-rw-r--r--src/util/util/Permissions.ts (renamed from util/src/util/Permissions.ts)0
-rw-r--r--src/util/util/RabbitMQ.ts (renamed from util/src/util/RabbitMQ.ts)0
-rw-r--r--src/util/util/Regex.ts (renamed from util/src/util/Regex.ts)0
-rw-r--r--src/util/util/Rights.ts (renamed from util/src/util/Rights.ts)0
-rw-r--r--src/util/util/Snowflake.ts (renamed from util/src/util/Snowflake.ts)0
-rw-r--r--src/util/util/String.ts (renamed from util/src/util/String.ts)0
-rw-r--r--src/util/util/Token.ts (renamed from util/src/util/Token.ts)0
-rw-r--r--src/util/util/TraverseDirectory.ts (renamed from util/src/util/TraverseDirectory.ts)0
-rw-r--r--src/util/util/cdn.ts (renamed from util/src/util/cdn.ts)0
-rw-r--r--src/util/util/imports/Checks.ts (renamed from util/src/util/imports/Checks.ts)0
-rw-r--r--src/util/util/imports/HTTPError.ts (renamed from util/src/util/imports/HTTPError.ts)0
-rw-r--r--src/util/util/imports/OrmUtils.ts (renamed from util/src/util/imports/OrmUtils.ts)0
-rw-r--r--src/util/util/imports/index.ts (renamed from util/src/util/imports/index.ts)0
-rw-r--r--src/util/util/index.ts (renamed from util/src/util/index.ts)0
379 files changed, 3538 insertions, 659 deletions
diff --git a/bundle/src/Server.ts b/src/Server.ts

index 3ed98b15..4d5d6422 100644 --- a/bundle/src/Server.ts +++ b/src/Server.ts
@@ -10,6 +10,7 @@ import { green, bold, yellow } from "picocolors"; import { Config, getOrInitialiseDatabase } from "@fosscord/util"; import * as Sentry from "@sentry/node"; import * as Tracing from "@sentry/tracing"; +// import { PluginLoader } from "@fosscord/util"; const app = express(); const server = http.createServer(); @@ -94,6 +95,7 @@ async function main() { }); } console.log(`[Server] ${green(`listening on port ${bold(port)}`)}`); + // PluginLoader.loadPlugins(); } main().catch(console.error); diff --git a/api/src/Server.ts b/src/api/Server.ts
index 136f9814..136f9814 100644 --- a/api/src/Server.ts +++ b/src/api/Server.ts
diff --git a/api/src/global.d.ts b/src/api/global.d.ts
index 7751af8f..7751af8f 100644 --- a/api/src/global.d.ts +++ b/src/api/global.d.ts
diff --git a/api/src/index.ts b/src/api/index.ts
index adc7649c..adc7649c 100644 --- a/api/src/index.ts +++ b/src/api/index.ts
diff --git a/api/src/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts
index 2d9ccf57..2d9ccf57 100644 --- a/api/src/middlewares/Authentication.ts +++ b/src/api/middlewares/Authentication.ts
diff --git a/api/src/middlewares/BodyParser.ts b/src/api/middlewares/BodyParser.ts
index 35db3c6f..35db3c6f 100644 --- a/api/src/middlewares/BodyParser.ts +++ b/src/api/middlewares/BodyParser.ts
diff --git a/api/src/middlewares/CORS.ts b/src/api/middlewares/CORS.ts
index 20260cf9..20260cf9 100644 --- a/api/src/middlewares/CORS.ts +++ b/src/api/middlewares/CORS.ts
diff --git a/api/src/middlewares/ErrorHandler.ts b/src/api/middlewares/ErrorHandler.ts
index 8a046e06..8a046e06 100644 --- a/api/src/middlewares/ErrorHandler.ts +++ b/src/api/middlewares/ErrorHandler.ts
diff --git a/api/src/middlewares/RateLimit.ts b/src/api/middlewares/RateLimit.ts
index 47180b62..47180b62 100644 --- a/api/src/middlewares/RateLimit.ts +++ b/src/api/middlewares/RateLimit.ts
diff --git a/api/src/middlewares/TestClient.ts b/src/api/middlewares/TestClient.ts
index 4fe631cb..c8ea57f6 100644 --- a/api/src/middlewares/TestClient.ts +++ b/src/api/middlewares/TestClient.ts
@@ -7,11 +7,13 @@ import { Config } from "@fosscord/util"; import { AssetCacheItem } from "../util/entities/AssetCacheItem" import { green } from "picocolors"; +const AssetsPath = path.join(__dirname, "..", "..", "..", "assets") + export default function TestClient(app: Application) { const agent = new ProxyAgent(); //build client page - let html = fs.readFileSync(path.join(__dirname, "..", "..", "client_test", "index.html"), { encoding: "utf8" }); + let html = fs.readFileSync(path.join(AssetsPath, "index.html"), { encoding: "utf8" }); html = applyEnv(html); html = applyInlinePlugins(html); html = applyPlugins(html); @@ -19,7 +21,7 @@ export default function TestClient(app: Application) { //load asset cache let newAssetCache: Map<string, AssetCacheItem> = new Map<string, AssetCacheItem>(); - let assetCacheDir = path.join(__dirname, "..", "..", "assets", "cache"); + let assetCacheDir = path.join(AssetsPath, "cache"); if(process.env.ASSET_CACHE_DIR) assetCacheDir = process.env.ASSET_CACHE_DIR @@ -32,7 +34,7 @@ export default function TestClient(app: Application) { newAssetCache = new Map<string, AssetCacheItem>(Object.entries(JSON.parse(rawdata.toString()))); } - app.use("/assets", express.static(path.join(__dirname, "..", "..", "assets"))); + app.use("/assets", express.static(path.join(AssetsPath))); app.get("/assets/:file", async (req: Request, res: Response) => { delete req.headers.host; let response: FetchResponse; @@ -77,7 +79,7 @@ export default function TestClient(app: Application) { if(!useTestClient) return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.") - res.send(fs.readFileSync(path.join(__dirname, "..", "..", "client_test", "developers.html"), { encoding: "utf8" })); + res.send(fs.readFileSync(path.join(__dirname, "..", "..", "..", "assets", "developers.html"), { encoding: "utf8" })); }); app.get("*", (req: Request, res: Response) => { const { useTestClient } = Config.get().client; @@ -113,7 +115,7 @@ function applyEnv(html: string): string { function applyPlugins(html: string): string { // plugins - let files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "plugins")); + let files = fs.readdirSync(path.join(AssetsPath, "plugins")); let plugins = ""; files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script src='/assets/plugins/${x}'></script>\n`; }); return html.replaceAll("<!-- plugin marker -->", plugins); @@ -121,7 +123,7 @@ function applyPlugins(html: string): string { function applyInlinePlugins(html: string): string{ // inline plugins - let files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "inline-plugins")); + let files = fs.readdirSync(path.join(AssetsPath, "inline-plugins")); let plugins = ""; files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script src='/assets/inline-plugins/${x}'></script>\n\n`; }); return html.replaceAll("<!-- inline plugin marker -->", plugins); @@ -129,9 +131,9 @@ function applyInlinePlugins(html: string): string{ function applyPreloadPlugins(html: string): string{ //preload plugins - let files = fs.readdirSync(path.join(__dirname, "..", "..", "assets", "preload-plugins")); + let files = fs.readdirSync(path.join(AssetsPath, "preload-plugins")); let plugins = ""; - files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script>${fs.readFileSync(path.join(__dirname, "..", "..", "assets", "preload-plugins", x))}</script>\n`; }); + files.forEach(x =>{if(x.endsWith(".js")) plugins += `<script>${fs.readFileSync(path.join(AssetsPath, "preload-plugins", x))}</script>\n`; }); return html.replaceAll("<!-- preload plugin marker -->", plugins); } diff --git a/api/src/middlewares/Translation.ts b/src/api/middlewares/Translation.ts
index baabf221..64b03bf8 100644 --- a/api/src/middlewares/Translation.ts +++ b/src/api/middlewares/Translation.ts
@@ -6,8 +6,8 @@ import i18nextBackend from "i18next-node-fs-backend"; import { Router } from "express"; export async function initTranslation(router: Router) { - const languages = fs.readdirSync(path.join(__dirname, "..", "..", "locales")); - const namespaces = fs.readdirSync(path.join(__dirname, "..", "..", "locales", "en")); + const languages = fs.readdirSync(path.join(__dirname, "..", "..", "..", "assets", "locales")); + const namespaces = fs.readdirSync(path.join(__dirname, "..", "..", "..", "assets", "locales", "en")); const ns = namespaces.filter((x) => x.endsWith(".json")).map((x) => x.slice(0, x.length - 5)); await i18next @@ -19,7 +19,7 @@ export async function initTranslation(router: Router) { fallbackLng: "en", ns, backend: { - loadPath: __dirname + "/../../locales/{{lng}}/{{ns}}.json" + loadPath: __dirname + "/../../../assets/locales/{{lng}}/{{ns}}.json" }, load: "all" }); diff --git a/api/src/middlewares/index.ts b/src/api/middlewares/index.ts
index f0c50dbe..f0c50dbe 100644 --- a/api/src/middlewares/index.ts +++ b/src/api/middlewares/index.ts
diff --git a/api/src/routes/-/healthz.ts b/src/api/routes/-/healthz.ts
index f7bcfebf..f7bcfebf 100644 --- a/api/src/routes/-/healthz.ts +++ b/src/api/routes/-/healthz.ts
diff --git a/api/src/routes/-/readyz.ts b/src/api/routes/-/readyz.ts
index f7bcfebf..f7bcfebf 100644 --- a/api/src/routes/-/readyz.ts +++ b/src/api/routes/-/readyz.ts
diff --git a/api/src/routes/applications/#id/bot/index.ts b/src/api/routes/applications/#id/bot/index.ts
index 5cae5215..5cae5215 100644 --- a/api/src/routes/applications/#id/bot/index.ts +++ b/src/api/routes/applications/#id/bot/index.ts
diff --git a/api/src/routes/applications/#id/entitlements.ts b/src/api/routes/applications/#id/entitlements.ts
index cfcfe40f..cfcfe40f 100644 --- a/api/src/routes/applications/#id/entitlements.ts +++ b/src/api/routes/applications/#id/entitlements.ts
diff --git a/api/src/routes/applications/#id/index.ts b/src/api/routes/applications/#id/index.ts
index 0aced582..0aced582 100644 --- a/api/src/routes/applications/#id/index.ts +++ b/src/api/routes/applications/#id/index.ts
diff --git a/api/src/routes/applications/#id/skus.ts b/src/api/routes/applications/#id/skus.ts
index 5b667f36..5b667f36 100644 --- a/api/src/routes/applications/#id/skus.ts +++ b/src/api/routes/applications/#id/skus.ts
diff --git a/api/src/routes/applications/detectable.ts b/src/api/routes/applications/detectable.ts
index 28ce42da..28ce42da 100644 --- a/api/src/routes/applications/detectable.ts +++ b/src/api/routes/applications/detectable.ts
diff --git a/api/src/routes/applications/index.ts b/src/api/routes/applications/index.ts
index 033dcc51..033dcc51 100644 --- a/api/src/routes/applications/index.ts +++ b/src/api/routes/applications/index.ts
diff --git a/api/src/routes/auth/location-metadata.ts b/src/api/routes/auth/location-metadata.ts
index f4c2bd16..f4c2bd16 100644 --- a/api/src/routes/auth/location-metadata.ts +++ b/src/api/routes/auth/location-metadata.ts
diff --git a/api/src/routes/auth/login.ts b/src/api/routes/auth/login.ts
index daef6056..9fc5924d 100644 --- a/api/src/routes/auth/login.ts +++ b/src/api/routes/auth/login.ts
@@ -1,21 +1,12 @@ import { Request, Response, Router } from "express"; import { route } from "@fosscord/api"; import bcrypt from "bcrypt"; -import { Config, User, generateToken, adjustEmail, FieldErrors } from "@fosscord/util"; +import { Config, User, generateToken, adjustEmail, FieldErrors, LoginSchema } from "@fosscord/util"; import crypto from "crypto"; const router: Router = Router(); export default router; -export interface LoginSchema { - login: string; - password: string; - undelete?: boolean; - captcha_key?: string; - login_source?: string; - gift_code_sku_id?: string; -} - router.post("/", route({ body: "LoginSchema" }), async (req: Request, res: Response) => { const { login, password, captcha_key, undelete } = req.body as LoginSchema; const email = adjustEmail(login); diff --git a/api/src/routes/auth/mfa/totp.ts b/src/api/routes/auth/mfa/totp.ts
index 255cf889..421dbafa 100644 --- a/api/src/routes/auth/mfa/totp.ts +++ b/src/api/routes/auth/mfa/totp.ts
@@ -1,17 +1,10 @@ import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; -import { BackupCode, FieldErrors, generateToken, User } from "@fosscord/util"; +import { BackupCode, FieldErrors, generateToken, TotpSchema, User } from "@fosscord/util"; import { verifyToken } from "node-2fa"; import { HTTPError } from "lambert-server"; const router = Router(); -export interface TotpSchema { - code: string, - ticket: string, - gift_code_sku_id?: string | null, - login_source?: string | null, -} - router.post("/", route({ body: "TotpSchema" }), async (req: Request, res: Response) => { const { code, ticket, gift_code_sku_id, login_source } = req.body as TotpSchema; diff --git a/api/src/routes/auth/register.ts b/src/api/routes/auth/register.ts
index 2baef98e..09366a12 100644 --- a/api/src/routes/auth/register.ts +++ b/src/api/routes/auth/register.ts
@@ -1,37 +1,11 @@ import { Request, Response, Router } from "express"; -import { Config, generateToken, Invite, FieldErrors, User, adjustEmail, trimSpecial } from "@fosscord/util"; +import { Config, generateToken, Invite, FieldErrors, User, adjustEmail, trimSpecial, RegisterSchema } from "@fosscord/util"; import { route, getIpAdress, IPAnalysis, isProxy } from "@fosscord/api"; import bcrypt from "bcrypt"; import { HTTPError } from "@fosscord/util"; const router: Router = Router(); -export interface RegisterSchema { - /** - * @minLength 2 - * @maxLength 32 - */ - username: string; - /** - * @minLength 1 - * @maxLength 72 - */ - password?: string; - consent: boolean; - /** - * @TJS-format email - */ - email?: string; - fingerprint?: string; - invite?: string; - /** - * @TJS-type string - */ - date_of_birth?: Date; // "2000-04-03" - gift_code_sku_id?: string; - captcha_key?: string; -} - router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Response) => { const body = req.body as RegisterSchema; const { register, security } = Config.get(); diff --git a/api/src/routes/channels/#channel_id/followers.ts b/src/api/routes/channels/#channel_id/followers.ts
index 641af4f8..641af4f8 100644 --- a/api/src/routes/channels/#channel_id/followers.ts +++ b/src/api/routes/channels/#channel_id/followers.ts
diff --git a/api/src/routes/channels/#channel_id/index.ts b/src/api/routes/channels/#channel_id/index.ts
index 68b52be6..bb8b868b 100644 --- a/api/src/routes/channels/#channel_id/index.ts +++ b/src/api/routes/channels/#channel_id/index.ts
@@ -6,7 +6,8 @@ import { ChannelUpdateEvent, emitEvent, Recipient, - handleFile + handleFile, + ChannelModifySchema } from "@fosscord/util"; import { Request, Response, Router } from "express"; import { route } from "@fosscord/api"; @@ -48,31 +49,6 @@ router.delete("/", route({ permission: "MANAGE_CHANNELS" }), async (req: Request res.send(channel); }); -export interface ChannelModifySchema { - /** - * @maxLength 100 - */ - name?: string; - type?: ChannelType; - topic?: string; - icon?: string | null; - bitrate?: number; - user_limit?: number; - rate_limit_per_user?: number; - position?: number; - permission_overwrites?: { - id: string; - type: ChannelPermissionOverwriteType; - allow: string; - deny: string; - }[]; - parent_id?: string; - id?: string; // is not used (only for guild create) - nsfw?: boolean; - rtc_region?: string; - default_auto_archive_duration?: number; -} - router.patch("/", route({ body: "ChannelModifySchema", permission: "MANAGE_CHANNELS" }), async (req: Request, res: Response) => { let payload = req.body as ChannelModifySchema; const { channel_id } = req.params; diff --git a/api/src/routes/channels/#channel_id/invites.ts b/src/api/routes/channels/#channel_id/invites.ts
index a53b1de4..b5c65c0d 100644 --- a/api/src/routes/channels/#channel_id/invites.ts +++ b/src/api/routes/channels/#channel_id/invites.ts
@@ -8,18 +8,6 @@ import { OrmUtils } from "@fosscord/util"; const router: Router = Router(); -export interface InviteCreateSchema { - target_user_id?: string; - target_type?: string; - validate?: string; // ? what is this - max_age?: number; - max_uses?: number; - temporary?: boolean; - unique?: boolean; - target_user?: string; - target_user_type?: number; -} - router.post("/", route({ body: "InviteCreateSchema", permission: "CREATE_INSTANT_INVITE", right: "CREATE_INVITES" }), async (req: Request, res: Response) => { const { user_id } = req; @@ -35,15 +23,12 @@ router.post("/", route({ body: "InviteCreateSchema", permission: "CREATE_INSTANT const expires_at = new Date(req.body.max_age * 1000 + Date.now()); const invite = await OrmUtils.mergeDeep(new Invite(),{ - code: random(), - temporary: req.body.temporary, - uses: 0, + temporary: req.body.temporary || true, max_uses: req.body.max_uses, max_age: req.body.max_age, expires_at, - created_at: new Date(), guild_id, - channel_id: channel_id, + channel_id, inviter_id: user_id }).save(); //TODO: check this, removed toJSON call @@ -57,7 +42,6 @@ router.post("/", route({ body: "InviteCreateSchema", permission: "CREATE_INSTANT }); router.get("/", route({ permission: "MANAGE_CHANNELS" }), async (req: Request, res: Response) => { - const { user_id } = req; const { channel_id } = req.params; const channel = await Channel.findOneOrFail({ where: { id: channel_id } }); diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts b/src/api/routes/channels/#channel_id/messages/#message_id/ack.ts
index c1b8d20f..041f4d5e 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts +++ b/src/api/routes/channels/#channel_id/messages/#message_id/ack.ts
@@ -5,15 +5,6 @@ import { OrmUtils } from "@fosscord/util"; const router = Router(); -// TODO: public read receipts & privacy scoping -// TODO: send read state event to all channel members -// TODO: advance-only notification cursor - -export interface MessageAcknowledgeSchema { - manual?: boolean; - mention_count?: number; -} - router.post("/", route({ body: "MessageAcknowledgeSchema" }), async (req: Request, res: Response) => { const { channel_id, message_id } = req.params; diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts b/src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts
index b2cb6763..b2cb6763 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts +++ b/src/api/routes/channels/#channel_id/messages/#message_id/crosspost.ts
diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts b/src/api/routes/channels/#channel_id/messages/#message_id/index.ts
index b3b310d3..d7e27062 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts +++ b/src/api/routes/channels/#channel_id/messages/#message_id/index.ts
@@ -12,13 +12,13 @@ import { MessageDeleteEvent, MessageUpdateEvent, Snowflake, - uploadFile + uploadFile, + MessageCreateSchema } from "@fosscord/util"; import { Router, Response, Request } from "express"; import multer from "multer"; import { route } from "@fosscord/api"; import { handleMessage, postHandleMessage } from "@fosscord/api"; -import { MessageCreateSchema } from "../index"; import { HTTPError } from "@fosscord/util"; const router = Router(); diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts b/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
index d0ab35bb..d0ab35bb 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts +++ b/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
diff --git a/api/src/routes/channels/#channel_id/messages/bulk-delete.ts b/src/api/routes/channels/#channel_id/messages/bulk-delete.ts
index 2e40f110..af44b522 100644 --- a/api/src/routes/channels/#channel_id/messages/bulk-delete.ts +++ b/src/api/routes/channels/#channel_id/messages/bulk-delete.ts
@@ -8,16 +8,12 @@ const router: Router = Router(); export default router; -export interface BulkDeleteSchema { - messages: string[]; -} - // should users be able to bulk delete messages or only bots? ANSWER: all users // should this request fail, if you provide messages older than 14 days/invalid ids? ANSWER: NO // https://discord.com/developers/docs/resources/channel#bulk-delete-messages router.post("/", route({ body: "BulkDeleteSchema" }), async (req: Request, res: Response) => { const { channel_id } = req.params; - const channel = await Channel.findOneByOrFail({ id: channel_id }); + const channel = await Channel.findOneOrFail({where:{ id: channel_id} }); if (!channel.guild_id) throw new HTTPError("Can't bulk delete dm channel messages", 400); const rights = await getRights(req.user_id); diff --git a/api/src/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts
index c2057422..9ab0d97d 100644 --- a/api/src/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -5,7 +5,6 @@ import { ChannelType, Config, DmChannelDTO, - Embed, emitEvent, getPermission, getRights, @@ -13,7 +12,8 @@ import { MessageCreateEvent, Snowflake, uploadFile, - Member + Member, + MessageCreateSchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { handleMessage, postHandleMessage, route } from "@fosscord/api"; @@ -49,38 +49,6 @@ export function isTextChannel(type: ChannelType): boolean { } } -export interface MessageCreateSchema { - type?: number; - content?: string; - nonce?: string; - channel_id?: string; - tts?: boolean; - flags?: string; - embeds?: Embed[]; - embed?: Embed; - // TODO: ^ embed is deprecated in favor of embeds (https://discord.com/developers/docs/resources/channel#message-object) - allowed_mentions?: { - parse?: string[]; - roles?: string[]; - users?: string[]; - replied_user?: boolean; - }; - message_reference?: { - message_id: string; - channel_id: string; - guild_id?: string; - fail_if_not_exists?: boolean; - }; - payload_json?: string; - file?: any; - /** - TODO: we should create an interface for attachments - TODO: OpenWAAO<-->attachment-style metadata conversion - **/ - attachments?: any[]; - sticker_ids?: string[]; -} - // https://discord.com/developers/docs/resources/channel#create-message // get messages router.get("/", async (req: Request, res: Response) => { diff --git a/api/src/routes/channels/#channel_id/permissions.ts b/src/api/routes/channels/#channel_id/permissions.ts
index 06a124bb..34052fe5 100644 --- a/api/src/routes/channels/#channel_id/permissions.ts +++ b/src/api/routes/channels/#channel_id/permissions.ts
@@ -1,6 +1,7 @@ import { Channel, ChannelPermissionOverwrite, + ChannelPermissionOverwriteSchema, ChannelPermissionOverwriteType, ChannelUpdateEvent, emitEvent, @@ -10,13 +11,9 @@ import { } from "@fosscord/util"; import { Router, Response, Request } from "express"; import { HTTPError } from "@fosscord/util"; - import { route } from "@fosscord/api"; -const router: Router = Router(); -// TODO: Only permissions your bot has in the guild or channel can be allowed/denied (unless your bot has a MANAGE_ROLES overwrite in the channel) - -export interface ChannelPermissionOverwriteSchema extends ChannelPermissionOverwrite {} +const router: Router = Router(); router.put( "/:overwrite_id", diff --git a/api/src/routes/channels/#channel_id/pins.ts b/src/api/routes/channels/#channel_id/pins.ts
index 003638c5..003638c5 100644 --- a/api/src/routes/channels/#channel_id/pins.ts +++ b/src/api/routes/channels/#channel_id/pins.ts
diff --git a/api/src/routes/channels/#channel_id/purge.ts b/src/api/routes/channels/#channel_id/purge.ts
index 7ab4ad9a..1ef6e1d7 100644 --- a/api/src/routes/channels/#channel_id/purge.ts +++ b/src/api/routes/channels/#channel_id/purge.ts
@@ -1,4 +1,4 @@ -import { HTTPError } from "@fosscord/util"; +import { HTTPError, PurgeSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; import { isTextChannel } from "./messages"; import { FindManyOptions, Between, Not } from "typeorm"; @@ -10,11 +10,6 @@ const router: Router = Router(); export default router; -export interface PurgeSchema { - before: string; - after: string; -} - /** TODO: apply the delete bit by bit to prevent client and database stress **/ diff --git a/api/src/routes/channels/#channel_id/recipients.ts b/src/api/routes/channels/#channel_id/recipients.ts
index 069212e2..069212e2 100644 --- a/api/src/routes/channels/#channel_id/recipients.ts +++ b/src/api/routes/channels/#channel_id/recipients.ts
diff --git a/api/src/routes/channels/#channel_id/typing.ts b/src/api/routes/channels/#channel_id/typing.ts
index 99460f6e..99460f6e 100644 --- a/api/src/routes/channels/#channel_id/typing.ts +++ b/src/api/routes/channels/#channel_id/typing.ts
diff --git a/api/src/routes/channels/#channel_id/webhooks.ts b/src/api/routes/channels/#channel_id/webhooks.ts
index 8f0e0a7f..b11c8eb9 100644 --- a/api/src/routes/channels/#channel_id/webhooks.ts +++ b/src/api/routes/channels/#channel_id/webhooks.ts
@@ -6,14 +6,6 @@ import { isTextChannel } from "./messages/index"; import { DiscordApiErrors } from "@fosscord/util"; const router: Router = Router(); -// TODO: webhooks -export interface WebhookCreateSchema { - /** - * @maxLength 80 - */ - name: string; - avatar: string; -} //TODO: implement webhooks router.get("/", route({}), async (req: Request, res: Response) => { res.json([]); @@ -36,6 +28,7 @@ router.post("/", route({ body: "WebhookCreateSchema", permission: "MANAGE_WEBHOO if (name === "clyde") throw new HTTPError("Invalid name", 400); // TODO: save webhook in database and send response + res.json(new Webhook()); }); export default router; diff --git a/api/src/routes/discoverable-guilds.ts b/src/api/routes/discoverable-guilds.ts
index 35ecf28c..35ecf28c 100644 --- a/api/src/routes/discoverable-guilds.ts +++ b/src/api/routes/discoverable-guilds.ts
diff --git a/api/src/routes/discovery.ts b/src/api/routes/discovery.ts
index 30c418c6..30c418c6 100644 --- a/api/src/routes/discovery.ts +++ b/src/api/routes/discovery.ts
diff --git a/api/src/routes/downloads.ts b/src/api/routes/downloads.ts
index 44530353..44530353 100644 --- a/api/src/routes/downloads.ts +++ b/src/api/routes/downloads.ts
diff --git a/api/src/routes/experiments.ts b/src/api/routes/experiments.ts
index fcbd9271..fcbd9271 100644 --- a/api/src/routes/experiments.ts +++ b/src/api/routes/experiments.ts
diff --git a/api/src/routes/gateway/bot.ts b/src/api/routes/gateway/bot.ts
index f1dbb9df..f1dbb9df 100644 --- a/api/src/routes/gateway/bot.ts +++ b/src/api/routes/gateway/bot.ts
diff --git a/api/src/routes/gateway/index.ts b/src/api/routes/gateway/index.ts
index 9bad7478..9bad7478 100644 --- a/api/src/routes/gateway/index.ts +++ b/src/api/routes/gateway/index.ts
diff --git a/api/src/routes/gifs/search.ts b/src/api/routes/gifs/search.ts
index 1099dc4a..1099dc4a 100644 --- a/api/src/routes/gifs/search.ts +++ b/src/api/routes/gifs/search.ts
diff --git a/api/src/routes/gifs/trending-gifs.ts b/src/api/routes/gifs/trending-gifs.ts
index 2b28d9d2..2b28d9d2 100644 --- a/api/src/routes/gifs/trending-gifs.ts +++ b/src/api/routes/gifs/trending-gifs.ts
diff --git a/api/src/routes/gifs/trending.ts b/src/api/routes/gifs/trending.ts
index 61eb76c4..61eb76c4 100644 --- a/api/src/routes/gifs/trending.ts +++ b/src/api/routes/gifs/trending.ts
diff --git a/api/src/routes/guild-recommendations.ts b/src/api/routes/guild-recommendations.ts
index bd0140d6..bd0140d6 100644 --- a/api/src/routes/guild-recommendations.ts +++ b/src/api/routes/guild-recommendations.ts
diff --git a/api/src/routes/guilds/#guild_id/audit-logs.ts b/src/api/routes/guilds/#guild_id/audit-logs.ts
index 7b1d0062..b54835fc 100644 --- a/api/src/routes/guilds/#guild_id/audit-logs.ts +++ b/src/api/routes/guilds/#guild_id/audit-logs.ts
@@ -1,8 +1,5 @@ import { Router, Response, Request } from "express"; -import { Channel, ChannelUpdateEvent, getPermission, emitEvent } from "@fosscord/util"; -import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { ChannelModifySchema } from "../../channels/#channel_id"; const router = Router(); //TODO: implement audit logs diff --git a/api/src/routes/guilds/#guild_id/bans.ts b/src/api/routes/guilds/#guild_id/bans.ts
index 0743687d..3d405344 100644 --- a/api/src/routes/guilds/#guild_id/bans.ts +++ b/src/api/routes/guilds/#guild_id/bans.ts
@@ -1,31 +1,9 @@ import { Request, Response, Router } from "express"; -import { DiscordApiErrors, emitEvent, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, Guild, Ban, User, Member } from "@fosscord/util"; +import { DiscordApiErrors, emitEvent, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, Guild, Ban, User, Member, BanRegistrySchema, BanModeratorSchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { getIpAdress, route } from "@fosscord/api"; import { OrmUtils } from "@fosscord/util"; -export interface BanCreateSchema { - delete_message_days?: string; - reason?: string; -}; - -export interface BanRegistrySchema { - id: string; - user_id: string; - guild_id: string; - executor_id: string; - ip?: string; - reason?: string | undefined; -}; - -export interface BanModeratorSchema { - id: string; - user_id: string; - guild_id: string; - executor_id: string; - reason?: string | undefined; -}; - const router: Router = Router(); /* TODO: Deleting the secrets is just a temporary go-around. Views should be implemented for both safety and better handling. */ diff --git a/api/src/routes/guilds/#guild_id/channels.ts b/src/api/routes/guilds/#guild_id/channels.ts
index b952b474..8f2d3643 100644 --- a/api/src/routes/guilds/#guild_id/channels.ts +++ b/src/api/routes/guilds/#guild_id/channels.ts
@@ -1,8 +1,7 @@ import { Router, Response, Request } from "express"; -import { Channel, ChannelUpdateEvent, getPermission, emitEvent } from "@fosscord/util"; +import { Channel, ChannelUpdateEvent, getPermission, emitEvent, ChannelModifySchema, ChannelReorderSchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { ChannelModifySchema } from "../../channels/#channel_id"; const router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { @@ -22,8 +21,6 @@ router.post("/", route({ body: "ChannelModifySchema", permission: "MANAGE_CHANNE res.status(201).json(channel); }); -export type ChannelReorderSchema = { id: string; position?: number; lock_permissions?: boolean; parent_id?: string }[]; - router.patch("/", route({ body: "ChannelReorderSchema", permission: "MANAGE_CHANNELS" }), async (req: Request, res: Response) => { // changes guild channel position const { guild_id } = req.params; diff --git a/api/src/routes/guilds/#guild_id/delete.ts b/src/api/routes/guilds/#guild_id/delete.ts
index e2624651..e2624651 100644 --- a/api/src/routes/guilds/#guild_id/delete.ts +++ b/src/api/routes/guilds/#guild_id/delete.ts
diff --git a/api/src/routes/guilds/#guild_id/discovery-requirements.ts b/src/api/routes/guilds/#guild_id/discovery-requirements.ts
index ad20633f..ad20633f 100644 --- a/api/src/routes/guilds/#guild_id/discovery-requirements.ts +++ b/src/api/routes/guilds/#guild_id/discovery-requirements.ts
diff --git a/api/src/routes/guilds/#guild_id/emojis.ts b/src/api/routes/guilds/#guild_id/emojis.ts
index 53a44ec3..4bf4bdcd 100644 --- a/api/src/routes/guilds/#guild_id/emojis.ts +++ b/src/api/routes/guilds/#guild_id/emojis.ts
@@ -1,22 +1,10 @@ import { Router, Request, Response } from "express"; -import { Config, DiscordApiErrors, emitEvent, Emoji, GuildEmojisUpdateEvent, handleFile, Member, Snowflake, User } from "@fosscord/util"; +import { Config, DiscordApiErrors, emitEvent, Emoji, EmojiCreateSchema, EmojiModifySchema, GuildEmojisUpdateEvent, handleFile, Member, Snowflake, User } from "@fosscord/util"; import { route } from "@fosscord/api"; import { OrmUtils } from "@fosscord/util"; const router = Router(); -export interface EmojiCreateSchema { - name?: string; - image: string; - require_colons?: boolean | null; - roles?: string[]; -} - -export interface EmojiModifySchema { - name?: string; - roles?: string[]; -} - router.get("/", route({}), async (req: Request, res: Response) => { const { guild_id } = req.params; diff --git a/api/src/routes/guilds/#guild_id/index.ts b/src/api/routes/guilds/#guild_id/index.ts
index abece88e..a9712c71 100644 --- a/api/src/routes/guilds/#guild_id/index.ts +++ b/src/api/routes/guilds/#guild_id/index.ts
@@ -1,28 +1,11 @@ import { Request, Response, Router } from "express"; -import { DiscordApiErrors, emitEvent, getPermission, getRights, Guild, GuildUpdateEvent, handleFile, Member } from "@fosscord/util"; +import { DiscordApiErrors, emitEvent, getPermission, getRights, Guild, GuildUpdateEvent, GuildUpdateSchema, handleFile, Member } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { GuildCreateSchema } from "../index"; import { OrmUtils } from "@fosscord/util"; const router = Router(); -export interface GuildUpdateSchema extends Omit<GuildCreateSchema, "channels" | "name"> { - name?: string; - banner?: string | null; - splash?: string | null; - description?: string; - features?: string[]; - verification_level?: number; - default_message_notifications?: number; - system_channel_flags?: number; - explicit_content_filter?: number; - public_updates_channel_id?: string; - afk_timeout?: number; - afk_channel_id?: string; - preferred_locale?: string; -} - router.get("/", route({}), async (req: Request, res: Response) => { const { guild_id } = req.params; diff --git a/api/src/routes/guilds/#guild_id/integrations.ts b/src/api/routes/guilds/#guild_id/integrations.ts
index 19f68563..90650111 100644 --- a/api/src/routes/guilds/#guild_id/integrations.ts +++ b/src/api/routes/guilds/#guild_id/integrations.ts
@@ -2,7 +2,6 @@ import { Router, Response, Request } from "express"; import { Channel, ChannelUpdateEvent, getPermission, emitEvent } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { ChannelModifySchema } from "../../channels/#channel_id"; const router = Router(); //TODO: implement integrations list diff --git a/api/src/routes/guilds/#guild_id/invites.ts b/src/api/routes/guilds/#guild_id/invites.ts
index b7534e31..b7534e31 100644 --- a/api/src/routes/guilds/#guild_id/invites.ts +++ b/src/api/routes/guilds/#guild_id/invites.ts
diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts b/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
index 824e34a4..794369d8 100644 --- a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts +++ b/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
@@ -1,15 +1,11 @@ import { Request, Response, Router } from "express"; -import { Member, getPermission, getRights, Role, GuildMemberUpdateEvent, emitEvent, Sticker, Emoji, Rights, Guild } from "@fosscord/util"; +import { Member, getPermission, getRights, Role, GuildMemberUpdateEvent, emitEvent, Sticker, Emoji, Rights, Guild, MemberChangeSchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; import { OrmUtils } from "@fosscord/util"; const router = Router(); -export interface MemberChangeSchema { - roles?: string[]; -} - router.get("/", route({}), async (req: Request, res: Response) => { const { guild_id, member_id } = req.params; await Member.IsInGuildOrFail(req.user_id, guild_id); diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/nick.ts b/src/api/routes/guilds/#guild_id/members/#member_id/nick.ts
index 4dfae8da..a6c71333 100644 --- a/api/src/routes/guilds/#guild_id/members/#member_id/nick.ts +++ b/src/api/routes/guilds/#guild_id/members/#member_id/nick.ts
@@ -4,10 +4,6 @@ import { Request, Response, Router } from "express"; const router = Router(); -export interface MemberNickChangeSchema { - nick: string; -} - router.patch("/", route({ body: "MemberNickChangeSchema" }), async (req: Request, res: Response) => { let { guild_id, member_id } = req.params; let permissionString: PermissionResolvable = "MANAGE_NICKNAMES"; diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts b/src/api/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts
index 8f5ca7ba..8f5ca7ba 100644 --- a/api/src/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts +++ b/src/api/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts
diff --git a/api/src/routes/guilds/#guild_id/members/index.ts b/src/api/routes/guilds/#guild_id/members/index.ts
index 2ed28bda..2ed28bda 100644 --- a/api/src/routes/guilds/#guild_id/members/index.ts +++ b/src/api/routes/guilds/#guild_id/members/index.ts
diff --git a/api/src/routes/guilds/#guild_id/premium.ts b/src/api/routes/guilds/#guild_id/premium.ts
index 75361ac6..75361ac6 100644 --- a/api/src/routes/guilds/#guild_id/premium.ts +++ b/src/api/routes/guilds/#guild_id/premium.ts
diff --git a/api/src/routes/guilds/#guild_id/prune.ts b/src/api/routes/guilds/#guild_id/prune.ts
index 01f18ce4..673f022f 100644 --- a/api/src/routes/guilds/#guild_id/prune.ts +++ b/src/api/routes/guilds/#guild_id/prune.ts
@@ -62,13 +62,6 @@ router.get("/", route({}), async (req: Request, res: Response) => { res.send({ pruned: members.length }); }); -export interface PruneSchema { - /** - * @min 0 - */ - days: number; -} - router.post("/", route({ permission: "KICK_MEMBERS", right: "KICK_BAN_MEMBERS" }), async (req: Request, res: Response) => { const days = parseInt(req.body.days); diff --git a/api/src/routes/guilds/#guild_id/regions.ts b/src/api/routes/guilds/#guild_id/regions.ts
index 308d5ee5..308d5ee5 100644 --- a/api/src/routes/guilds/#guild_id/regions.ts +++ b/src/api/routes/guilds/#guild_id/regions.ts
diff --git a/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts b/src/api/routes/guilds/#guild_id/roles/#role_id/index.ts
index 0482b9ca..d4422a9c 100644 --- a/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts +++ b/src/api/routes/guilds/#guild_id/roles/#role_id/index.ts
@@ -1,8 +1,7 @@ import { Router, Request, Response } from "express"; -import { Role, Member, GuildRoleUpdateEvent, GuildRoleDeleteEvent, emitEvent, handleFile } from "@fosscord/util"; +import { Role, Member, GuildRoleUpdateEvent, GuildRoleDeleteEvent, emitEvent, handleFile, RoleModifySchema } from "@fosscord/util"; import { route } from "@fosscord/api"; import { HTTPError } from "@fosscord/util"; -import { RoleModifySchema } from "../"; import { OrmUtils } from "@fosscord/util"; const router = Router(); diff --git a/api/src/routes/guilds/#guild_id/roles/index.ts b/src/api/routes/guilds/#guild_id/roles/index.ts
index 6fbb8702..17f0b5e9 100644 --- a/api/src/routes/guilds/#guild_id/roles/index.ts +++ b/src/api/routes/guilds/#guild_id/roles/index.ts
@@ -9,7 +9,9 @@ import { emitEvent, Config, DiscordApiErrors, - handleFile + handleFile, + RoleModifySchema, + RolePositionUpdateSchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; @@ -17,22 +19,6 @@ import { OrmUtils } from "@fosscord/util"; const router: Router = Router(); -export interface RoleModifySchema { - name?: string; - permissions?: string; - color?: number; - hoist?: boolean; // whether the role should be displayed separately in the sidebar - mentionable?: boolean; // whether the role should be mentionable - position?: number; - icon?: string; - unicode_emoji?: string; -} - -export type RolePositionUpdateSchema = { - id: string; - position: number; -}[]; - router.get("/", route({}), async (req: Request, res: Response) => { const guild_id = req.params.guild_id; diff --git a/api/src/routes/guilds/#guild_id/stickers.ts b/src/api/routes/guilds/#guild_id/stickers.ts
index 157ccff4..71c9dfcd 100644 --- a/api/src/routes/guilds/#guild_id/stickers.ts +++ b/src/api/routes/guilds/#guild_id/stickers.ts
@@ -3,6 +3,7 @@ import { GuildStickersUpdateEvent, handleFile, Member, + ModifyGuildStickerSchema, Snowflake, Sticker, StickerFormatType, @@ -83,22 +84,6 @@ router.get("/:sticker_id", route({}), async (req: Request, res: Response) => { res.json(await Sticker.findOneOrFail({ where: { guild_id, id: sticker_id } })); }); -export interface ModifyGuildStickerSchema { - /** - * @minLength 2 - * @maxLength 30 - */ - name: string; - /** - * @maxLength 100 - */ - description?: string; - /** - * @maxLength 200 - */ - tags: string; -} - router.patch( "/:sticker_id", route({ body: "ModifyGuildStickerSchema", permission: "MANAGE_EMOJIS_AND_STICKERS" }), diff --git a/api/src/routes/guilds/#guild_id/templates.ts b/src/api/routes/guilds/#guild_id/templates.ts
index 3d14de41..9c79692d 100644 --- a/api/src/routes/guilds/#guild_id/templates.ts +++ b/src/api/routes/guilds/#guild_id/templates.ts
@@ -24,16 +24,6 @@ const TemplateGuildProjection: (keyof Guild)[] = [ "icon" ]; -export interface TemplateCreateSchema { - name: string; - description?: string; -} - -export interface TemplateModifySchema { - name: string; - description?: string; -} - router.get("/", route({}), async (req: Request, res: Response) => { const { guild_id } = req.params; diff --git a/api/src/routes/guilds/#guild_id/vanity-url.ts b/src/api/routes/guilds/#guild_id/vanity-url.ts
index ac46e18a..ff92ce8d 100644 --- a/api/src/routes/guilds/#guild_id/vanity-url.ts +++ b/src/api/routes/guilds/#guild_id/vanity-url.ts
@@ -1,4 +1,4 @@ -import { Channel, ChannelType, getPermission, Guild, Invite, trimSpecial } from "@fosscord/util"; +import { Channel, ChannelType, getPermission, Guild, Invite, trimSpecial, VanityUrlSchema } from "@fosscord/util"; import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; import { HTTPError } from "@fosscord/util"; @@ -25,14 +25,6 @@ router.get("/", route({ permission: "MANAGE_GUILD" }), async (req: Request, res: } }); -export interface VanityUrlSchema { - /** - * @minLength 1 - * @maxLength 20 - */ - code?: string; -} - router.patch("/", route({ body: "VanityUrlSchema", permission: "MANAGE_GUILD" }), async (req: Request, res: Response) => { const { guild_id } = req.params; const body = req.body as VanityUrlSchema; diff --git a/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts b/src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts
index 32d1aadf..28a9e8c1 100644 --- a/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts +++ b/src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts
@@ -1,21 +1,9 @@ -import { Channel, ChannelType, DiscordApiErrors, emitEvent, getPermission, VoiceState, VoiceStateUpdateEvent } from "@fosscord/util"; +import { Channel, ChannelType, DiscordApiErrors, emitEvent, getPermission, VoiceState, VoiceStateUpdateEvent, VoiceStateUpdateSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; import { Request, Response, Router } from "express"; import { OrmUtils } from "@fosscord/util"; const router = Router(); -//TODO need more testing when community guild and voice stage channel are working - -export interface VoiceStateUpdateSchema { - channel_id: string; - guild_id?: string; - suppress?: boolean; - request_to_speak_timestamp?: Date; - self_mute?: boolean; - self_deaf?: boolean; - self_video?: boolean; -} - router.patch("/", route({ body: "VoiceStateUpdateSchema" }), async (req: Request, res: Response) => { const body = req.body as VoiceStateUpdateSchema; let { guild_id, user_id } = req.params; diff --git a/api/src/routes/guilds/#guild_id/webhooks.ts b/src/api/routes/guilds/#guild_id/webhooks.ts
index 7f5b9592..c8c1eb5c 100644 --- a/api/src/routes/guilds/#guild_id/webhooks.ts +++ b/src/api/routes/guilds/#guild_id/webhooks.ts
@@ -2,7 +2,6 @@ import { Router, Response, Request } from "express"; import { Channel, ChannelUpdateEvent, getPermission, emitEvent } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { ChannelModifySchema } from "../../channels/#channel_id"; const router = Router(); //TODO: implement webhooks diff --git a/api/src/routes/guilds/#guild_id/welcome_screen.ts b/src/api/routes/guilds/#guild_id/welcome_screen.ts
index 4093ec1d..d08300ba 100644 --- a/api/src/routes/guilds/#guild_id/welcome_screen.ts +++ b/src/api/routes/guilds/#guild_id/welcome_screen.ts
@@ -1,21 +1,10 @@ import { Request, Response, Router } from "express"; -import { Guild, getPermission, Snowflake, Member } from "@fosscord/util"; +import { Guild, getPermission, Snowflake, Member, GuildUpdateWelcomeScreenSchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; const router: Router = Router(); -export interface GuildUpdateWelcomeScreenSchema { - welcome_channels?: { - channel_id: string; - description: string; - emoji_id?: string; - emoji_name: string; - }[]; - enabled?: boolean; - description?: string; -} - router.get("/", route({}), async (req: Request, res: Response) => { const guild_id = req.params.guild_id; diff --git a/api/src/routes/guilds/#guild_id/widget.json.ts b/src/api/routes/guilds/#guild_id/widget.json.ts
index 37739418..37739418 100644 --- a/api/src/routes/guilds/#guild_id/widget.json.ts +++ b/src/api/routes/guilds/#guild_id/widget.json.ts
diff --git a/api/src/routes/guilds/#guild_id/widget.png.ts b/src/api/routes/guilds/#guild_id/widget.png.ts
index ec0ac85c..a61d938d 100644 --- a/api/src/routes/guilds/#guild_id/widget.png.ts +++ b/src/api/routes/guilds/#guild_id/widget.png.ts
@@ -34,7 +34,7 @@ router.get("/", route({}), async (req: Request, res: Response) => { const sizeOf = require("image-size"); // TODO: Widget style templates need Fosscord branding - const source = path.join(__dirname, "..", "..", "..", "..", "assets", "widget", `${style}.png`); + const source = path.join(__dirname, "..", "..", "..", "..", "..", "assets", "widget", `${style}.png`); if (!fs.existsSync(source)) { throw new HTTPError("Widget template does not exist.", 400); } diff --git a/api/src/routes/guilds/#guild_id/widget.ts b/src/api/routes/guilds/#guild_id/widget.ts
index 103f84a3..dbb4cc0c 100644 --- a/api/src/routes/guilds/#guild_id/widget.ts +++ b/src/api/routes/guilds/#guild_id/widget.ts
@@ -1,12 +1,7 @@ import { Request, Response, Router } from "express"; -import { Guild } from "@fosscord/util"; +import { Guild, WidgetModifySchema } from "@fosscord/util"; import { route } from "@fosscord/api"; -export interface WidgetModifySchema { - enabled: boolean; // whether the widget is enabled - channel_id: string; // the widget channel id -} - const router: Router = Router(); // https://discord.com/developers/docs/resources/guild#get-guild-widget-settings diff --git a/api/src/routes/guilds/index.ts b/src/api/routes/guilds/index.ts
index 64b9454b..e4d66192 100644 --- a/api/src/routes/guilds/index.ts +++ b/src/api/routes/guilds/index.ts
@@ -1,23 +1,9 @@ import { Router, Request, Response } from "express"; -import { Role, Guild, Snowflake, Config, getRights, Member, Channel, DiscordApiErrors, handleFile } from "@fosscord/util"; +import { Role, Guild, Snowflake, Config, getRights, Member, Channel, DiscordApiErrors, handleFile, GuildCreateSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { ChannelModifySchema } from "../channels/#channel_id"; const router: Router = Router(); -export interface GuildCreateSchema { - /** - * @maxLength 100 - */ - name: string; - region?: string; - icon?: string | null; - channels?: ChannelModifySchema[]; - guild_template_code?: string; - system_channel_id?: string; - rules_channel_id?: string; -} - //TODO: create default channel router.post("/", route({ body: "GuildCreateSchema", right: "CREATE_GUILDS" }), async (req: Request, res: Response) => { diff --git a/api/src/routes/guilds/templates/index.ts b/src/api/routes/guilds/templates/index.ts
index bac4eb8a..3a0de9e8 100644 --- a/api/src/routes/guilds/templates/index.ts +++ b/src/api/routes/guilds/templates/index.ts
@@ -1,15 +1,8 @@ import { Request, Response, Router } from "express"; -import { Template, Guild, Role, Snowflake, Config, User, Member } from "@fosscord/util"; +import { Template, Guild, Role, Snowflake, Config, User, Member, DiscordApiErrors, OrmUtils, GuildTemplateCreateSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { DiscordApiErrors } from "@fosscord/util"; import fetch from "node-fetch"; const router: Router = Router(); -import { OrmUtils } from "@fosscord/util"; - -export interface GuildTemplateCreateSchema { - name: string; - avatar?: string | null; -} router.get("/:code", route({}), async (req: Request, res: Response) => { const { allowDiscordTemplates, allowRaws, enabled } = Config.get().templates; diff --git a/api/src/routes/invites/index.ts b/src/api/routes/invites/index.ts
index 1b434505..1b434505 100644 --- a/api/src/routes/invites/index.ts +++ b/src/api/routes/invites/index.ts
diff --git a/api/src/routes/oauth2/tokens.ts b/src/api/routes/oauth2/tokens.ts
index bd284221..bd284221 100644 --- a/api/src/routes/oauth2/tokens.ts +++ b/src/api/routes/oauth2/tokens.ts
diff --git a/api/src/routes/outbound-promotions.ts b/src/api/routes/outbound-promotions.ts
index 411e95bf..411e95bf 100644 --- a/api/src/routes/outbound-promotions.ts +++ b/src/api/routes/outbound-promotions.ts
diff --git a/api/src/routes/partners/#guild_id/requirements.ts b/src/api/routes/partners/#guild_id/requirements.ts
index 545c5c78..545c5c78 100644 --- a/api/src/routes/partners/#guild_id/requirements.ts +++ b/src/api/routes/partners/#guild_id/requirements.ts
diff --git a/api/src/routes/ping.ts b/src/api/routes/ping.ts
index 3c1da2c3..3c1da2c3 100644 --- a/api/src/routes/ping.ts +++ b/src/api/routes/ping.ts
diff --git a/api/src/routes/policies/instance/domains.ts b/src/api/routes/policies/instance/domains.ts
index 20cd07ba..20cd07ba 100644 --- a/api/src/routes/policies/instance/domains.ts +++ b/src/api/routes/policies/instance/domains.ts
diff --git a/api/src/routes/policies/instance/index.ts b/src/api/routes/policies/instance/index.ts
index e3da014f..e3da014f 100644 --- a/api/src/routes/policies/instance/index.ts +++ b/src/api/routes/policies/instance/index.ts
diff --git a/api/src/routes/policies/instance/limits.ts b/src/api/routes/policies/instance/limits.ts
index 7de1476b..7de1476b 100644 --- a/api/src/routes/policies/instance/limits.ts +++ b/src/api/routes/policies/instance/limits.ts
diff --git a/api/src/routes/scheduled-maintenances/upcoming_json.ts b/src/api/routes/scheduled-maintenances/upcoming_json.ts
index 83092e44..83092e44 100644 --- a/api/src/routes/scheduled-maintenances/upcoming_json.ts +++ b/src/api/routes/scheduled-maintenances/upcoming_json.ts
diff --git a/api/src/routes/science.ts b/src/api/routes/science.ts
index 8556a3ad..8556a3ad 100644 --- a/api/src/routes/science.ts +++ b/src/api/routes/science.ts
diff --git a/api/src/routes/stage-instances.ts b/src/api/routes/stage-instances.ts
index 411e95bf..411e95bf 100644 --- a/api/src/routes/stage-instances.ts +++ b/src/api/routes/stage-instances.ts
diff --git a/api/src/routes/sticker-packs/index.ts b/src/api/routes/sticker-packs/index.ts
index e6560d12..e6560d12 100644 --- a/api/src/routes/sticker-packs/index.ts +++ b/src/api/routes/sticker-packs/index.ts
diff --git a/api/src/routes/stickers/#sticker_id/index.ts b/src/api/routes/stickers/#sticker_id/index.ts
index b484a7a1..b484a7a1 100644 --- a/api/src/routes/stickers/#sticker_id/index.ts +++ b/src/api/routes/stickers/#sticker_id/index.ts
diff --git a/api/src/routes/stop.ts b/src/api/routes/stop.ts
index 7f8b78ba..7f8b78ba 100644 --- a/api/src/routes/stop.ts +++ b/src/api/routes/stop.ts
diff --git a/api/src/routes/store/published-listings/applications.ts b/src/api/routes/store/published-listings/applications.ts
index 060a4c3d..060a4c3d 100644 --- a/api/src/routes/store/published-listings/applications.ts +++ b/src/api/routes/store/published-listings/applications.ts
diff --git a/api/src/routes/store/published-listings/applications/#id/subscription-plans.ts b/src/api/routes/store/published-listings/applications/#id/subscription-plans.ts
index 54151ae5..54151ae5 100644 --- a/api/src/routes/store/published-listings/applications/#id/subscription-plans.ts +++ b/src/api/routes/store/published-listings/applications/#id/subscription-plans.ts
diff --git a/api/src/routes/store/published-listings/skus.ts b/src/api/routes/store/published-listings/skus.ts
index 060a4c3d..060a4c3d 100644 --- a/api/src/routes/store/published-listings/skus.ts +++ b/src/api/routes/store/published-listings/skus.ts
diff --git a/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts b/src/api/routes/store/published-listings/skus/#sku_id/subscription-plans.ts
index 723a5160..723a5160 100644 --- a/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts +++ b/src/api/routes/store/published-listings/skus/#sku_id/subscription-plans.ts
diff --git a/api/src/routes/teams.ts b/src/api/routes/teams.ts
index 7ce3abcb..7ce3abcb 100644 --- a/api/src/routes/teams.ts +++ b/src/api/routes/teams.ts
diff --git a/api/src/routes/template.ts.disabled b/src/api/routes/template.ts.disabled
index fcc59ef4..fcc59ef4 100644 --- a/api/src/routes/template.ts.disabled +++ b/src/api/routes/template.ts.disabled
diff --git a/api/src/routes/track.ts b/src/api/routes/track.ts
index 8556a3ad..8556a3ad 100644 --- a/api/src/routes/track.ts +++ b/src/api/routes/track.ts
diff --git a/api/src/routes/updates.ts b/src/api/routes/updates.ts
index a24e94c1..a24e94c1 100644 --- a/api/src/routes/updates.ts +++ b/src/api/routes/updates.ts
diff --git a/api/src/routes/users/#id/index.ts b/src/api/routes/users/#id/index.ts
index bdb1060f..bdb1060f 100644 --- a/api/src/routes/users/#id/index.ts +++ b/src/api/routes/users/#id/index.ts
diff --git a/api/src/routes/users/#id/profile.ts b/src/api/routes/users/#id/profile.ts
index 7a995a8c..7a995a8c 100644 --- a/api/src/routes/users/#id/profile.ts +++ b/src/api/routes/users/#id/profile.ts
diff --git a/api/src/routes/users/#id/relationships.ts b/src/api/routes/users/#id/relationships.ts
index 61655c25..61655c25 100644 --- a/api/src/routes/users/#id/relationships.ts +++ b/src/api/routes/users/#id/relationships.ts
diff --git a/api/src/routes/users/@me/activities/statistics/applications.ts b/src/api/routes/users/@me/activities/statistics/applications.ts
index 014df8af..014df8af 100644 --- a/api/src/routes/users/@me/activities/statistics/applications.ts +++ b/src/api/routes/users/@me/activities/statistics/applications.ts
diff --git a/api/src/routes/users/@me/affinities/guilds.ts b/src/api/routes/users/@me/affinities/guilds.ts
index 8d744744..8d744744 100644 --- a/api/src/routes/users/@me/affinities/guilds.ts +++ b/src/api/routes/users/@me/affinities/guilds.ts
diff --git a/api/src/routes/users/@me/affinities/users.ts b/src/api/routes/users/@me/affinities/users.ts
index 6d4e4991..6d4e4991 100644 --- a/api/src/routes/users/@me/affinities/users.ts +++ b/src/api/routes/users/@me/affinities/users.ts
diff --git a/api/src/routes/users/@me/applications/#app_id/entitlements.ts b/src/api/routes/users/@me/applications/#app_id/entitlements.ts
index 411e95bf..411e95bf 100644 --- a/api/src/routes/users/@me/applications/#app_id/entitlements.ts +++ b/src/api/routes/users/@me/applications/#app_id/entitlements.ts
diff --git a/api/src/routes/users/@me/billing/country-code.ts b/src/api/routes/users/@me/billing/country-code.ts
index 33d40796..33d40796 100644 --- a/api/src/routes/users/@me/billing/country-code.ts +++ b/src/api/routes/users/@me/billing/country-code.ts
diff --git a/api/src/routes/users/@me/billing/payment-sources.ts b/src/api/routes/users/@me/billing/payment-sources.ts
index 014df8af..014df8af 100644 --- a/api/src/routes/users/@me/billing/payment-sources.ts +++ b/src/api/routes/users/@me/billing/payment-sources.ts
diff --git a/api/src/routes/users/@me/billing/subscriptions.ts b/src/api/routes/users/@me/billing/subscriptions.ts
index 411e95bf..411e95bf 100644 --- a/api/src/routes/users/@me/billing/subscriptions.ts +++ b/src/api/routes/users/@me/billing/subscriptions.ts
diff --git a/api/src/routes/users/@me/channels.ts b/src/api/routes/users/@me/channels.ts
index 78f531e1..ad483529 100644 --- a/api/src/routes/users/@me/channels.ts +++ b/src/api/routes/users/@me/channels.ts
@@ -1,5 +1,5 @@ import { Request, Response, Router } from "express"; -import { Recipient, DmChannelDTO, Channel } from "@fosscord/util"; +import { Recipient, DmChannelDTO, Channel, DmChannelCreateSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; const router: Router = Router(); @@ -12,11 +12,6 @@ router.get("/", route({}), async (req: Request, res: Response) => { res.json(await Promise.all(recipients.map((r) => DmChannelDTO.from(r.channel, [req.user_id])))); }); -export interface DmChannelCreateSchema { - name?: string; - recipients: string[]; -} - router.post("/", route({ body: "DmChannelCreateSchema" }), async (req: Request, res: Response) => { const body = req.body as DmChannelCreateSchema; res.json(await Channel.createDMChannel(body.recipients, req.user_id, body.name)); diff --git a/api/src/routes/users/@me/connections.ts b/src/api/routes/users/@me/connections.ts
index 411e95bf..411e95bf 100644 --- a/api/src/routes/users/@me/connections.ts +++ b/src/api/routes/users/@me/connections.ts
diff --git a/api/src/routes/users/@me/delete.ts b/src/api/routes/users/@me/delete.ts
index 1d81c2b9..1d81c2b9 100644 --- a/api/src/routes/users/@me/delete.ts +++ b/src/api/routes/users/@me/delete.ts
diff --git a/api/src/routes/users/@me/devices.ts b/src/api/routes/users/@me/devices.ts
index 8556a3ad..8556a3ad 100644 --- a/api/src/routes/users/@me/devices.ts +++ b/src/api/routes/users/@me/devices.ts
diff --git a/api/src/routes/users/@me/disable.ts b/src/api/routes/users/@me/disable.ts
index 4aff3774..4aff3774 100644 --- a/api/src/routes/users/@me/disable.ts +++ b/src/api/routes/users/@me/disable.ts
diff --git a/api/src/routes/users/@me/email-settings.ts b/src/api/routes/users/@me/email-settings.ts
index 3114984e..3114984e 100644 --- a/api/src/routes/users/@me/email-settings.ts +++ b/src/api/routes/users/@me/email-settings.ts
diff --git a/api/src/routes/users/@me/entitlements.ts b/src/api/routes/users/@me/entitlements.ts
index 341e2b4c..341e2b4c 100644 --- a/api/src/routes/users/@me/entitlements.ts +++ b/src/api/routes/users/@me/entitlements.ts
diff --git a/api/src/routes/users/@me/guilds.ts b/src/api/routes/users/@me/guilds.ts
index 4d4fccd4..4d4fccd4 100644 --- a/api/src/routes/users/@me/guilds.ts +++ b/src/api/routes/users/@me/guilds.ts
diff --git a/api/src/routes/users/@me/guilds/premium/subscription-slots.ts b/src/api/routes/users/@me/guilds/premium/subscription-slots.ts
index 014df8af..014df8af 100644 --- a/api/src/routes/users/@me/guilds/premium/subscription-slots.ts +++ b/src/api/routes/users/@me/guilds/premium/subscription-slots.ts
diff --git a/api/src/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts
index 4cf96a8d..7d095451 100644 --- a/api/src/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts
@@ -1,30 +1,11 @@ import { Router, Request, Response } from "express"; -import { User, PrivateUserProjection, emitEvent, UserUpdateEvent, handleFile, FieldErrors } from "@fosscord/util"; +import { User, PrivateUserProjection, emitEvent, UserUpdateEvent, handleFile, FieldErrors, UserModifySchema } from "@fosscord/util"; import { route } from "@fosscord/api"; import bcrypt from "bcrypt"; import { OrmUtils, generateToken } from "@fosscord/util"; const router: Router = Router(); -export interface UserModifySchema { - /** - * @minLength 1 - * @maxLength 100 - */ - username?: string; - discriminator?: string; - avatar?: string | null; - /** - * @maxLength 1024 - */ - bio?: string; - accent_color?: number; - banner?: string | null; - password?: string; - new_password?: string; - code?: string; -} - router.get("/", route({}), async (req: Request, res: Response) => { res.json(await User.findOne({ select: PrivateUserProjection, where: { id: req.user_id } })); }); diff --git a/api/src/routes/users/@me/library.ts b/src/api/routes/users/@me/library.ts
index 7ac13bae..7ac13bae 100644 --- a/api/src/routes/users/@me/library.ts +++ b/src/api/routes/users/@me/library.ts
diff --git a/api/src/routes/users/@me/mfa/codes.ts b/src/api/routes/users/@me/mfa/codes.ts
index 75e3e964..4224a1c0 100644 --- a/api/src/routes/users/@me/mfa/codes.ts +++ b/src/api/routes/users/@me/mfa/codes.ts
@@ -1,15 +1,10 @@ import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; -import { BackupCode, Config, FieldErrors, generateMfaBackupCodes, User } from "@fosscord/util"; +import { BackupCode, Config, FieldErrors, generateMfaBackupCodes, MfaCodesSchema, User } from "@fosscord/util"; import bcrypt from "bcrypt"; const router = Router(); -export interface MfaCodesSchema { - password: string; - regenerate?: boolean; -} - // TODO: This route is replaced with users/@me/mfa/codes-verification in newer clients router.post("/", route({ body: "MfaCodesSchema" }), async (req: Request, res: Response) => { diff --git a/api/src/routes/users/@me/mfa/totp/disable.ts b/src/api/routes/users/@me/mfa/totp/disable.ts
index 2d385fda..2fe9355c 100644 --- a/api/src/routes/users/@me/mfa/totp/disable.ts +++ b/src/api/routes/users/@me/mfa/totp/disable.ts
@@ -2,14 +2,10 @@ import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; import { verifyToken } from 'node-2fa'; import { HTTPError } from "lambert-server"; -import { User, generateToken, BackupCode } from "@fosscord/util"; +import { User, generateToken, BackupCode, TotpDisableSchema } from "@fosscord/util"; const router = Router(); -export interface TotpDisableSchema { - code: string; -} - router.post("/", route({ body: "TotpDisableSchema" }), async (req: Request, res: Response) => { const body = req.body as TotpDisableSchema; diff --git a/api/src/routes/users/@me/mfa/totp/enable.ts b/src/api/routes/users/@me/mfa/totp/enable.ts
index 87f36d55..ac668d1d 100644 --- a/api/src/routes/users/@me/mfa/totp/enable.ts +++ b/src/api/routes/users/@me/mfa/totp/enable.ts
@@ -1,5 +1,5 @@ import { Router, Request, Response } from "express"; -import { User, generateToken, BackupCode, generateMfaBackupCodes, Config } from "@fosscord/util"; +import { User, generateToken, BackupCode, generateMfaBackupCodes, Config, TotpEnableSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; import bcrypt from "bcrypt"; import { HTTPError } from "lambert-server"; @@ -7,12 +7,6 @@ import { verifyToken } from 'node-2fa'; const router = Router(); -export interface TotpEnableSchema { - password: string; - code?: string; - secret?: string; -} - router.post("/", route({ body: "TotpEnableSchema" }), async (req: Request, res: Response) => { const body = req.body as TotpEnableSchema; diff --git a/api/src/routes/users/@me/notes.ts b/src/api/routes/users/@me/notes.ts
index f938f088..f938f088 100644 --- a/api/src/routes/users/@me/notes.ts +++ b/src/api/routes/users/@me/notes.ts
diff --git a/api/src/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts
index 6e22f4f3..f7464b99 100644 --- a/api/src/routes/users/@me/relationships.ts +++ b/src/api/routes/users/@me/relationships.ts
@@ -38,10 +38,6 @@ router.get("/", route({}), async (req: Request, res: Response) => { return res.json(related_users); }); -export interface RelationshipPutSchema { - type?: RelationshipType; -} - router.put("/:id", route({ body: "RelationshipPutSchema" }), async (req: Request, res: Response) => { return await updateRelationship( req, @@ -51,11 +47,6 @@ router.put("/:id", route({ body: "RelationshipPutSchema" }), async (req: Request ); }); -export interface RelationshipPostSchema { - discriminator: string; - username: string; -} - router.post("/", route({ body: "RelationshipPostSchema" }), async (req: Request, res: Response) => { return await updateRelationship( req, diff --git a/api/src/routes/users/@me/settings.ts b/src/api/routes/users/@me/settings.ts
index 70f8a218..7578d36e 100644 --- a/api/src/routes/users/@me/settings.ts +++ b/src/api/routes/users/@me/settings.ts
@@ -4,14 +4,12 @@ import { route } from "@fosscord/api"; const router = Router(); -export interface UserSettingsSchema extends Partial<UserSettings> {} - router.patch("/", route({ body: "UserSettingsSchema" }), async (req: Request, res: Response) => { const body = req.body as UserSettings; if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale - const user = await User.findOneOrFail({ where: { id: req.user_id, bot: false } }); - user.settings = { ...user.settings, ...body }; + const user = await User.findOneOrFail({ where: { id: req.user_id, bot: false }, relations: ["settings"] }); + user.settings = { ...user.settings, ...body } as UserSettings; await user.save(); res.sendStatus(204); diff --git a/api/src/routes/voice/regions.ts b/src/api/routes/voice/regions.ts
index 4de304ee..4de304ee 100644 --- a/api/src/routes/voice/regions.ts +++ b/src/api/routes/voice/regions.ts
diff --git a/api/src/start.ts b/src/api/start.ts
index 9ba198e7..9ba198e7 100644 --- a/api/src/start.ts +++ b/src/api/start.ts
diff --git a/api/src/util/entities/AssetCacheItem.ts b/src/api/util/entities/AssetCacheItem.ts
index 160dece6..160dece6 100644 --- a/api/src/util/entities/AssetCacheItem.ts +++ b/src/api/util/entities/AssetCacheItem.ts
diff --git a/api/src/util/entities/blockedEmailDomains.txt b/src/api/util/entities/blockedEmailDomains.txt
index eb88305d..eb88305d 100644 --- a/api/src/util/entities/blockedEmailDomains.txt +++ b/src/api/util/entities/blockedEmailDomains.txt
diff --git a/api/src/util/entities/trustedEmailDomains.txt b/src/api/util/entities/trustedEmailDomains.txt
index 38ffa4fa..38ffa4fa 100644 --- a/api/src/util/entities/trustedEmailDomains.txt +++ b/src/api/util/entities/trustedEmailDomains.txt
diff --git a/api/src/util/handlers/Instance.ts b/src/api/util/handlers/Instance.ts
index 7c337270..7c337270 100644 --- a/api/src/util/handlers/Instance.ts +++ b/src/api/util/handlers/Instance.ts
diff --git a/api/src/util/handlers/Message.ts b/src/api/util/handlers/Message.ts
index 0f584c56..ff5ece75 100644 --- a/api/src/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -21,12 +21,13 @@ import { Webhook, Attachment, Config, + MessageCreateSchema, } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import fetch from "node-fetch"; import cheerio from "cheerio"; -import { MessageCreateSchema } from "../../routes/channels/#channel_id/messages"; import { OrmUtils } from "@fosscord/util"; + const allow_empty = false; // TODO: check webhook, application, system author, stickers // TODO: embed gifs/videos/images diff --git a/api/src/util/handlers/Voice.ts b/src/api/util/handlers/Voice.ts
index 4d60eb91..4d60eb91 100644 --- a/api/src/util/handlers/Voice.ts +++ b/src/api/util/handlers/Voice.ts
diff --git a/api/src/util/handlers/route.ts b/src/api/util/handlers/route.ts
index eaf7dc91..71e14955 100644 --- a/api/src/util/handlers/route.ts +++ b/src/api/util/handlers/route.ts
@@ -19,7 +19,7 @@ import Ajv from "ajv"; import { AnyValidateFunction } from "ajv/dist/core"; import addFormats from "ajv-formats"; -const SchemaPath = path.join(__dirname, "..", "..", "..", "assets", "schemas.json"); +const SchemaPath = path.join(__dirname, "..", "..", "..","..", "assets", "schemas.json"); const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" })); export const ajv = new Ajv({ @@ -117,6 +117,11 @@ export function route(opts: RouteOptions) { const valid = validate(normalizeBody(req.body)); if (!valid) { const fields: Record<string, { code?: string; message: string }> = {}; + if(process.env.LOG_INVALID_BODY) { + console.log(`Got invalid request: ${req.method} ${req.originalUrl}`) + console.log(req.body) + validate.errors?.forEach(x => console.log(x.params)) + } validate.errors?.forEach((x) => (fields[x.instancePath.slice(1)] = { code: x.keyword, message: x.message || "" })); throw FieldErrors(fields); } diff --git a/api/src/util/index.ts b/src/api/util/index.ts
index b3c7559f..b3c7559f 100644 --- a/api/src/util/index.ts +++ b/src/api/util/index.ts
diff --git a/api/src/util/utility/Base64.ts b/src/api/util/utility/Base64.ts
index 46cff77a..46cff77a 100644 --- a/api/src/util/utility/Base64.ts +++ b/src/api/util/utility/Base64.ts
diff --git a/api/src/util/utility/RandomInviteID.ts b/src/api/util/utility/RandomInviteID.ts
index 7ea344e0..7ea344e0 100644 --- a/api/src/util/utility/RandomInviteID.ts +++ b/src/api/util/utility/RandomInviteID.ts
diff --git a/api/src/util/utility/String.ts b/src/api/util/utility/String.ts
index 982b7e11..982b7e11 100644 --- a/api/src/util/utility/String.ts +++ b/src/api/util/utility/String.ts
diff --git a/api/src/util/utility/ipAddress.ts b/src/api/util/utility/ipAddress.ts
index 8d986b26..8d986b26 100644 --- a/api/src/util/utility/ipAddress.ts +++ b/src/api/util/utility/ipAddress.ts
diff --git a/api/src/util/utility/passwordStrength.ts b/src/api/util/utility/passwordStrength.ts
index 8eca63b8..8eca63b8 100644 --- a/api/src/util/utility/passwordStrength.ts +++ b/src/api/util/utility/passwordStrength.ts
diff --git a/cdn/src/Server.ts b/src/cdn/Server.ts
index b27d3321..b27d3321 100644 --- a/cdn/src/Server.ts +++ b/src/cdn/Server.ts
diff --git a/cdn/src/index.ts b/src/cdn/index.ts
index a24300d6..a24300d6 100644 --- a/cdn/src/index.ts +++ b/src/cdn/index.ts
diff --git a/cdn/src/routes/attachments.ts b/src/cdn/routes/attachments.ts
index 723a6c03..723a6c03 100644 --- a/cdn/src/routes/attachments.ts +++ b/src/cdn/routes/attachments.ts
diff --git a/cdn/src/routes/avatars.ts b/src/cdn/routes/avatars.ts
index 40705b2e..40705b2e 100644 --- a/cdn/src/routes/avatars.ts +++ b/src/cdn/routes/avatars.ts
diff --git a/cdn/src/routes/external.ts b/src/cdn/routes/external.ts
index c9441fc2..c9441fc2 100644 --- a/cdn/src/routes/external.ts +++ b/src/cdn/routes/external.ts
diff --git a/cdn/src/routes/ping.ts b/src/cdn/routes/ping.ts
index 38daf81e..38daf81e 100644 --- a/cdn/src/routes/ping.ts +++ b/src/cdn/routes/ping.ts
diff --git a/cdn/src/routes/role-icons.ts b/src/cdn/routes/role-icons.ts
index 2e5c42dd..2e5c42dd 100644 --- a/cdn/src/routes/role-icons.ts +++ b/src/cdn/routes/role-icons.ts
diff --git a/cdn/src/start.ts b/src/cdn/start.ts
index 71681b40..71681b40 100644 --- a/cdn/src/start.ts +++ b/src/cdn/start.ts
diff --git a/cdn/src/util/FileStorage.ts b/src/cdn/util/FileStorage.ts
index aee9d345..aee9d345 100644 --- a/cdn/src/util/FileStorage.ts +++ b/src/cdn/util/FileStorage.ts
diff --git a/cdn/src/util/S3Storage.ts b/src/cdn/util/S3Storage.ts
index c4066817..c4066817 100644 --- a/cdn/src/util/S3Storage.ts +++ b/src/cdn/util/S3Storage.ts
diff --git a/cdn/src/util/Storage.ts b/src/cdn/util/Storage.ts
index 728804a0..728804a0 100644 --- a/cdn/src/util/Storage.ts +++ b/src/cdn/util/Storage.ts
diff --git a/cdn/src/util/index.ts b/src/cdn/util/index.ts
index 07a5c31a..07a5c31a 100644 --- a/cdn/src/util/index.ts +++ b/src/cdn/util/index.ts
diff --git a/cdn/src/util/multer.ts b/src/cdn/util/multer.ts
index bfdf6aff..bfdf6aff 100644 --- a/cdn/src/util/multer.ts +++ b/src/cdn/util/multer.ts
diff --git a/gateway/src/Server.ts b/src/gateway/Server.ts
index 82fbeba2..82fbeba2 100644 --- a/gateway/src/Server.ts +++ b/src/gateway/Server.ts
diff --git a/gateway/src/events/Close.ts b/src/gateway/events/Close.ts
index 5b7c512c..5b7c512c 100644 --- a/gateway/src/events/Close.ts +++ b/src/gateway/events/Close.ts
diff --git a/gateway/src/events/Connection.ts b/src/gateway/events/Connection.ts
index 508b4741..508b4741 100644 --- a/gateway/src/events/Connection.ts +++ b/src/gateway/events/Connection.ts
diff --git a/gateway/src/events/Message.ts b/src/gateway/events/Message.ts
index 7ed1dd06..569f5fc7 100644 --- a/gateway/src/events/Message.ts +++ b/src/gateway/events/Message.ts
@@ -6,7 +6,6 @@ try { } catch (error) {} import OPCodeHandlers from "../opcodes"; import { check } from "../opcodes/instanceOf"; -import WS from "ws"; const PayloadSchema = { op: Number, @@ -15,7 +14,7 @@ const PayloadSchema = { $t: String, }; -export async function Message(this: WebSocket, buffer: WS.RawData) { +export async function Message(this: WebSocket, buffer: Buffer) { // TODO: compression let data: Payload; diff --git a/gateway/src/index.ts b/src/gateway/index.ts
index d77ce931..d77ce931 100644 --- a/gateway/src/index.ts +++ b/src/gateway/index.ts
diff --git a/gateway/src/listener/listener.ts b/src/gateway/listener/listener.ts
index 8c69e193..8c69e193 100644 --- a/gateway/src/listener/listener.ts +++ b/src/gateway/listener/listener.ts
diff --git a/gateway/src/opcodes/Heartbeat.ts b/src/gateway/opcodes/Heartbeat.ts
index 42b72d4b..42b72d4b 100644 --- a/gateway/src/opcodes/Heartbeat.ts +++ b/src/gateway/opcodes/Heartbeat.ts
diff --git a/gateway/src/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts
index 03fff796..44db598c 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts
@@ -18,12 +18,13 @@ import { PrivateSessionProjection, MemberPrivateProjection, PresenceUpdateEvent, + UserSettings, + IdentifySchema, } from "@fosscord/util"; import { Send } from "../util/Send"; import { CLOSECODES, OPCODES } from "../util/Constants"; import { genSessionId } from "../util/SessionUtils"; import { setupListener } from "../listener/listener"; -import { IdentifySchema } from "../schema/Identify"; // import experiments from "./experiments.json"; const experiments: any = []; import { check } from "./instanceOf"; @@ -56,7 +57,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { await Promise.all([ User.findOneOrFail({ where: { id: this.user_id }, - relations: ["relationships", "relationships.to"], + relations: ["relationships", "relationships.to", "settings"], select: [...PrivateUserProjection, "relationships"], }), ReadState.find({ where: { user_id: this.user_id } }), @@ -101,8 +102,13 @@ export async function onIdentify(this: WebSocket, data: Payload) { ]); if (!user) return this.close(CLOSECODES.Authentication_failed); + if (!user.settings) { //settings may not exist after updating... + user.settings = new UserSettings(); + user.settings.id = user.id; + //await (user.settings as UserSettings).save(); + } - if (!identify.intents) identify.intents = BigInt("0x6ffffffff"); + if (!identify.intents) identify.intents = "30064771071"; this.intents = new Intents(identify.intents); if (identify.shard) { this.shard_id = identify.shard[0]; diff --git a/gateway/src/opcodes/LazyRequest.ts b/src/gateway/opcodes/LazyRequest.ts
index 5ba65cdd..74996f5b 100644 --- a/gateway/src/opcodes/LazyRequest.ts +++ b/src/gateway/opcodes/LazyRequest.ts
@@ -1,5 +1,4 @@ -import { getPermission, listenEvent, Member, Role, getOrInitialiseDatabase } from "@fosscord/util"; -import { LazyRequest } from "../schema/LazyRequest"; +import { getPermission, listenEvent, Member, Role, getOrInitialiseDatabase, LazyRequest } from "@fosscord/util"; import { Send } from "../util/Send"; import { OPCODES } from "../util/Constants"; import { WebSocket, Payload, handlePresenceUpdate } from "@fosscord/gateway"; @@ -17,7 +16,7 @@ async function getMembers(guild_id: string, range: [number, number]) { // TODO: wait for typeorm to implement ordering for .find queries https://github.com/typeorm/typeorm/issues/2620 // TODO: rewrite this, released in 0.3.0 - let members = await (await getOrInitialiseDatabase()).getRepository(Member) + let members: Member[] = await (await getOrInitialiseDatabase()).getRepository(Member) .createQueryBuilder("member") .where("member.guild_id = :guild_id", { guild_id }) .leftJoinAndSelect("member.roles", "role") diff --git a/gateway/src/opcodes/PresenceUpdate.ts b/src/gateway/opcodes/PresenceUpdate.ts
index 415df6ee..f31c9161 100644 --- a/gateway/src/opcodes/PresenceUpdate.ts +++ b/src/gateway/opcodes/PresenceUpdate.ts
@@ -1,6 +1,5 @@ import { WebSocket, Payload } from "@fosscord/gateway"; -import { emitEvent, PresenceUpdateEvent, Session, User } from "@fosscord/util"; -import { ActivitySchema } from "../schema/Activity"; +import { ActivitySchema, emitEvent, PresenceUpdateEvent, Session, User } from "@fosscord/util"; import { check } from "./instanceOf"; export async function onPresenceUpdate(this: WebSocket, { d }: Payload) { diff --git a/gateway/src/opcodes/RequestGuildMembers.ts b/src/gateway/opcodes/RequestGuildMembers.ts
index b80721dc..b80721dc 100644 --- a/gateway/src/opcodes/RequestGuildMembers.ts +++ b/src/gateway/opcodes/RequestGuildMembers.ts
diff --git a/gateway/src/opcodes/Resume.ts b/src/gateway/opcodes/Resume.ts
index 42dc586d..42dc586d 100644 --- a/gateway/src/opcodes/Resume.ts +++ b/src/gateway/opcodes/Resume.ts
diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/src/gateway/opcodes/VoiceStateUpdate.ts
index d62425f3..c4297a68 100644 --- a/gateway/src/opcodes/VoiceStateUpdate.ts +++ b/src/gateway/opcodes/VoiceStateUpdate.ts
@@ -1,4 +1,3 @@ -import { VoiceStateUpdateSchema } from "../schema/VoiceStateUpdateSchema"; import { Payload, WebSocket } from "@fosscord/gateway"; import { genVoiceToken } from "../util/SessionUtils"; import { check } from "./instanceOf"; @@ -7,12 +6,13 @@ import { emitEvent, Guild, Member, - Region, VoiceServerUpdateEvent, VoiceState, VoiceStateUpdateEvent, + VoiceStateUpdateSchema, } from "@fosscord/util"; import { OrmUtils } from "@fosscord/util"; +import { Region } from "@fosscord/util"; // TODO: check if a voice server is setup // Notice: Bot users respect the voice channel's user limit, if set. When the voice channel is full, you will not receive the Voice State Update or Voice Server Update events in response to your own Voice State Update. Having MANAGE_CHANNELS permission bypasses this limit and allows you to join regardless of the channel being full or not. @@ -20,6 +20,11 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) { check.call(this, VoiceStateUpdateSchema, data.d); const body = data.d as VoiceStateUpdateSchema; + if(body.guild_id == null) { + console.log(`[Gateway] VoiceStateUpdate called with guild_id == null by user ${this.user_id}!`); + return; + } + let voiceState: VoiceState; try { voiceState = await VoiceState.findOneOrFail({ diff --git a/gateway/src/opcodes/experiments.json b/src/gateway/opcodes/experiments.json
index 0370b5da..0370b5da 100644 --- a/gateway/src/opcodes/experiments.json +++ b/src/gateway/opcodes/experiments.json
diff --git a/gateway/src/opcodes/index.ts b/src/gateway/opcodes/index.ts
index 027739db..027739db 100644 --- a/gateway/src/opcodes/index.ts +++ b/src/gateway/opcodes/index.ts
diff --git a/gateway/src/opcodes/instanceOf.ts b/src/gateway/opcodes/instanceOf.ts
index eb6f6ea1..eb6f6ea1 100644 --- a/gateway/src/opcodes/instanceOf.ts +++ b/src/gateway/opcodes/instanceOf.ts
diff --git a/gateway/src/start.ts b/src/gateway/start.ts
index 2000522a..2000522a 100644 --- a/gateway/src/start.ts +++ b/src/gateway/start.ts
diff --git a/gateway/src/util/Constants.ts b/src/gateway/util/Constants.ts
index 692f9028..692f9028 100644 --- a/gateway/src/util/Constants.ts +++ b/src/gateway/util/Constants.ts
diff --git a/gateway/src/util/Heartbeat.ts b/src/gateway/util/Heartbeat.ts
index f6871cfe..f6871cfe 100644 --- a/gateway/src/util/Heartbeat.ts +++ b/src/gateway/util/Heartbeat.ts
diff --git a/gateway/src/util/Send.ts b/src/gateway/util/Send.ts
index 2a28d8e0..2a28d8e0 100644 --- a/gateway/src/util/Send.ts +++ b/src/gateway/util/Send.ts
diff --git a/gateway/src/util/SessionUtils.ts b/src/gateway/util/SessionUtils.ts
index bf854042..bf854042 100644 --- a/gateway/src/util/SessionUtils.ts +++ b/src/gateway/util/SessionUtils.ts
diff --git a/gateway/src/util/WebSocket.ts b/src/gateway/util/WebSocket.ts
index e3313f40..9496da85 100644 --- a/gateway/src/util/WebSocket.ts +++ b/src/gateway/util/WebSocket.ts
@@ -8,8 +8,8 @@ export interface WebSocket extends WS { session_id: string; encoding: "etf" | "json"; compress?: "zlib-stream"; - shard_count?: bigint; - shard_id?: bigint; + shard_count?: number; + shard_id?: number; deflate?: Deflate; heartbeatTimeout: NodeJS.Timeout; readyTimeout: NodeJS.Timeout; diff --git a/gateway/src/util/index.ts b/src/gateway/util/index.ts
index 0be5ecee..0be5ecee 100644 --- a/gateway/src/util/index.ts +++ b/src/gateway/util/index.ts
diff --git a/src/plugins/example-plugin/build.sh b/src/plugins/example-plugin/build.sh new file mode 100755
index 00000000..1b36607b --- /dev/null +++ b/src/plugins/example-plugin/build.sh
@@ -0,0 +1,5 @@ +#rm -rf dist/ +#mkdir dist +rm -rfv *.js *.js.map +ln -s ../../bundle/node_modules node_modules +tsc -p . diff --git a/src/plugins/example-plugin/index.ts b/src/plugins/example-plugin/index.ts new file mode 100644
index 00000000..d5db6563 --- /dev/null +++ b/src/plugins/example-plugin/index.ts
@@ -0,0 +1,7 @@ +/*import { Plugin } from "@fosscord/util" + +export default class TestPlugin extends Plugin { + onPluginLoaded(): void { + console.log("Hello from test plugin! IT WORKS!!!!!!!"); + } +}*/ \ No newline at end of file diff --git a/src/plugins/example-plugin/plugin.json b/src/plugins/example-plugin/plugin.json new file mode 100644
index 00000000..980edbdf --- /dev/null +++ b/src/plugins/example-plugin/plugin.json
@@ -0,0 +1,9 @@ +{ + "id": "example-plugin", + "name": "Fosscord example plugin", + "authors": [ + "The Arcane Brony" + ], + "repository": "https://github.com/fosscord/fosscord-server", + "license": "" +} diff --git a/api/tsconfig.json b/src/plugins/example-plugin/tsconfig.json
index 80fca16d..7efe9434 100644 --- a/api/tsconfig.json +++ b/src/plugins/example-plugin/tsconfig.json
@@ -1,75 +1,85 @@ -{ - "exclude": ["node_modules"], - "include": ["src/**/*.ts"], - "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Basic Options */ - "incremental": false /* Enable incremental compilation */, - "target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, - "lib": ["ES2021"] /* Specify library files to be included in the compilation. */, - "allowJs": true /* Allow javascript files to be compiled. */, - "checkJs": true /* Report errors in .js files. */, - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - "declaration": true /* Generates corresponding '.d.ts' file. */, - "declarationMap": false /* Generates a sourcemap for each corresponding '.d.ts' file. */, - "sourceMap": true /* Generates corresponding '.map' file. */, - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./dist/" /* Redirect output structure to the directory. */, - "rootDir": "./src/" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - - /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, - "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, - "strictNullChecks": true /* Enable strict null checks. */, - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - "strictPropertyInitialization": false /* Enable strict checking of property initialization in classes. */, - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - "types": ["node"] /* Type declaration files to be included in compilation. */, - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - - /* Advanced Options */ - "skipLibCheck": true /* Skip type checking of declaration files. */, - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, - "baseUrl": ".", - "paths": { - "@fosscord/api": ["src/index"] - }, - "plugins": [{ "transform": "@ovos-media/ts-transform-paths" }], - "experimentalDecorators": true - } -} +{ + "include": ["./**/*.ts"], + "exclude": [], + "compilerOptions": { + + /* Basic Options */ + "incremental": false /* Enable incremental compilation */, + "target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, + "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, + "lib": [ + "ESNext" + ] /* Specify library files to be included in the compilation. */, + "allowJs": true /* Allow javascript files to be compiled. */, + "checkJs": true /* Report errors in .js files. */, + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + "declaration": false /* Generates corresponding '.d.ts' file. */, + "declarationMap": false /* Generates a sourcemap for each corresponding '.d.ts' file. */, + "sourceMap": true /* Generates corresponding '.map' file. */, + // "outFile": "./", /* Concatenate and emit output to single file. */ + "outDir": "./dist/" /* Redirect output structure to the directory. */, + "rootDir": "./" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, + // "composite": true, /* Enable project compilation */ + // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */, + "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, + "strictNullChecks": true /* Enable strict null checks. */, + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + "strictPropertyInitialization": false /* Enable strict checking of property initialization in classes. */, + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + "types": [ + "node" + ] /* Type declaration files to be included in compilation. */, + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + + /* Advanced Options */ + "skipLibCheck": true /* Skip type checking of declaration files. */, + "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "resolveJsonModule": true, + "baseUrl": "../../bundle/dist/", + "paths": { + "@fosscord/api": ["../../api/src/index"], + "@fosscord/gateway": ["../../gateway/src/index"], + "@fosscord/cdn": ["../../cdn/src/index"], + "@fosscord/util": ["../../util/src/index"] + }, + "plugins": [{ "transform": "@ovos-media/ts-transform-paths" }], + "noEmitHelpers": true, + "importHelpers": true + } +} diff --git a/bundle/src/start.ts b/src/start.ts
index a20581c3..a20581c3 100644 --- a/bundle/src/start.ts +++ b/src/start.ts
diff --git a/src/stats.ts b/src/stats.ts new file mode 100644
index 00000000..654e0a4f --- /dev/null +++ b/src/stats.ts
@@ -0,0 +1,24 @@ +import os from "os"; +import { red } from "picocolors"; + +export function initStats() { + + console.log(`[Path] running in ${__dirname}`); + try { + console.log(`[CPU] ${os.cpus()[0].model} Cores x${os.cpus().length}`); + } + catch { + console.log('[CPU] Failed to get cpu model!') + } + + console.log(`[System] ${os.platform()} ${os.arch()}`); + console.log(`[Process] running with PID: ${process.pid}`); + if (process.getuid && process.getuid() === 0) { + console.warn( + red( + `[Process] Warning fosscord is running as root, this highly discouraged and might expose your system vulnerable to attackers. Please run fosscord as a user without root privileges.` + ) + ); + } + +} diff --git a/src/util/config/Config.ts b/src/util/config/Config.ts new file mode 100644
index 00000000..7aee1775 --- /dev/null +++ b/src/util/config/Config.ts
@@ -0,0 +1,22 @@ +import { ApiConfiguration, ClientConfiguration, DefaultsConfiguration, EndpointConfiguration, GeneralConfiguration, GifConfiguration, GuildConfiguration, KafkaConfiguration, LimitsConfiguration, LoginConfiguration, MetricsConfiguration, RabbitMQConfiguration, RegionConfiguration, RegisterConfiguration, SecurityConfiguration, SentryConfiguration, TemplateConfiguration } from "."; + +export class ConfigValue { + gateway: EndpointConfiguration = new EndpointConfiguration(); + cdn: EndpointConfiguration = new EndpointConfiguration(); + api: ApiConfiguration = new ApiConfiguration(); + general: GeneralConfiguration = new GeneralConfiguration(); + limits: LimitsConfiguration = new LimitsConfiguration(); + security: SecurityConfiguration = new SecurityConfiguration(); + login: LoginConfiguration = new LoginConfiguration(); + register: RegisterConfiguration = new RegisterConfiguration(); + regions: RegionConfiguration = new RegionConfiguration(); + guild: GuildConfiguration = new GuildConfiguration(); + gif: GifConfiguration = new GifConfiguration(); + rabbitmq: RabbitMQConfiguration = new RabbitMQConfiguration(); + kafka: KafkaConfiguration = new KafkaConfiguration(); + templates: TemplateConfiguration = new TemplateConfiguration(); + client: ClientConfiguration = new ClientConfiguration(); + metrics: MetricsConfiguration = new MetricsConfiguration(); + sentry: SentryConfiguration = new SentryConfiguration(); + defaults: DefaultsConfiguration = new DefaultsConfiguration(); +} \ No newline at end of file diff --git a/src/util/config/index.ts b/src/util/config/index.ts new file mode 100644
index 00000000..0a9b58ae --- /dev/null +++ b/src/util/config/index.ts
@@ -0,0 +1,2 @@ +export * from "./Config"; +export * from "./types/index"; diff --git a/src/util/config/types/ApiConfiguration.ts b/src/util/config/types/ApiConfiguration.ts new file mode 100644
index 00000000..16b1efba --- /dev/null +++ b/src/util/config/types/ApiConfiguration.ts
@@ -0,0 +1,5 @@ +export class ApiConfiguration { + defaultVersion: string = "9"; + activeVersions: string[] = ["6", "7", "8", "9"]; + useFosscordEnhancements: boolean = true; +} \ No newline at end of file diff --git a/src/util/config/types/ClientConfiguration.ts b/src/util/config/types/ClientConfiguration.ts new file mode 100644
index 00000000..1adda1e2 --- /dev/null +++ b/src/util/config/types/ClientConfiguration.ts
@@ -0,0 +1,8 @@ +import { ClientReleaseConfiguration } from "."; + +export class ClientConfiguration { + //classes + releases: ClientReleaseConfiguration = new ClientReleaseConfiguration(); + //base types + useTestClient: boolean = true; +} \ No newline at end of file diff --git a/src/util/config/types/DefaultsConfiguration.ts b/src/util/config/types/DefaultsConfiguration.ts new file mode 100644
index 00000000..9b02a590 --- /dev/null +++ b/src/util/config/types/DefaultsConfiguration.ts
@@ -0,0 +1,6 @@ +import { GuildDefaults, UserDefaults } from "."; + +export class DefaultsConfiguration { + guild: GuildDefaults = new GuildDefaults(); + user: UserDefaults = new UserDefaults(); +} \ No newline at end of file diff --git a/src/util/config/types/EndpointConfiguration.ts b/src/util/config/types/EndpointConfiguration.ts new file mode 100644
index 00000000..87baea31 --- /dev/null +++ b/src/util/config/types/EndpointConfiguration.ts
@@ -0,0 +1,5 @@ +export class EndpointConfiguration { + endpointClient: string | null = null; + endpointPrivate: string | null = null; + endpointPublic: string | null = null; +} \ No newline at end of file diff --git a/src/util/config/types/GeneralConfiguration.ts b/src/util/config/types/GeneralConfiguration.ts new file mode 100644
index 00000000..55848b44 --- /dev/null +++ b/src/util/config/types/GeneralConfiguration.ts
@@ -0,0 +1,12 @@ +import { Snowflake } from "../../util"; + +export class GeneralConfiguration { + instanceName: string = "Fosscord Instance"; + instanceDescription: string | null = "This is a Fosscord instance made in the pre-release days"; + frontPage: string | null = null; + tosPage: string | null = null; + correspondenceEmail: string | null = "noreply@localhost.local"; + correspondenceUserID: string | null = null; + image: string | null = null; + instanceId: string = Snowflake.generate(); +} \ No newline at end of file diff --git a/src/util/config/types/GifConfiguration.ts b/src/util/config/types/GifConfiguration.ts new file mode 100644
index 00000000..6a2d520d --- /dev/null +++ b/src/util/config/types/GifConfiguration.ts
@@ -0,0 +1,5 @@ +export class GifConfiguration { + enabled: boolean = true; + provider: "tenor" = "tenor"; // more coming soon + apiKey?: string = "LIVDSRZULELA"; +} \ No newline at end of file diff --git a/src/util/config/types/GuildConfiguration.ts b/src/util/config/types/GuildConfiguration.ts new file mode 100644
index 00000000..3d43b368 --- /dev/null +++ b/src/util/config/types/GuildConfiguration.ts
@@ -0,0 +1,6 @@ +import { DiscoveryConfiguration, AutoJoinConfiguration } from "."; + +export class GuildConfiguration { + discovery: DiscoveryConfiguration = new DiscoveryConfiguration(); + autoJoin: AutoJoinConfiguration = new AutoJoinConfiguration(); +} diff --git a/src/util/config/types/KafkaConfiguration.ts b/src/util/config/types/KafkaConfiguration.ts new file mode 100644
index 00000000..7932f49e --- /dev/null +++ b/src/util/config/types/KafkaConfiguration.ts
@@ -0,0 +1,5 @@ +import { KafkaBroker } from "."; + +export class KafkaConfiguration { + brokers: KafkaBroker[] | null = null; +} \ No newline at end of file diff --git a/src/util/config/types/LimitConfigurations.ts b/src/util/config/types/LimitConfigurations.ts new file mode 100644
index 00000000..bcc2e7e2 --- /dev/null +++ b/src/util/config/types/LimitConfigurations.ts
@@ -0,0 +1,9 @@ +import { ChannelLimits, GuildLimits, MessageLimits, RateLimits, UserLimits } from "."; + +export class LimitsConfiguration { + user: UserLimits = new UserLimits(); + guild: GuildLimits = new GuildLimits(); + message: MessageLimits = new MessageLimits(); + channel: ChannelLimits = new ChannelLimits(); + rate: RateLimits = new RateLimits(); +} \ No newline at end of file diff --git a/src/util/config/types/LoginConfiguration.ts b/src/util/config/types/LoginConfiguration.ts new file mode 100644
index 00000000..255c9451 --- /dev/null +++ b/src/util/config/types/LoginConfiguration.ts
@@ -0,0 +1,3 @@ +export class LoginConfiguration { + requireCaptcha: boolean = false; +} \ No newline at end of file diff --git a/src/util/config/types/MetricsConfiguration.ts b/src/util/config/types/MetricsConfiguration.ts new file mode 100644
index 00000000..d7cd4937 --- /dev/null +++ b/src/util/config/types/MetricsConfiguration.ts
@@ -0,0 +1,3 @@ +export class MetricsConfiguration { + timeout: number = 30000; +} \ No newline at end of file diff --git a/src/util/config/types/RabbitMQConfiguration.ts b/src/util/config/types/RabbitMQConfiguration.ts new file mode 100644
index 00000000..ce4a9123 --- /dev/null +++ b/src/util/config/types/RabbitMQConfiguration.ts
@@ -0,0 +1,3 @@ +export class RabbitMQConfiguration { + host: string | null = null; +} \ No newline at end of file diff --git a/src/util/config/types/RegionConfiguration.ts b/src/util/config/types/RegionConfiguration.ts new file mode 100644
index 00000000..09d9271c --- /dev/null +++ b/src/util/config/types/RegionConfiguration.ts
@@ -0,0 +1,16 @@ +import { Region } from "."; + +export class RegionConfiguration { + default: string = "fosscord"; + useDefaultAsOptimal: boolean = true; + available: Region[] = [ + { + id: "fosscord", + name: "Fosscord", + endpoint: "127.0.0.1:3004", + vip: false, + custom: false, + deprecated: false, + }, + ]; +} \ No newline at end of file diff --git a/src/util/config/types/RegisterConfiguration.ts b/src/util/config/types/RegisterConfiguration.ts new file mode 100644
index 00000000..a0dc97c5 --- /dev/null +++ b/src/util/config/types/RegisterConfiguration.ts
@@ -0,0 +1,18 @@ +import { DateOfBirthConfiguration, EmailConfiguration, PasswordConfiguration } from "."; + +export class RegisterConfiguration { + //classes + email: EmailConfiguration = new EmailConfiguration(); + dateOfBirth: DateOfBirthConfiguration = new DateOfBirthConfiguration(); + password: PasswordConfiguration = new PasswordConfiguration(); + //base types + disabled: boolean = false; + requireCaptcha: boolean = true; + requireInvite: boolean = false; + guestsRequireInvite: boolean = true; + allowNewRegistration: boolean = true; + allowMultipleAccounts: boolean = true; + blockProxies: boolean = true; + incrementingDiscriminators: boolean = false; // random otherwise + defaultRights: string = "0"; +} diff --git a/src/util/config/types/SecurityConfiguration.ts b/src/util/config/types/SecurityConfiguration.ts new file mode 100644
index 00000000..405b86ac --- /dev/null +++ b/src/util/config/types/SecurityConfiguration.ts
@@ -0,0 +1,17 @@ +import crypto from "crypto"; +import { CaptchaConfiguration, TwoFactorConfiguration } from "."; + +export class SecurityConfiguration { + //classes + captcha: CaptchaConfiguration = new CaptchaConfiguration(); + twoFactor: TwoFactorConfiguration = new TwoFactorConfiguration(); + //base types + autoUpdate: boolean | number = true; + requestSignature: string = crypto.randomBytes(32).toString("base64"); + jwtSecret: string = crypto.randomBytes(256).toString("base64"); + // header to get the real user ip address + // X-Forwarded-For for nginx/reverse proxies + // CF-Connecting-IP for cloudflare + forwadedFor: string | null = null; + ipdataApiKey: string | null = "eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9"; +} diff --git a/src/util/config/types/SentryConfiguration.ts b/src/util/config/types/SentryConfiguration.ts new file mode 100644
index 00000000..836094a1 --- /dev/null +++ b/src/util/config/types/SentryConfiguration.ts
@@ -0,0 +1,8 @@ +import { hostname } from "os"; + +export class SentryConfiguration { + enabled: boolean = false; + endpoint: string = "https://05e8e3d005f34b7d97e920ae5870a5e5@sentry.thearcanebrony.net/6"; + traceSampleRate: number = 1.0; + environment: string = hostname(); +} \ No newline at end of file diff --git a/src/util/config/types/TemplateConfiguration.ts b/src/util/config/types/TemplateConfiguration.ts new file mode 100644
index 00000000..4a9aa8f2 --- /dev/null +++ b/src/util/config/types/TemplateConfiguration.ts
@@ -0,0 +1,6 @@ +export class TemplateConfiguration { + enabled: boolean = true; + allowTemplateCreation: boolean = true; + allowDiscordTemplates: boolean = true; + allowRaws: boolean = true; +} \ No newline at end of file diff --git a/src/util/config/types/index.ts b/src/util/config/types/index.ts new file mode 100644
index 00000000..608503a0 --- /dev/null +++ b/src/util/config/types/index.ts
@@ -0,0 +1,18 @@ +export * from "./ApiConfiguration"; +export * from "./ClientConfiguration"; +export * from "./DefaultsConfiguration"; +export * from "./EndpointConfiguration"; +export * from "./GeneralConfiguration"; +export * from "./GifConfiguration"; +export * from "./GuildConfiguration"; +export * from "./KafkaConfiguration"; +export * from "./LimitConfigurations"; +export * from "./LoginConfiguration"; +export * from "./MetricsConfiguration"; +export * from "./RabbitMQConfiguration"; +export * from "./RegionConfiguration"; +export * from "./RegisterConfiguration"; +export * from "./SecurityConfiguration"; +export * from "./SentryConfiguration"; +export * from "./TemplateConfiguration"; +export * from "./subconfigurations/index"; diff --git a/src/util/config/types/subconfigurations/client/ClientReleaseConfiguration.ts b/src/util/config/types/subconfigurations/client/ClientReleaseConfiguration.ts new file mode 100644
index 00000000..54e7f365 --- /dev/null +++ b/src/util/config/types/subconfigurations/client/ClientReleaseConfiguration.ts
@@ -0,0 +1,4 @@ +export class ClientReleaseConfiguration { + useLocalRelease: boolean = true; //TODO + upstreamVersion: string = "0.0.264"; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/client/index.ts b/src/util/config/types/subconfigurations/client/index.ts new file mode 100644
index 00000000..96bbb0ca --- /dev/null +++ b/src/util/config/types/subconfigurations/client/index.ts
@@ -0,0 +1 @@ +export * from "./ClientReleaseConfiguration"; diff --git a/src/util/config/types/subconfigurations/defaults/GuildDefaults.ts b/src/util/config/types/subconfigurations/defaults/GuildDefaults.ts new file mode 100644
index 00000000..d6ff7697 --- /dev/null +++ b/src/util/config/types/subconfigurations/defaults/GuildDefaults.ts
@@ -0,0 +1,8 @@ +export class GuildDefaults { + maxPresences: number = 250000; + maxVideoChannelUsers: number = 200; + afkTimeout: number = 300; + defaultMessageNotifications: number = 1; + explicitContentFilter: number = 0; + test: number = 123; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/defaults/UserDefaults.ts b/src/util/config/types/subconfigurations/defaults/UserDefaults.ts new file mode 100644
index 00000000..4481c011 --- /dev/null +++ b/src/util/config/types/subconfigurations/defaults/UserDefaults.ts
@@ -0,0 +1,5 @@ +export class UserDefaults { + premium: boolean = false; + premium_type: number = 2; + verified: boolean = true; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/defaults/index.ts b/src/util/config/types/subconfigurations/defaults/index.ts new file mode 100644
index 00000000..50258d1c --- /dev/null +++ b/src/util/config/types/subconfigurations/defaults/index.ts
@@ -0,0 +1,2 @@ +export * from "./GuildDefaults"; +export * from "./UserDefaults"; diff --git a/src/util/config/types/subconfigurations/guild/AutoJoin.ts b/src/util/config/types/subconfigurations/guild/AutoJoin.ts new file mode 100644
index 00000000..47dfe5ec --- /dev/null +++ b/src/util/config/types/subconfigurations/guild/AutoJoin.ts
@@ -0,0 +1,5 @@ +export class AutoJoinConfiguration { + enabled: boolean = true; + guilds: string[] = []; + canLeave: boolean = true; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/guild/Discovery.ts b/src/util/config/types/subconfigurations/guild/Discovery.ts new file mode 100644
index 00000000..59d8a8ae --- /dev/null +++ b/src/util/config/types/subconfigurations/guild/Discovery.ts
@@ -0,0 +1,6 @@ +export class DiscoveryConfiguration { + showAllGuilds: boolean = false; + useRecommendation: boolean = false; // TODO: Recommendation, privacy concern? + offset: number = 0; + limit: number = 24; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/guild/index.ts b/src/util/config/types/subconfigurations/guild/index.ts new file mode 100644
index 00000000..e9614856 --- /dev/null +++ b/src/util/config/types/subconfigurations/guild/index.ts
@@ -0,0 +1,2 @@ +export * from "./AutoJoin"; +export * from "./Discovery"; diff --git a/src/util/config/types/subconfigurations/index.ts b/src/util/config/types/subconfigurations/index.ts new file mode 100644
index 00000000..bfbadc92 --- /dev/null +++ b/src/util/config/types/subconfigurations/index.ts
@@ -0,0 +1,8 @@ +export * from "./client/index"; +export * from "./defaults/index"; +export * from "./guild/index"; +export * from "./kafka/index"; +export * from "./limits/index"; +export * from "./region/index"; +export * from "./register/index"; +export * from "./security/index"; diff --git a/src/util/config/types/subconfigurations/kafka/KafkaBroker.ts b/src/util/config/types/subconfigurations/kafka/KafkaBroker.ts new file mode 100644
index 00000000..4f9a5e51 --- /dev/null +++ b/src/util/config/types/subconfigurations/kafka/KafkaBroker.ts
@@ -0,0 +1,4 @@ +export interface KafkaBroker { + ip: string; + port: number; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/kafka/index.ts b/src/util/config/types/subconfigurations/kafka/index.ts new file mode 100644
index 00000000..2c633950 --- /dev/null +++ b/src/util/config/types/subconfigurations/kafka/index.ts
@@ -0,0 +1 @@ +export * from "./KafkaBroker"; diff --git a/src/util/config/types/subconfigurations/limits/ChannelLimits.ts b/src/util/config/types/subconfigurations/limits/ChannelLimits.ts new file mode 100644
index 00000000..2f8f9485 --- /dev/null +++ b/src/util/config/types/subconfigurations/limits/ChannelLimits.ts
@@ -0,0 +1,5 @@ +export class ChannelLimits { + maxPins: number = 500; + maxTopic: number = 1024; + maxWebhooks: number = 100; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/limits/GuildLimits.ts b/src/util/config/types/subconfigurations/limits/GuildLimits.ts new file mode 100644
index 00000000..91ad39ae --- /dev/null +++ b/src/util/config/types/subconfigurations/limits/GuildLimits.ts
@@ -0,0 +1,8 @@ +export class GuildLimits { + maxRoles: number = 1000; + maxEmojis: number = 2000; + maxMembers: number = 25000000; + maxChannels: number = 65535; + maxChannelsInCategory: number = 65535; + hideOfflineMember: number = 3; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/limits/MessageLimits.ts b/src/util/config/types/subconfigurations/limits/MessageLimits.ts new file mode 100644
index 00000000..51576b90 --- /dev/null +++ b/src/util/config/types/subconfigurations/limits/MessageLimits.ts
@@ -0,0 +1,8 @@ +export class MessageLimits { + maxCharacters: number = 1048576; + maxTTSCharacters: number = 160; + maxReactions: number = 2048; + maxAttachmentSize: number = 1024 * 1024 * 1024; + maxBulkDelete: number = 1000; + maxEmbedDownloadSize: number = 1024 * 1024 * 5; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/limits/RateLimits.ts b/src/util/config/types/subconfigurations/limits/RateLimits.ts new file mode 100644
index 00000000..25e7a1e0 --- /dev/null +++ b/src/util/config/types/subconfigurations/limits/RateLimits.ts
@@ -0,0 +1,18 @@ +import { RouteRateLimit, RateLimitOptions } from "."; + +export class RateLimits { + disabled: boolean = true; + ip: Omit<RateLimitOptions, "bot_count"> = { + count: 500, + window: 5 + }; + global: RateLimitOptions = { + count: 250, + window: 5 + }; + error: RateLimitOptions = { + count: 10, + window: 5 + }; + routes: RouteRateLimit; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/limits/UserLimits.ts b/src/util/config/types/subconfigurations/limits/UserLimits.ts new file mode 100644
index 00000000..0d10e0b3 --- /dev/null +++ b/src/util/config/types/subconfigurations/limits/UserLimits.ts
@@ -0,0 +1,5 @@ +export class UserLimits { + maxGuilds: number = 1048576; + maxUsername: number = 127; + maxFriends: number = 5000; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/limits/index.ts b/src/util/config/types/subconfigurations/limits/index.ts new file mode 100644
index 00000000..0b7304f6 --- /dev/null +++ b/src/util/config/types/subconfigurations/limits/index.ts
@@ -0,0 +1,6 @@ +export * from "./ChannelLimits"; +export * from "./GuildLimits"; +export * from "./MessageLimits"; +export * from "./RateLimits"; +export * from "./UserLimits"; +export * from "./ratelimits/index"; diff --git a/src/util/config/types/subconfigurations/limits/ratelimits/Auth.ts b/src/util/config/types/subconfigurations/limits/ratelimits/Auth.ts new file mode 100644
index 00000000..df171044 --- /dev/null +++ b/src/util/config/types/subconfigurations/limits/ratelimits/Auth.ts
@@ -0,0 +1,12 @@ +import { RateLimitOptions } from "./RateLimitOptions"; + +export class AuthRateLimit { + login: RateLimitOptions = { + count: 5, + window: 60 + }; + register: RateLimitOptions = { + count: 2, + window: 60 * 60 * 12 + }; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/limits/ratelimits/RateLimitOptions.ts b/src/util/config/types/subconfigurations/limits/ratelimits/RateLimitOptions.ts new file mode 100644
index 00000000..7089e28e --- /dev/null +++ b/src/util/config/types/subconfigurations/limits/ratelimits/RateLimitOptions.ts
@@ -0,0 +1,6 @@ +export interface RateLimitOptions { + bot?: number; + count: number; + window: number; + onyIp?: boolean; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/limits/ratelimits/Route.ts b/src/util/config/types/subconfigurations/limits/ratelimits/Route.ts new file mode 100644
index 00000000..844b1b9a --- /dev/null +++ b/src/util/config/types/subconfigurations/limits/ratelimits/Route.ts
@@ -0,0 +1,19 @@ +import { AuthRateLimit } from "./Auth"; +import { RateLimitOptions } from "./RateLimitOptions"; + +export class RouteRateLimit { + guild: RateLimitOptions = { + count: 5, + window: 5 + }; + webhook: RateLimitOptions = { + count: 10, + window: 5 + }; + channel: RateLimitOptions = { + count: 10, + window: 5 + }; + auth: AuthRateLimit; + // TODO: rate limit configuration for all routes +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/limits/ratelimits/index.ts b/src/util/config/types/subconfigurations/limits/ratelimits/index.ts new file mode 100644
index 00000000..432eb601 --- /dev/null +++ b/src/util/config/types/subconfigurations/limits/ratelimits/index.ts
@@ -0,0 +1,3 @@ +export * from "./Auth"; +export * from "./RateLimitOptions"; +export * from "./Route"; diff --git a/src/util/config/types/subconfigurations/region/Region.ts b/src/util/config/types/subconfigurations/region/Region.ts new file mode 100644
index 00000000..a8717e1f --- /dev/null +++ b/src/util/config/types/subconfigurations/region/Region.ts
@@ -0,0 +1,12 @@ +export interface Region { + id: string; + name: string; + endpoint: string; + location?: { + latitude: number; + longitude: number; + }; + vip: boolean; + custom: boolean; + deprecated: boolean; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/region/index.ts b/src/util/config/types/subconfigurations/region/index.ts new file mode 100644
index 00000000..2beb8de7 --- /dev/null +++ b/src/util/config/types/subconfigurations/region/index.ts
@@ -0,0 +1 @@ +export * from "./Region"; diff --git a/src/util/config/types/subconfigurations/register/DateOfBirth.ts b/src/util/config/types/subconfigurations/register/DateOfBirth.ts new file mode 100644
index 00000000..5a3c4e9d --- /dev/null +++ b/src/util/config/types/subconfigurations/register/DateOfBirth.ts
@@ -0,0 +1,4 @@ +export class DateOfBirthConfiguration { + required: boolean = true; + minimum: number = 13; // in years +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/register/Email.ts b/src/util/config/types/subconfigurations/register/Email.ts new file mode 100644
index 00000000..115d49e0 --- /dev/null +++ b/src/util/config/types/subconfigurations/register/Email.ts
@@ -0,0 +1,7 @@ +export class EmailConfiguration { + required: boolean = false; + allowlist: boolean = false; + blocklist: boolean = true; + domains: string[] = [];// TODO: efficiently save domain blocklist in database + // domains: fs.readFileSync(__dirname + "/blockedEmailDomains.txt", { encoding: "utf8" }).split("\n"), +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/register/Password.ts b/src/util/config/types/subconfigurations/register/Password.ts new file mode 100644
index 00000000..977473ac --- /dev/null +++ b/src/util/config/types/subconfigurations/register/Password.ts
@@ -0,0 +1,7 @@ +export class PasswordConfiguration { + required: boolean = false; + minLength: number = 8; + minNumbers: number = 2; + minUpperCase: number =2; + minSymbols: number = 0; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/register/index.ts b/src/util/config/types/subconfigurations/register/index.ts new file mode 100644
index 00000000..d9738120 --- /dev/null +++ b/src/util/config/types/subconfigurations/register/index.ts
@@ -0,0 +1,3 @@ +export * from "./DateOfBirth"; +export * from "./Email"; +export * from "./Password"; diff --git a/src/util/config/types/subconfigurations/security/Captcha.ts b/src/util/config/types/subconfigurations/security/Captcha.ts new file mode 100644
index 00000000..ad6aa762 --- /dev/null +++ b/src/util/config/types/subconfigurations/security/Captcha.ts
@@ -0,0 +1,6 @@ +export class CaptchaConfiguration { + enabled: boolean = false; + service: "recaptcha" | "hcaptcha" | null = null; // TODO: hcaptcha, custom + sitekey: string | null = null; + secret: string | null = null; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/security/TwoFactor.ts b/src/util/config/types/subconfigurations/security/TwoFactor.ts new file mode 100644
index 00000000..33a47385 --- /dev/null +++ b/src/util/config/types/subconfigurations/security/TwoFactor.ts
@@ -0,0 +1,3 @@ +export class TwoFactorConfiguration { + generateBackupCodes: boolean = true; +} \ No newline at end of file diff --git a/src/util/config/types/subconfigurations/security/index.ts b/src/util/config/types/subconfigurations/security/index.ts new file mode 100644
index 00000000..17619589 --- /dev/null +++ b/src/util/config/types/subconfigurations/security/index.ts
@@ -0,0 +1,2 @@ +export * from "./Captcha"; +export * from "./TwoFactor"; diff --git a/util/src/dtos/DmChannelDTO.ts b/src/util/dtos/DmChannelDTO.ts
index 226b2f9d..226b2f9d 100644 --- a/util/src/dtos/DmChannelDTO.ts +++ b/src/util/dtos/DmChannelDTO.ts
diff --git a/util/src/dtos/UserDTO.ts b/src/util/dtos/UserDTO.ts
index ee2752a4..ee2752a4 100644 --- a/util/src/dtos/UserDTO.ts +++ b/src/util/dtos/UserDTO.ts
diff --git a/util/src/dtos/index.ts b/src/util/dtos/index.ts
index 0e8f8459..0e8f8459 100644 --- a/util/src/dtos/index.ts +++ b/src/util/dtos/index.ts
diff --git a/util/src/entities/Application.ts b/src/util/entities/Application.ts
index 103f8e84..103f8e84 100644 --- a/util/src/entities/Application.ts +++ b/src/util/entities/Application.ts
diff --git a/util/src/entities/Attachment.ts b/src/util/entities/Attachment.ts
index 7b4b17eb..7b4b17eb 100644 --- a/util/src/entities/Attachment.ts +++ b/src/util/entities/Attachment.ts
diff --git a/util/src/entities/AuditLog.ts b/src/util/entities/AuditLog.ts
index b003e7ba..b003e7ba 100644 --- a/util/src/entities/AuditLog.ts +++ b/src/util/entities/AuditLog.ts
diff --git a/util/src/entities/BackupCodes.ts b/src/util/entities/BackupCodes.ts
index 9092c14e..9092c14e 100644 --- a/util/src/entities/BackupCodes.ts +++ b/src/util/entities/BackupCodes.ts
diff --git a/util/src/entities/Ban.ts b/src/util/entities/Ban.ts
index 9504bd8e..9504bd8e 100644 --- a/util/src/entities/Ban.ts +++ b/src/util/entities/Ban.ts
diff --git a/util/src/entities/BaseClass.ts b/src/util/entities/BaseClass.ts
index c872e7f1..aecc2465 100644 --- a/util/src/entities/BaseClass.ts +++ b/src/util/entities/BaseClass.ts
@@ -1,5 +1,5 @@ import "reflect-metadata"; -import { BaseEntity, EntityMetadata, ObjectIdColumn, PrimaryColumn, FindOptionsWhere, Generated, SaveOptions } from "typeorm"; +import { BaseEntity, ObjectIdColumn, PrimaryColumn, SaveOptions } from "typeorm"; import { Snowflake } from "../util/Snowflake"; export class BaseClassWithoutId extends BaseEntity { diff --git a/util/src/entities/Categories.ts b/src/util/entities/Categories.ts
index 81fbc303..81fbc303 100644 --- a/util/src/entities/Categories.ts +++ b/src/util/entities/Categories.ts
diff --git a/util/src/entities/Channel.ts b/src/util/entities/Channel.ts
index ade0fb39..a576d7af 100644 --- a/util/src/entities/Channel.ts +++ b/src/util/entities/Channel.ts
@@ -151,6 +151,13 @@ export class Channel extends BaseClass { }) webhooks?: Webhook[]; + @Column({ nullable: true }) + flags?: number = 0; + + @Column({ nullable: true }) + default_thread_rate_limit_per_user?: number = 0; + + // TODO: DM channel static async createChannel( channel: Partial<Channel>, diff --git a/util/src/entities/ClientRelease.ts b/src/util/entities/ClientRelease.ts
index c5afd307..c5afd307 100644 --- a/util/src/entities/ClientRelease.ts +++ b/src/util/entities/ClientRelease.ts
diff --git a/src/util/entities/Config.ts b/src/util/entities/Config.ts new file mode 100644
index 00000000..606fe901 --- /dev/null +++ b/src/util/entities/Config.ts
@@ -0,0 +1,11 @@ +import { Column, Entity } from "typeorm"; +import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; + +@Entity("config") +export class ConfigEntity extends BaseClassWithoutId { + @PrimaryIdColumn() + key: string; + + @Column({ type: "simple-json", nullable: true }) + value: number | boolean | null | string | undefined; +} \ No newline at end of file diff --git a/util/src/entities/ConnectedAccount.ts b/src/util/entities/ConnectedAccount.ts
index 09ae30ab..09ae30ab 100644 --- a/util/src/entities/ConnectedAccount.ts +++ b/src/util/entities/ConnectedAccount.ts
diff --git a/util/src/entities/Emoji.ts b/src/util/entities/Emoji.ts
index a3615b7d..a3615b7d 100644 --- a/util/src/entities/Emoji.ts +++ b/src/util/entities/Emoji.ts
diff --git a/util/src/entities/Encryption.ts b/src/util/entities/Encryption.ts
index 6b578d15..6b578d15 100644 --- a/util/src/entities/Encryption.ts +++ b/src/util/entities/Encryption.ts
diff --git a/util/src/entities/Group.ts b/src/util/entities/Group.ts
index b24d38cf..b24d38cf 100644 --- a/util/src/entities/Group.ts +++ b/src/util/entities/Group.ts
diff --git a/util/src/entities/Guild.ts b/src/util/entities/Guild.ts
index 77a04350..d146e577 100644 --- a/util/src/entities/Guild.ts +++ b/src/util/entities/Guild.ts
@@ -53,7 +53,7 @@ export class Guild extends BaseClass { afk_channel?: Channel; @Column({ nullable: true }) - afk_timeout?: number; + afk_timeout?: number = Config.get().defaults.guild.afkTimeout; // * commented out -> use owner instead // application id of the guild creator if it is bot-created @@ -71,7 +71,7 @@ export class Guild extends BaseClass { banner?: string; @Column({ nullable: true }) - default_message_notifications?: number; + default_message_notifications?: number = Config.get().defaults.guild.defaultMessageNotifications; @Column({ nullable: true }) description?: string; @@ -80,7 +80,7 @@ export class Guild extends BaseClass { discovery_splash?: string; @Column({ nullable: true }) - explicit_content_filter?: number; + explicit_content_filter?: number = Config.get().defaults.guild.explicitContentFilter; @Column({ type: "simple-array" }) features: string[]; //TODO use enum @@ -96,19 +96,19 @@ export class Guild extends BaseClass { large?: boolean; @Column({ nullable: true }) - max_members?: number; // e.g. default 100.000 + max_members?: number = Config.get().limits.guild.maxMembers; // e.g. default 100.000 @Column({ nullable: true }) - max_presences?: number; + max_presences?: number = Config.get().defaults.guild.maxPresences; @Column({ nullable: true }) - max_video_channel_users?: number; // ? default: 25, is this max 25 streaming or watching + max_video_channel_users?: number = Config.get().defaults.guild.maxVideoChannelUsers; // ? default: 25, is this max 25 streaming or watching @Column({ nullable: true }) - member_count?: number; + member_count?: number = 0; @Column({ nullable: true }) - presence_count?: number; // users online + presence_count?: number = 0; // users online @OneToMany(() => Member, (member: Member) => member.guild, { cascade: true, @@ -278,6 +278,10 @@ export class Guild extends BaseClass { // only for developer portal permissions?: number; + //new guild settings, 11/08/2022: + @Column({ nullable: true }) + premium_progress_bar_enabled: boolean = false; + static async createGuild(body: { name?: string; icon?: string | null; diff --git a/util/src/entities/Invite.ts b/src/util/entities/Invite.ts
index 1e0ebe52..1e0ebe52 100644 --- a/util/src/entities/Invite.ts +++ b/src/util/entities/Invite.ts
diff --git a/util/src/entities/Member.ts b/src/util/entities/Member.ts
index baac58ed..baac58ed 100644 --- a/util/src/entities/Member.ts +++ b/src/util/entities/Member.ts
diff --git a/util/src/entities/Message.ts b/src/util/entities/Message.ts
index ba3d4f2d..ba3d4f2d 100644 --- a/util/src/entities/Message.ts +++ b/src/util/entities/Message.ts
diff --git a/util/src/entities/Migration.ts b/src/util/entities/Migration.ts
index 3f39ae72..3f39ae72 100644 --- a/util/src/entities/Migration.ts +++ b/src/util/entities/Migration.ts
diff --git a/util/src/entities/Note.ts b/src/util/entities/Note.ts
index 36017c5e..36017c5e 100644 --- a/util/src/entities/Note.ts +++ b/src/util/entities/Note.ts
diff --git a/util/src/entities/RateLimit.ts b/src/util/entities/RateLimit.ts
index f5916f6b..f5916f6b 100644 --- a/util/src/entities/RateLimit.ts +++ b/src/util/entities/RateLimit.ts
diff --git a/util/src/entities/ReadState.ts b/src/util/entities/ReadState.ts
index b915573b..b915573b 100644 --- a/util/src/entities/ReadState.ts +++ b/src/util/entities/ReadState.ts
diff --git a/util/src/entities/Recipient.ts b/src/util/entities/Recipient.ts
index a945f938..a945f938 100644 --- a/util/src/entities/Recipient.ts +++ b/src/util/entities/Recipient.ts
diff --git a/util/src/entities/Relationship.ts b/src/util/entities/Relationship.ts
index c3592c76..c3592c76 100644 --- a/util/src/entities/Relationship.ts +++ b/src/util/entities/Relationship.ts
diff --git a/util/src/entities/Role.ts b/src/util/entities/Role.ts
index 4b721b5b..4b721b5b 100644 --- a/util/src/entities/Role.ts +++ b/src/util/entities/Role.ts
diff --git a/util/src/entities/Session.ts b/src/util/entities/Session.ts
index 969efa89..969efa89 100644 --- a/util/src/entities/Session.ts +++ b/src/util/entities/Session.ts
diff --git a/util/src/entities/Sticker.ts b/src/util/entities/Sticker.ts
index 37bc6fbe..37bc6fbe 100644 --- a/util/src/entities/Sticker.ts +++ b/src/util/entities/Sticker.ts
diff --git a/util/src/entities/StickerPack.ts b/src/util/entities/StickerPack.ts
index ec8c69a2..ec8c69a2 100644 --- a/util/src/entities/StickerPack.ts +++ b/src/util/entities/StickerPack.ts
diff --git a/util/src/entities/Team.ts b/src/util/entities/Team.ts
index 22140b7f..22140b7f 100644 --- a/util/src/entities/Team.ts +++ b/src/util/entities/Team.ts
diff --git a/util/src/entities/TeamMember.ts b/src/util/entities/TeamMember.ts
index b726e1e8..b726e1e8 100644 --- a/util/src/entities/TeamMember.ts +++ b/src/util/entities/TeamMember.ts
diff --git a/util/src/entities/Template.ts b/src/util/entities/Template.ts
index 1d952283..1d952283 100644 --- a/util/src/entities/Template.ts +++ b/src/util/entities/Template.ts
diff --git a/util/src/entities/User.ts b/src/util/entities/User.ts
index a9f00b0d..5432f298 100644 --- a/util/src/entities/User.ts +++ b/src/util/entities/User.ts
@@ -1,11 +1,11 @@ -import { Column, Entity, FindOneOptions, FindOptionsSelectByString, JoinColumn, OneToMany } from "typeorm"; +import { Column, Entity, FindOneOptions, FindOptionsSelectByString, JoinColumn, OneToMany, OneToOne } from "typeorm"; import { OrmUtils } from "../util/imports/OrmUtils"; import { BaseClass } from "./BaseClass"; import { BitField } from "../util/BitField"; import { Relationship } from "./Relationship"; import { ConnectedAccount } from "./ConnectedAccount"; import { Config, FieldErrors, Snowflake, trimSpecial } from ".."; -import { Member, Session } from "."; +import { Member, Session, UserSettings } from "."; export enum PublicUserEnum { username, @@ -83,30 +83,30 @@ export class User extends BaseClass { phone?: string; // phone number of the user @Column({ select: false }) - desktop: boolean; // if the user has desktop app installed + desktop: boolean = false; // if the user has desktop app installed @Column({ select: false }) - mobile: boolean; // if the user has mobile app installed + mobile: boolean = false; // if the user has mobile app installed @Column() - premium: boolean; // if user bought individual premium + premium: boolean = Config.get().defaults.user.premium; // if user bought individual premium @Column() - premium_type: number; // individual premium level + premium_type: number = Config.get().defaults.user.premium_type; // individual premium level @Column() - bot: boolean; // if user is bot + bot: boolean = false; // if user is bot - @Column() + @Column({ nullable: true }) bio: string; // short description of the user (max 190 chars -> should be configurable) @Column() - system: boolean; // shouldn't be used, the api sends this field type true, if the generated message comes from a system generated author + system: boolean = false; // shouldn't be used, the api sends this field type true, if the generated message comes from a system generated author @Column({ select: false }) - nsfw_allowed: boolean; // if the user can do age-restricted actions (NSFW channels/guilds/commands) + nsfw_allowed: boolean = true; // if the user can do age-restricted actions (NSFW channels/guilds/commands) // TODO: depending on age - @Column({ select: false }) + @Column({ select: false, nullable: true }) mfa_enabled: boolean; // if multi factor authentication is enabled @Column({ select: false, nullable: true }) @@ -116,31 +116,31 @@ export class User extends BaseClass { totp_last_ticket?: string; @Column() - created_at: Date; // registration date + created_at: Date = new Date(); // registration date @Column({ nullable: true }) - premium_since: Date; // premium date + premium_since: Date = new Date(); // premium date @Column({ select: false }) - verified: boolean; // if the user is offically verified + verified: boolean = Config.get().defaults.user.verified; // if the user is offically verified @Column() - disabled: boolean; // if the account is disabled + disabled: boolean = false; // if the account is disabled @Column() - deleted: boolean; // if the user was deleted + deleted: boolean = false; // if the user was deleted @Column({ nullable: true, select: false }) email?: string; // email of the user @Column() - flags: string; // UserFlags + flags: string = "0"; // UserFlags // TODO: generate @Column() - public_flags: number; + public_flags: number = 0; @Column({ type: "bigint" }) - rights: string; // Rights + rights: string = Config.get().register.defaultRights; // Rights @OneToMany(() => Session, (session: Session) => session.user) sessions: Session[]; @@ -166,17 +166,30 @@ export class User extends BaseClass { }; @Column({ type: "simple-array", select: false }) - fingerprints: string[]; // array of fingerprints -> used to prevent multiple accounts + fingerprints: string[] = []; // array of fingerprints -> used to prevent multiple accounts - @Column({ type: "simple-json", select: false }) + + @OneToOne(()=> UserSettings, { + cascade: true, + orphanedRowAction: "delete", + eager: false + }) + @JoinColumn() settings: UserSettings; // workaround to prevent fossord-unaware clients from deleting settings not used by them @Column({ type: "simple-json", select: false }) - extended_settings: string; + extended_settings: string = "{}"; @Column({ type: "simple-json" }) - notes: { [key: string]: string }; //key is ID of user + notes: { [key: string]: string } = {}; //key is ID of user + + async save(): Promise<any> { + if(!this.settings) this.settings = new UserSettings(); + this.settings.id = this.id; + //await this.settings.save(); + return super.save(); + } toPublicUser() { const user: any = {}; @@ -256,39 +269,19 @@ export class User extends BaseClass { const language = req?.language === "en" ? "en-US" : req?.language || "en-US"; const user = OrmUtils.mergeDeep(new User(), { - created_at: new Date(), + //required: username: username, discriminator, id: Snowflake.generate(), - bot: false, - system: false, - premium_since: new Date(), - desktop: false, - mobile: false, - premium: true, - premium_type: 2, - bio: "", - mfa_enabled: false, - totp_secret: "", - totp_backup_codes: [], - verified: true, - disabled: false, - deleted: false, email: email, - rights: Config.get().register.defaultRights, // TODO: grant rights correctly, as 0 actually stands for no rights at all - nsfw_allowed: true, // TODO: depending on age - public_flags: "0", - flags: "0", // TODO: generate data: { hash: password, valid_tokens_since: new Date(), }, - settings: { ...defaultSettings, locale: language }, - extended_settings: {}, - fingerprints: [], - notes: {}, + settings: { ...new UserSettings(), locale: language } }); + //await (user.settings as UserSettings).save(); await user.save(); setImmediate(async () => { @@ -303,85 +296,6 @@ export class User extends BaseClass { } } -export const defaultSettings: UserSettings = { - afk_timeout: 3600, - allow_accessibility_detection: true, - animate_emoji: true, - animate_stickers: 0, - contact_sync_enabled: false, - convert_emoticons: false, - custom_status: null, - default_guilds_restricted: false, - detect_platform_accounts: false, - developer_mode: true, - disable_games_tab: true, - enable_tts_command: false, - explicit_content_filter: 0, - friend_source_flags: { all: true }, - gateway_connected: false, - gif_auto_play: true, - guild_folders: [], - guild_positions: [], - inline_attachment_media: true, - inline_embed_media: true, - locale: "en-US", - message_display_compact: false, - native_phone_integration_enabled: true, - render_embeds: true, - render_reactions: true, - restricted_guilds: [], - show_current_game: true, - status: "online", - stream_notifications_enabled: false, - theme: "dark", - timezone_offset: 0, // TODO: timezone from request -}; - -export interface UserSettings { - afk_timeout: number; - allow_accessibility_detection: boolean; - animate_emoji: boolean; - animate_stickers: number; - contact_sync_enabled: boolean; - convert_emoticons: boolean; - custom_status: { - emoji_id?: string; - emoji_name?: string; - expires_at?: number; - text?: string; - } | null; - default_guilds_restricted: boolean; - detect_platform_accounts: boolean; - developer_mode: boolean; - disable_games_tab: boolean; - enable_tts_command: boolean; - explicit_content_filter: number; - friend_source_flags: { all: boolean }; - gateway_connected: boolean; - gif_auto_play: boolean; - // every top guild is displayed as a "folder" - guild_folders: { - color: number; - guild_ids: string[]; - id: number; - name: string; - }[]; - guild_positions: string[]; // guild ids ordered by position - inline_attachment_media: boolean; - inline_embed_media: boolean; - locale: string; // en_US - message_display_compact: boolean; - native_phone_integration_enabled: boolean; - render_embeds: boolean; - render_reactions: boolean; - restricted_guilds: string[]; - show_current_game: boolean; - status: "online" | "offline" | "dnd" | "idle" | "invisible"; - stream_notifications_enabled: boolean; - theme: "dark" | "white"; // dark - timezone_offset: number; // e.g -60 -} - export const CUSTOM_USER_FLAG_OFFSET = BigInt(1) << BigInt(32); export class UserFlags extends BitField { diff --git a/util/src/entities/UserGroup.ts b/src/util/entities/UserGroup.ts
index 709b9d0b..709b9d0b 100644 --- a/util/src/entities/UserGroup.ts +++ b/src/util/entities/UserGroup.ts
diff --git a/src/util/entities/UserSettings.ts b/src/util/entities/UserSettings.ts new file mode 100644
index 00000000..ef6f95af --- /dev/null +++ b/src/util/entities/UserSettings.ts
@@ -0,0 +1,119 @@ +import { Column, Entity, JoinColumn } from "typeorm"; +import { BaseClassWithoutId, PrimaryIdColumn } from "."; + +@Entity("user_settings") +export class UserSettings extends BaseClassWithoutId { + @PrimaryIdColumn() + id: string; + + @Column({ nullable: true }) + afk_timeout: number = 3600; + + @Column({ nullable: true }) + allow_accessibility_detection: boolean = true; + + @Column({ nullable: true }) + animate_emoji: boolean = true; + + @Column({ nullable: true }) + animate_stickers: number = 0; + + @Column({ nullable: true }) + contact_sync_enabled: boolean = false; + + @Column({ nullable: true }) + convert_emoticons: boolean = false; + + @Column({ nullable: true, type: "simple-json" }) + custom_status: CustomStatus | null = null; + + @Column({ nullable: true }) + default_guilds_restricted: boolean = false; + + @Column({ nullable: true }) + detect_platform_accounts: boolean = false; + + @Column({ nullable: true }) + developer_mode: boolean = true; + + @Column({ nullable: true }) + disable_games_tab: boolean = true; + + @Column({ nullable: true }) + enable_tts_command: boolean = false; + + @Column({ nullable: true }) + explicit_content_filter: number = 0; + + @Column({ nullable: true, type: "simple-json" }) + friend_source_flags: FriendSourceFlags = { all: true }; + + @Column({ nullable: true }) + gateway_connected: boolean = false; + + @Column({ nullable: true }) + gif_auto_play: boolean = false; + + @Column({ nullable: true, type: "simple-json" }) + guild_folders: GuildFolder[] = []; // every top guild is displayed as a "folder" + + @Column({ nullable: true, type: "simple-json" }) + guild_positions: string[] = []; // guild ids ordered by position + + @Column({ nullable: true }) + inline_attachment_media: boolean = true; + + @Column({ nullable: true }) + inline_embed_media: boolean = true; + + @Column({ nullable: true }) + locale: string = "en-US"; // en_US + + @Column({ nullable: true }) + message_display_compact: boolean = false; + + @Column({ nullable: true }) + native_phone_integration_enabled: boolean = true; + + @Column({ nullable: true }) + render_embeds: boolean = true; + + @Column({ nullable: true }) + render_reactions: boolean = true; + + @Column({ nullable: true, type: "simple-json" }) + restricted_guilds: string[] = []; + + @Column({ nullable: true }) + show_current_game: boolean = true; + + @Column({ nullable: true }) + status: "online" | "offline" | "dnd" | "idle" | "invisible" = "online"; + + @Column({ nullable: true }) + stream_notifications_enabled: boolean = false; + + @Column({ nullable: true }) + theme: "dark" | "white" = "dark"; // dark + + @Column({ nullable: true }) + timezone_offset: number = 0; // e.g -60 +} + +interface CustomStatus { + emoji_id?: string; + emoji_name?: string; + expires_at?: number; + text?: string; +} + +interface GuildFolder { + color: number; + guild_ids: string[]; + id: number; + name: string; +} + +interface FriendSourceFlags { + all: boolean +} \ No newline at end of file diff --git a/util/src/entities/VoiceState.ts b/src/util/entities/VoiceState.ts
index 75748a01..75748a01 100644 --- a/util/src/entities/VoiceState.ts +++ b/src/util/entities/VoiceState.ts
diff --git a/util/src/entities/Webhook.ts b/src/util/entities/Webhook.ts
index 89538417..89538417 100644 --- a/util/src/entities/Webhook.ts +++ b/src/util/entities/Webhook.ts
diff --git a/util/src/entities/index.ts b/src/util/entities/index.ts
index c439a4b7..c6f12022 100644 --- a/util/src/entities/index.ts +++ b/src/util/entities/index.ts
@@ -30,3 +30,4 @@ export * from "./Webhook"; export * from "./ClientRelease"; export * from "./BackupCodes"; export * from "./Note"; +export * from "./UserSettings"; diff --git a/util/src/index.ts b/src/util/index.ts
index 259d1c97..d944dc49 100644 --- a/util/src/index.ts +++ b/src/util/index.ts
@@ -1,7 +1,9 @@ import "reflect-metadata"; export * from "./util/index"; +export * from "./config/index"; export * from "./interfaces/index"; export * from "./entities/index"; export * from "./dtos/index"; -export * from "./util/MFA"; \ No newline at end of file +export * from "./util/MFA"; +export * from "./schemas"; \ No newline at end of file diff --git a/util/src/interfaces/Activity.ts b/src/util/interfaces/Activity.ts
index 43984afd..43984afd 100644 --- a/util/src/interfaces/Activity.ts +++ b/src/util/interfaces/Activity.ts
diff --git a/util/src/interfaces/Event.ts b/src/util/interfaces/Event.ts
index f3391c4f..be66c62f 100644 --- a/util/src/interfaces/Event.ts +++ b/src/util/interfaces/Event.ts
@@ -1,4 +1,4 @@ -import { PublicUser, User, UserSettings } from "../entities/User"; +import { PublicUser, User } from "../entities/User"; import { Channel } from "../entities/Channel"; import { Guild } from "../entities/Guild"; import { Member, PublicMember, UserGuildSettings } from "../entities/Member"; @@ -12,7 +12,7 @@ import { Interaction } from "./Interaction"; import { ConnectedAccount } from "../entities/ConnectedAccount"; import { Relationship, RelationshipType } from "../entities/Relationship"; import { Presence } from "./Presence"; -import { Sticker } from ".."; +import { Sticker, UserSettings } from ".."; import { Activity, Status } from "."; export interface Event { diff --git a/util/src/interfaces/Interaction.ts b/src/util/interfaces/Interaction.ts
index 5d3aae24..5d3aae24 100644 --- a/util/src/interfaces/Interaction.ts +++ b/src/util/interfaces/Interaction.ts
diff --git a/util/src/interfaces/Presence.ts b/src/util/interfaces/Presence.ts
index 7663891a..7663891a 100644 --- a/util/src/interfaces/Presence.ts +++ b/src/util/interfaces/Presence.ts
diff --git a/util/src/interfaces/Status.ts b/src/util/interfaces/Status.ts
index 5d2e1bba..5d2e1bba 100644 --- a/util/src/interfaces/Status.ts +++ b/src/util/interfaces/Status.ts
diff --git a/util/src/interfaces/index.ts b/src/util/interfaces/index.ts
index ab7fa429..ab7fa429 100644 --- a/util/src/interfaces/index.ts +++ b/src/util/interfaces/index.ts
diff --git a/util/src/migrations/mariadb/1659901151025-initial.ts b/src/util/migrations/mariadb/1659901151025-initial.ts
index d15e0add..d15e0add 100644 --- a/util/src/migrations/mariadb/1659901151025-initial.ts +++ b/src/util/migrations/mariadb/1659901151025-initial.ts
diff --git a/util/src/migrations/mariadb/1659921859145-premium_since_as_date.ts b/src/util/migrations/mariadb/1659921859145-premium_since_as_date.ts
index de173cfe..de173cfe 100644 --- a/util/src/migrations/mariadb/1659921859145-premium_since_as_date.ts +++ b/src/util/migrations/mariadb/1659921859145-premium_since_as_date.ts
diff --git a/util/src/migrations/mariadb/1660130586602-updated-applications.ts b/src/util/migrations/mariadb/1660130586602-updated-applications.ts
index ec574416..ec574416 100644 --- a/util/src/migrations/mariadb/1660130586602-updated-applications.ts +++ b/src/util/migrations/mariadb/1660130586602-updated-applications.ts
diff --git a/util/src/migrations/mariadb/1660131942703-apps_nullable_team.ts b/src/util/migrations/mariadb/1660131942703-apps_nullable_team.ts
index ac445772..ac445772 100644 --- a/util/src/migrations/mariadb/1660131942703-apps_nullable_team.ts +++ b/src/util/migrations/mariadb/1660131942703-apps_nullable_team.ts
diff --git a/src/util/migrations/mariadb/1660540527213-sync_migrations.ts b/src/util/migrations/mariadb/1660540527213-sync_migrations.ts new file mode 100644
index 00000000..8cc1d2f1 --- /dev/null +++ b/src/util/migrations/mariadb/1660540527213-sync_migrations.ts
@@ -0,0 +1,127 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class syncMigrations1660540527213 implements MigrationInterface { + name = 'syncMigrations1660540527213' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` CHANGE \`settings\` \`settingsId\` text NOT NULL + `); + await queryRunner.query(` + CREATE TABLE \`user_settings\` ( + \`id\` varchar(255) NOT NULL, + \`afk_timeout\` int NULL, + \`allow_accessibility_detection\` tinyint NULL, + \`animate_emoji\` tinyint NULL, + \`animate_stickers\` int NULL, + \`contact_sync_enabled\` tinyint NULL, + \`convert_emoticons\` tinyint NULL, + \`custom_status\` text NULL, + \`default_guilds_restricted\` tinyint NULL, + \`detect_platform_accounts\` tinyint NULL, + \`developer_mode\` tinyint NULL, + \`disable_games_tab\` tinyint NULL, + \`enable_tts_command\` tinyint NULL, + \`explicit_content_filter\` int NULL, + \`friend_source_flags\` text NULL, + \`gateway_connected\` tinyint NULL, + \`gif_auto_play\` tinyint NULL, + \`guild_folders\` text NULL, + \`guild_positions\` text NULL, + \`inline_attachment_media\` tinyint NULL, + \`inline_embed_media\` tinyint NULL, + \`locale\` varchar(255) NULL, + \`message_display_compact\` tinyint NULL, + \`native_phone_integration_enabled\` tinyint NULL, + \`render_embeds\` tinyint NULL, + \`render_reactions\` tinyint NULL, + \`restricted_guilds\` text NULL, + \`show_current_game\` tinyint NULL, + \`status\` varchar(255) NULL, + \`stream_notifications_enabled\` tinyint NULL, + \`theme\` varchar(255) NULL, + \`timezone_offset\` int NULL, + PRIMARY KEY (\`id\`) + ) ENGINE = InnoDB + `); + await queryRunner.query(` + ALTER TABLE \`channels\` + ADD \`flags\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`channels\` + ADD \`default_thread_rate_limit_per_user\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`guilds\` + ADD \`premium_progress_bar_enabled\` tinyint NULL + `); + await queryRunner.query(` + ALTER TABLE \`users\` DROP COLUMN \`settingsId\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` + ADD \`settingsId\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`users\` + ADD UNIQUE INDEX \`IDX_76ba283779c8441fd5ff819c8c\` (\`settingsId\`) + `); + await queryRunner.query(` + CREATE UNIQUE INDEX \`REL_76ba283779c8441fd5ff819c8c\` ON \`users\` (\`settingsId\`) + `); + await queryRunner.query(` + ALTER TABLE \`users\` + ADD CONSTRAINT \`FK_76ba283779c8441fd5ff819c8cf\` FOREIGN KEY (\`settingsId\`) REFERENCES \`user_settings\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION + `); + await queryRunner.query(` + ALTER TABLE \`invites\` + ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` DROP FOREIGN KEY \`FK_76ba283779c8441fd5ff819c8cf\` + `); + await queryRunner.query(` + DROP INDEX \`REL_76ba283779c8441fd5ff819c8c\` ON \`users\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` DROP INDEX \`IDX_76ba283779c8441fd5ff819c8c\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` DROP COLUMN \`settingsId\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` + ADD \`settingsId\` text NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`guilds\` DROP COLUMN \`premium_progress_bar_enabled\` + `); + await queryRunner.query(` + ALTER TABLE \`channels\` DROP COLUMN \`default_thread_rate_limit_per_user\` + `); + await queryRunner.query(` + ALTER TABLE \`channels\` DROP COLUMN \`flags\` + `); + await queryRunner.query(` + DROP TABLE \`user_settings\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` CHANGE \`settingsId\` \`settings\` text NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`invites\` + ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + +} diff --git a/src/util/migrations/mariadb/1660549252130-fix_nullables.ts b/src/util/migrations/mariadb/1660549252130-fix_nullables.ts new file mode 100644
index 00000000..c9456b54 --- /dev/null +++ b/src/util/migrations/mariadb/1660549252130-fix_nullables.ts
@@ -0,0 +1,30 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class fixNullables1660549252130 implements MigrationInterface { + name = 'fixNullables1660549252130' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + DROP INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` CHANGE \`bio\` \`bio\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`users\` CHANGE \`mfa_enabled\` \`mfa_enabled\` tinyint NULL + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE \`users\` CHANGE \`mfa_enabled\` \`mfa_enabled\` tinyint NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`users\` CHANGE \`bio\` \`bio\` varchar(255) NOT NULL + `); + await queryRunner.query(` + CREATE UNIQUE INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\` (\`settingsId\`) + `); + } + +} diff --git a/util/src/migrations/postgres/1659899687168-initial.ts b/src/util/migrations/postgres/1659899687168-initial.ts
index 4ffb897d..4ffb897d 100644 --- a/util/src/migrations/postgres/1659899687168-initial.ts +++ b/src/util/migrations/postgres/1659899687168-initial.ts
diff --git a/util/src/migrations/postgres/1659921826567-premium_since_as_date.ts b/src/util/migrations/postgres/1659921826567-premium_since_as_date.ts
index ac1e2edb..ac1e2edb 100644 --- a/util/src/migrations/postgres/1659921826567-premium_since_as_date.ts +++ b/src/util/migrations/postgres/1659921826567-premium_since_as_date.ts
diff --git a/util/src/migrations/postgres/1660130561959-updated-applications.ts b/src/util/migrations/postgres/1660130561959-updated-applications.ts
index 8fab54c7..8fab54c7 100644 --- a/util/src/migrations/postgres/1660130561959-updated-applications.ts +++ b/src/util/migrations/postgres/1660130561959-updated-applications.ts
diff --git a/src/util/migrations/postgres/1660257815436-CodeCleanup2.ts b/src/util/migrations/postgres/1660257815436-CodeCleanup2.ts new file mode 100644
index 00000000..511c2f5a --- /dev/null +++ b/src/util/migrations/postgres/1660257815436-CodeCleanup2.ts
@@ -0,0 +1,59 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup21660257815436 implements MigrationInterface { + name = 'CodeCleanup21660257815436' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "user_settings" ( + "id" character varying NOT NULL, + "afk_timeout" integer, + "allow_accessibility_detection" boolean, + "animate_emoji" boolean, + "animate_stickers" integer, + "contact_sync_enabled" boolean, + "convert_emoticons" boolean, + "custom_status" text, + "default_guilds_restricted" boolean, + "detect_platform_accounts" boolean, + "developer_mode" boolean, + "disable_games_tab" boolean, + "enable_tts_command" boolean, + "explicit_content_filter" integer, + "friend_source_flags" text, + "gateway_connected" boolean, + "gif_auto_play" boolean, + "guild_folders" text, + "guild_positions" text, + "inline_attachment_media" boolean, + "inline_embed_media" boolean, + "locale" character varying, + "message_display_compact" boolean, + "native_phone_integration_enabled" boolean, + "render_embeds" boolean, + "render_reactions" boolean, + "restricted_guilds" text, + "show_current_game" boolean, + "status" character varying, + "stream_notifications_enabled" boolean, + "theme" character varying, + "timezone_offset" integer, + CONSTRAINT "PK_00f004f5922a0744d174530d639" PRIMARY KEY ("id") + ) + `); + await queryRunner.query(` + ALTER TABLE "guilds" + ADD "premium_progress_bar_enabled" boolean + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "guilds" DROP COLUMN "premium_progress_bar_enabled" + `); + await queryRunner.query(` + DROP TABLE "user_settings" + `); + } + +} diff --git a/src/util/migrations/postgres/1660258372154-CodeCleanup3.ts b/src/util/migrations/postgres/1660258372154-CodeCleanup3.ts new file mode 100644
index 00000000..e2823a54 --- /dev/null +++ b/src/util/migrations/postgres/1660258372154-CodeCleanup3.ts
@@ -0,0 +1,19 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup31660258372154 implements MigrationInterface { + name = 'CodeCleanup31660258372154' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" DROP COLUMN "settings" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + ADD "settings" text NOT NULL + `); + } + +} diff --git a/src/util/migrations/postgres/1660260565996-CodeCleanup4.ts b/src/util/migrations/postgres/1660260565996-CodeCleanup4.ts new file mode 100644
index 00000000..0aaf7197 --- /dev/null +++ b/src/util/migrations/postgres/1660260565996-CodeCleanup4.ts
@@ -0,0 +1,33 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup41660260565996 implements MigrationInterface { + name = 'CodeCleanup41660260565996' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + ADD "settingsId" character varying + `); + await queryRunner.query(` + ALTER TABLE "users" + ADD CONSTRAINT "UQ_76ba283779c8441fd5ff819c8cf" UNIQUE ("settingsId") + `); + await queryRunner.query(` + ALTER TABLE "users" + ADD CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings"("id") ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" DROP CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" + `); + await queryRunner.query(` + ALTER TABLE "users" DROP CONSTRAINT "UQ_76ba283779c8441fd5ff819c8cf" + `); + await queryRunner.query(` + ALTER TABLE "users" DROP COLUMN "settingsId" + `); + } + +} diff --git a/src/util/migrations/postgres/1660265907544-CodeCleanup5.ts b/src/util/migrations/postgres/1660265907544-CodeCleanup5.ts new file mode 100644
index 00000000..157d686a --- /dev/null +++ b/src/util/migrations/postgres/1660265907544-CodeCleanup5.ts
@@ -0,0 +1,26 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup51660265907544 implements MigrationInterface { + name = 'CodeCleanup51660265907544' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "channels" + ADD "flags" integer + `); + await queryRunner.query(` + ALTER TABLE "channels" + ADD "default_thread_rate_limit_per_user" integer + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "channels" DROP COLUMN "default_thread_rate_limit_per_user" + `); + await queryRunner.query(` + ALTER TABLE "channels" DROP COLUMN "flags" + `); + } + +} diff --git a/util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts b/src/util/migrations/postgres/1660416055566-InvitersAreDeletable.ts
index e6101318..e6101318 100644 --- a/util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts +++ b/src/util/migrations/postgres/1660416055566-InvitersAreDeletable.ts
diff --git a/src/util/migrations/postgres/1660549242936-fix_nullables.ts b/src/util/migrations/postgres/1660549242936-fix_nullables.ts new file mode 100644
index 00000000..b9a0194d --- /dev/null +++ b/src/util/migrations/postgres/1660549242936-fix_nullables.ts
@@ -0,0 +1,30 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class fixNullables1660549242936 implements MigrationInterface { + name = 'fixNullables1660549242936' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + ALTER COLUMN "bio" DROP NOT NULL + `); + await queryRunner.query(` + ALTER TABLE "users" + ALTER COLUMN "mfa_enabled" DROP NOT NULL + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + ALTER COLUMN "mfa_enabled" + SET NOT NULL + `); + await queryRunner.query(` + ALTER TABLE "users" + ALTER COLUMN "bio" + SET NOT NULL + `); + } + +} diff --git a/util/src/migrations/sqlite/1659899662635-initial.ts b/src/util/migrations/sqlite/1659899662635-initial.ts
index f82e7b0d..f82e7b0d 100644 --- a/util/src/migrations/sqlite/1659899662635-initial.ts +++ b/src/util/migrations/sqlite/1659899662635-initial.ts
diff --git a/util/src/migrations/sqlite/1659921722863-premium_since_as_date.ts b/src/util/migrations/sqlite/1659921722863-premium_since_as_date.ts
index 788be625..788be625 100644 --- a/util/src/migrations/sqlite/1659921722863-premium_since_as_date.ts +++ b/src/util/migrations/sqlite/1659921722863-premium_since_as_date.ts
diff --git a/util/src/migrations/sqlite/1660130536131-updated-applications.ts b/src/util/migrations/sqlite/1660130536131-updated-applications.ts
index b8cbcc33..b8cbcc33 100644 --- a/util/src/migrations/sqlite/1660130536131-updated-applications.ts +++ b/src/util/migrations/sqlite/1660130536131-updated-applications.ts
diff --git a/src/util/migrations/sqlite/1660257576211-CodeCleanup1.ts b/src/util/migrations/sqlite/1660257576211-CodeCleanup1.ts new file mode 100644
index 00000000..5a61db0d --- /dev/null +++ b/src/util/migrations/sqlite/1660257576211-CodeCleanup1.ts
@@ -0,0 +1,326 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup11660257576211 implements MigrationInterface { + name = 'CodeCleanup11660257576211' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "user_settings" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_timeout" integer, + "allow_accessibility_detection" boolean, + "animate_emoji" boolean, + "animate_stickers" integer, + "contact_sync_enabled" boolean, + "convert_emoticons" boolean, + "custom_status" text, + "default_guilds_restricted" boolean, + "detect_platform_accounts" boolean, + "developer_mode" boolean, + "disable_games_tab" boolean, + "enable_tts_command" boolean, + "explicit_content_filter" integer, + "friend_source_flags" text, + "gateway_connected" boolean, + "gif_auto_play" boolean, + "guild_folders" text, + "guild_positions" text, + "inline_attachment_media" boolean, + "inline_embed_media" boolean, + "locale" varchar, + "message_display_compact" boolean, + "native_phone_integration_enabled" boolean, + "render_embeds" boolean, + "render_reactions" boolean, + "restricted_guilds" text, + "show_current_game" boolean, + "status" varchar, + "stream_notifications_enabled" boolean, + "theme" varchar, + "timezone_offset" integer + ) + `); + await queryRunner.query(` + CREATE TABLE "temporary_guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + "premium_progress_bar_enabled" boolean NOT NULL, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent" + FROM "guilds" + `); + await queryRunner.query(` + DROP TABLE "guilds" + `); + await queryRunner.query(` + ALTER TABLE "temporary_guilds" + RENAME TO "guilds" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "guilds" + RENAME TO "temporary_guilds" + `); + await queryRunner.query(` + CREATE TABLE "guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent" + FROM "temporary_guilds" + `); + await queryRunner.query(` + DROP TABLE "temporary_guilds" + `); + await queryRunner.query(` + DROP TABLE "user_settings" + `); + } + +} diff --git a/src/util/migrations/sqlite/1660257795259-CodeCleanup2.ts b/src/util/migrations/sqlite/1660257795259-CodeCleanup2.ts new file mode 100644
index 00000000..53698256 --- /dev/null +++ b/src/util/migrations/sqlite/1660257795259-CodeCleanup2.ts
@@ -0,0 +1,572 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup21660257795259 implements MigrationInterface { + name = 'CodeCleanup21660257795259' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "temporary_guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + "premium_progress_bar_enabled" boolean NOT NULL, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + FROM "guilds" + `); + await queryRunner.query(` + DROP TABLE "guilds" + `); + await queryRunner.query(` + ALTER TABLE "temporary_guilds" + RENAME TO "guilds" + `); + await queryRunner.query(` + CREATE TABLE "temporary_guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + "premium_progress_bar_enabled" boolean, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + FROM "guilds" + `); + await queryRunner.query(` + DROP TABLE "guilds" + `); + await queryRunner.query(` + ALTER TABLE "temporary_guilds" + RENAME TO "guilds" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "guilds" + RENAME TO "temporary_guilds" + `); + await queryRunner.query(` + CREATE TABLE "guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + "premium_progress_bar_enabled" boolean NOT NULL, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + FROM "temporary_guilds" + `); + await queryRunner.query(` + DROP TABLE "temporary_guilds" + `); + await queryRunner.query(` + ALTER TABLE "guilds" + RENAME TO "temporary_guilds" + `); + await queryRunner.query(` + CREATE TABLE "guilds" ( + "id" varchar PRIMARY KEY NOT NULL, + "afk_channel_id" varchar, + "afk_timeout" integer, + "banner" varchar, + "default_message_notifications" integer, + "description" varchar, + "discovery_splash" varchar, + "explicit_content_filter" integer, + "features" text NOT NULL, + "primary_category_id" integer, + "icon" varchar, + "large" boolean, + "max_members" integer, + "max_presences" integer, + "max_video_channel_users" integer, + "member_count" integer, + "presence_count" integer, + "template_id" varchar, + "mfa_level" integer, + "name" varchar NOT NULL, + "owner_id" varchar, + "preferred_locale" varchar, + "premium_subscription_count" integer, + "premium_tier" integer, + "public_updates_channel_id" varchar, + "rules_channel_id" varchar, + "region" varchar, + "splash" varchar, + "system_channel_id" varchar, + "system_channel_flags" integer, + "unavailable" boolean, + "verification_level" integer, + "welcome_screen" text NOT NULL, + "widget_channel_id" varchar, + "widget_enabled" boolean, + "nsfw_level" integer, + "nsfw" boolean, + "parent" varchar, + "premium_progress_bar_enabled" boolean NOT NULL, + CONSTRAINT "FK_f591a66b8019d87b0fe6c12dad6" FOREIGN KEY ("afk_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_e2a2f873a64a5cf62526de42325" FOREIGN KEY ("template_id") REFERENCES "templates" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_fc1a451727e3643ca572a3bb394" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_8d450b016dc8bec35f36729e4b0" FOREIGN KEY ("public_updates_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_95828668aa333460582e0ca6396" FOREIGN KEY ("rules_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_cfc3d3ad260f8121c95b31a1fce" FOREIGN KEY ("system_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_9d1d665379eefde7876a17afa99" FOREIGN KEY ("widget_channel_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "guilds"( + "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + ) + SELECT "id", + "afk_channel_id", + "afk_timeout", + "banner", + "default_message_notifications", + "description", + "discovery_splash", + "explicit_content_filter", + "features", + "primary_category_id", + "icon", + "large", + "max_members", + "max_presences", + "max_video_channel_users", + "member_count", + "presence_count", + "template_id", + "mfa_level", + "name", + "owner_id", + "preferred_locale", + "premium_subscription_count", + "premium_tier", + "public_updates_channel_id", + "rules_channel_id", + "region", + "splash", + "system_channel_id", + "system_channel_flags", + "unavailable", + "verification_level", + "welcome_screen", + "widget_channel_id", + "widget_enabled", + "nsfw_level", + "nsfw", + "parent", + "premium_progress_bar_enabled" + FROM "temporary_guilds" + `); + await queryRunner.query(` + DROP TABLE "temporary_guilds" + `); + } + +} diff --git a/src/util/migrations/sqlite/1660258351379-CodeCleanup3.ts b/src/util/migrations/sqlite/1660258351379-CodeCleanup3.ts new file mode 100644
index 00000000..13fba6dd --- /dev/null +++ b/src/util/migrations/sqlite/1660258351379-CodeCleanup3.ts
@@ -0,0 +1,231 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup31660258351379 implements MigrationInterface { + name = 'CodeCleanup31660258351379' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "temporary_users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + FROM "users" + `); + await queryRunner.query(` + DROP TABLE "users" + `); + await queryRunner.query(` + ALTER TABLE "temporary_users" + RENAME TO "users" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + RENAME TO "temporary_users" + `); + await queryRunner.query(` + CREATE TABLE "users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "settings" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL + ) + `); + await queryRunner.query(` + INSERT INTO "users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + FROM "temporary_users" + `); + await queryRunner.query(` + DROP TABLE "temporary_users" + `); + } + +} diff --git a/src/util/migrations/sqlite/1660260672914-CodeCleanup4.ts b/src/util/migrations/sqlite/1660260672914-CodeCleanup4.ts new file mode 100644
index 00000000..33f4df03 --- /dev/null +++ b/src/util/migrations/sqlite/1660260672914-CodeCleanup4.ts
@@ -0,0 +1,459 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup41660260672914 implements MigrationInterface { + name = 'CodeCleanup41660260672914' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "temporary_users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId") + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + FROM "users" + `); + await queryRunner.query(` + DROP TABLE "users" + `); + await queryRunner.query(` + ALTER TABLE "temporary_users" + RENAME TO "users" + `); + await queryRunner.query(` + CREATE TABLE "temporary_users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId"), + CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + FROM "users" + `); + await queryRunner.query(` + DROP TABLE "users" + `); + await queryRunner.query(` + ALTER TABLE "temporary_users" + RENAME TO "users" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + RENAME TO "temporary_users" + `); + await queryRunner.query(` + CREATE TABLE "users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId") + ) + `); + await queryRunner.query(` + INSERT INTO "users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + FROM "temporary_users" + `); + await queryRunner.query(` + DROP TABLE "temporary_users" + `); + await queryRunner.query(` + ALTER TABLE "users" + RENAME TO "temporary_users" + `); + await queryRunner.query(` + CREATE TABLE "users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL + ) + `); + await queryRunner.query(` + INSERT INTO "users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes" + FROM "temporary_users" + `); + await queryRunner.query(` + DROP TABLE "temporary_users" + `); + } + +} diff --git a/util/src/migrations/sqlite/1660416010862-InvitersAreDeletable.ts b/src/util/migrations/sqlite/1660416010862-InvitersAreDeletable.ts
index 9b29e119..9b29e119 100644 --- a/util/src/migrations/sqlite/1660416010862-InvitersAreDeletable.ts +++ b/src/util/migrations/sqlite/1660416010862-InvitersAreDeletable.ts
diff --git a/src/util/migrations/sqlite/1660538628956-sync_migrations.ts b/src/util/migrations/sqlite/1660538628956-sync_migrations.ts new file mode 100644
index 00000000..9cdc064f --- /dev/null +++ b/src/util/migrations/sqlite/1660538628956-sync_migrations.ts
@@ -0,0 +1,172 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class syncMigrations1660538628956 implements MigrationInterface { + name = 'syncMigrations1660538628956' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "temporary_channels" ( + "id" varchar PRIMARY KEY NOT NULL, + "created_at" datetime NOT NULL, + "name" varchar, + "icon" text, + "type" integer NOT NULL, + "last_message_id" varchar, + "guild_id" varchar, + "parent_id" varchar, + "owner_id" varchar, + "last_pin_timestamp" integer, + "default_auto_archive_duration" integer, + "position" integer, + "permission_overwrites" text, + "video_quality_mode" integer, + "bitrate" integer, + "user_limit" integer, + "nsfw" boolean, + "rate_limit_per_user" integer, + "topic" varchar, + "retention_policy_id" varchar, + "flags" integer, + "default_thread_rate_limit_per_user" integer, + CONSTRAINT "FK_3873ed438575cce703ecff4fc7b" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_3274522d14af40540b1a883fc80" FOREIGN KEY ("parent_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_c253dafe5f3a03ec00cd8fb4581" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_channels"( + "id", + "created_at", + "name", + "icon", + "type", + "last_message_id", + "guild_id", + "parent_id", + "owner_id", + "last_pin_timestamp", + "default_auto_archive_duration", + "position", + "permission_overwrites", + "video_quality_mode", + "bitrate", + "user_limit", + "nsfw", + "rate_limit_per_user", + "topic", + "retention_policy_id" + ) + SELECT "id", + "created_at", + "name", + "icon", + "type", + "last_message_id", + "guild_id", + "parent_id", + "owner_id", + "last_pin_timestamp", + "default_auto_archive_duration", + "position", + "permission_overwrites", + "video_quality_mode", + "bitrate", + "user_limit", + "nsfw", + "rate_limit_per_user", + "topic", + "retention_policy_id" + FROM "channels" + `); + await queryRunner.query(` + DROP TABLE "channels" + `); + await queryRunner.query(` + ALTER TABLE "temporary_channels" + RENAME TO "channels" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "channels" + RENAME TO "temporary_channels" + `); + await queryRunner.query(` + CREATE TABLE "channels" ( + "id" varchar PRIMARY KEY NOT NULL, + "created_at" datetime NOT NULL, + "name" varchar, + "icon" text, + "type" integer NOT NULL, + "last_message_id" varchar, + "guild_id" varchar, + "parent_id" varchar, + "owner_id" varchar, + "last_pin_timestamp" integer, + "default_auto_archive_duration" integer, + "position" integer, + "permission_overwrites" text, + "video_quality_mode" integer, + "bitrate" integer, + "user_limit" integer, + "nsfw" boolean, + "rate_limit_per_user" integer, + "topic" varchar, + "retention_policy_id" varchar, + CONSTRAINT "FK_3873ed438575cce703ecff4fc7b" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_3274522d14af40540b1a883fc80" FOREIGN KEY ("parent_id") REFERENCES "channels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_c253dafe5f3a03ec00cd8fb4581" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "channels"( + "id", + "created_at", + "name", + "icon", + "type", + "last_message_id", + "guild_id", + "parent_id", + "owner_id", + "last_pin_timestamp", + "default_auto_archive_duration", + "position", + "permission_overwrites", + "video_quality_mode", + "bitrate", + "user_limit", + "nsfw", + "rate_limit_per_user", + "topic", + "retention_policy_id" + ) + SELECT "id", + "created_at", + "name", + "icon", + "type", + "last_message_id", + "guild_id", + "parent_id", + "owner_id", + "last_pin_timestamp", + "default_auto_archive_duration", + "position", + "permission_overwrites", + "video_quality_mode", + "bitrate", + "user_limit", + "nsfw", + "rate_limit_per_user", + "topic", + "retention_policy_id" + FROM "temporary_channels" + `); + await queryRunner.query(` + DROP TABLE "temporary_channels" + `); + } + +} diff --git a/src/util/migrations/sqlite/1660549233583-fix_nullables.ts b/src/util/migrations/sqlite/1660549233583-fix_nullables.ts new file mode 100644
index 00000000..68f650c7 --- /dev/null +++ b/src/util/migrations/sqlite/1660549233583-fix_nullables.ts
@@ -0,0 +1,240 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class fixNullables1660549233583 implements MigrationInterface { + name = 'fixNullables1660549233583' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + CREATE TABLE "temporary_users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId"), + CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + FROM "users" + `); + await queryRunner.query(` + DROP TABLE "users" + `); + await queryRunner.query(` + ALTER TABLE "temporary_users" + RENAME TO "users" + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "users" + RENAME TO "temporary_users" + `); + await queryRunner.query(` + CREATE TABLE "users" ( + "id" varchar PRIMARY KEY NOT NULL, + "username" varchar NOT NULL, + "discriminator" varchar NOT NULL, + "avatar" varchar, + "accent_color" integer, + "banner" varchar, + "phone" varchar, + "desktop" boolean NOT NULL, + "mobile" boolean NOT NULL, + "premium" boolean NOT NULL, + "premium_type" integer NOT NULL, + "bot" boolean NOT NULL, + "bio" varchar NOT NULL, + "system" boolean NOT NULL, + "nsfw_allowed" boolean NOT NULL, + "mfa_enabled" boolean NOT NULL, + "totp_secret" varchar, + "totp_last_ticket" varchar, + "created_at" datetime NOT NULL, + "premium_since" datetime, + "verified" boolean NOT NULL, + "disabled" boolean NOT NULL, + "deleted" boolean NOT NULL, + "email" varchar, + "flags" varchar NOT NULL, + "public_flags" integer NOT NULL, + "rights" bigint NOT NULL, + "data" text NOT NULL, + "fingerprints" text NOT NULL, + "extended_settings" text NOT NULL, + "notes" text NOT NULL, + "settingsId" varchar, + CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId"), + CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "users"( + "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + ) + SELECT "id", + "username", + "discriminator", + "avatar", + "accent_color", + "banner", + "phone", + "desktop", + "mobile", + "premium", + "premium_type", + "bot", + "bio", + "system", + "nsfw_allowed", + "mfa_enabled", + "totp_secret", + "totp_last_ticket", + "created_at", + "premium_since", + "verified", + "disabled", + "deleted", + "email", + "flags", + "public_flags", + "rights", + "data", + "fingerprints", + "extended_settings", + "notes", + "settingsId" + FROM "temporary_users" + `); + await queryRunner.query(` + DROP TABLE "temporary_users" + `); + } + +} diff --git a/gateway/src/schema/Activity.ts b/src/util/schemas/ActivitySchema.ts
index e18f66c8..e18f66c8 100644 --- a/gateway/src/schema/Activity.ts +++ b/src/util/schemas/ActivitySchema.ts
diff --git a/src/util/schemas/BanCreateSchema.ts b/src/util/schemas/BanCreateSchema.ts new file mode 100644
index 00000000..64b02943 --- /dev/null +++ b/src/util/schemas/BanCreateSchema.ts
@@ -0,0 +1,5 @@ + +export interface BanCreateSchema { + delete_message_days?: string; + reason?: string; +} diff --git a/src/util/schemas/BanModeratorSchema.ts b/src/util/schemas/BanModeratorSchema.ts new file mode 100644
index 00000000..b497d319 --- /dev/null +++ b/src/util/schemas/BanModeratorSchema.ts
@@ -0,0 +1,8 @@ + +export interface BanModeratorSchema { + id: string; + user_id: string; + guild_id: string; + executor_id: string; + reason?: string | undefined; +} diff --git a/src/util/schemas/BanRegistrySchema.ts b/src/util/schemas/BanRegistrySchema.ts new file mode 100644
index 00000000..661f934f --- /dev/null +++ b/src/util/schemas/BanRegistrySchema.ts
@@ -0,0 +1,9 @@ + +export interface BanRegistrySchema { + id: string; + user_id: string; + guild_id: string; + executor_id: string; + ip?: string; + reason?: string | undefined; +} diff --git a/src/util/schemas/BulkDeleteSchema.ts b/src/util/schemas/BulkDeleteSchema.ts new file mode 100644
index 00000000..26f88374 --- /dev/null +++ b/src/util/schemas/BulkDeleteSchema.ts
@@ -0,0 +1,4 @@ + +export interface BulkDeleteSchema { + messages: string[]; +} diff --git a/src/util/schemas/ChannelModifySchema.ts b/src/util/schemas/ChannelModifySchema.ts new file mode 100644
index 00000000..3cfcf7d2 --- /dev/null +++ b/src/util/schemas/ChannelModifySchema.ts
@@ -0,0 +1,29 @@ +import { ChannelPermissionOverwriteType, ChannelType } from ".."; + + +export interface ChannelModifySchema { + /** + * @maxLength 100 + */ + name?: string; + type?: ChannelType; + topic?: string; + icon?: string | null; + bitrate?: number; + user_limit?: number; + rate_limit_per_user?: number; + position?: number; + permission_overwrites?: { + id: string; + type: ChannelPermissionOverwriteType; + allow: string; + deny: string; + }[]; + parent_id?: string; + id?: string; // is not used (only for guild create) + nsfw?: boolean; + rtc_region?: string; + default_auto_archive_duration?: number; + flags?: number; + default_thread_rate_limit_per_user?: number; +} \ No newline at end of file diff --git a/src/util/schemas/ChannelPermissionOverwriteSchema.ts b/src/util/schemas/ChannelPermissionOverwriteSchema.ts new file mode 100644
index 00000000..fe9ba860 --- /dev/null +++ b/src/util/schemas/ChannelPermissionOverwriteSchema.ts
@@ -0,0 +1,5 @@ +import { ChannelPermissionOverwrite } from "@fosscord/util"; + +// TODO: Only permissions your bot has in the guild or channel can be allowed/denied (unless your bot has a MANAGE_ROLES overwrite in the channel) + +export interface ChannelPermissionOverwriteSchema extends ChannelPermissionOverwrite { } diff --git a/src/util/schemas/ChannelReorderSchema.ts b/src/util/schemas/ChannelReorderSchema.ts new file mode 100644
index 00000000..3715f59e --- /dev/null +++ b/src/util/schemas/ChannelReorderSchema.ts
@@ -0,0 +1 @@ +export type ChannelReorderSchema = { id: string; position?: number; lock_permissions?: boolean; parent_id?: string }[]; \ No newline at end of file diff --git a/src/util/schemas/DmChannelCreateSchema.ts b/src/util/schemas/DmChannelCreateSchema.ts new file mode 100644
index 00000000..d5afc6d7 --- /dev/null +++ b/src/util/schemas/DmChannelCreateSchema.ts
@@ -0,0 +1,5 @@ + +export interface DmChannelCreateSchema { + name?: string; + recipients: string[]; +} diff --git a/src/util/schemas/EmojiCreateSchema.ts b/src/util/schemas/EmojiCreateSchema.ts new file mode 100644
index 00000000..d50c419c --- /dev/null +++ b/src/util/schemas/EmojiCreateSchema.ts
@@ -0,0 +1,7 @@ + +export interface EmojiCreateSchema { + name?: string; + image: string; + require_colons?: boolean | null; + roles?: string[]; +} diff --git a/src/util/schemas/EmojiModifySchema.ts b/src/util/schemas/EmojiModifySchema.ts new file mode 100644
index 00000000..5529dbd5 --- /dev/null +++ b/src/util/schemas/EmojiModifySchema.ts
@@ -0,0 +1,5 @@ + +export interface EmojiModifySchema { + name?: string; + roles?: string[]; +} diff --git a/src/util/schemas/GuildCreateSchema.ts b/src/util/schemas/GuildCreateSchema.ts new file mode 100644
index 00000000..e4855119 --- /dev/null +++ b/src/util/schemas/GuildCreateSchema.ts
@@ -0,0 +1,14 @@ +import { ChannelModifySchema } from "."; + +export interface GuildCreateSchema { + /** + * @maxLength 100 + */ + name: string; + region?: string; + icon?: string | null; + channels?: ChannelModifySchema[]; + guild_template_code?: string; + system_channel_id?: string; + rules_channel_id?: string; +} diff --git a/src/util/schemas/GuildTemplateCreateSchema.ts b/src/util/schemas/GuildTemplateCreateSchema.ts new file mode 100644
index 00000000..1579001e --- /dev/null +++ b/src/util/schemas/GuildTemplateCreateSchema.ts
@@ -0,0 +1,5 @@ + +export interface GuildTemplateCreateSchema { + name: string; + avatar?: string | null; +} diff --git a/src/util/schemas/GuildUpdateSchema.ts b/src/util/schemas/GuildUpdateSchema.ts new file mode 100644
index 00000000..86527cf1 --- /dev/null +++ b/src/util/schemas/GuildUpdateSchema.ts
@@ -0,0 +1,18 @@ +import { GuildCreateSchema } from "."; + +export interface GuildUpdateSchema extends Omit<GuildCreateSchema, "channels" | "name"> { + name?: string; + banner?: string | null; + splash?: string | null; + description?: string; + features?: string[]; + verification_level?: number; + default_message_notifications?: number; + system_channel_flags?: number; + explicit_content_filter?: number; + public_updates_channel_id?: string; + afk_timeout?: number; + afk_channel_id?: string; + preferred_locale?: string; + premium_progress_bar_enabled?: boolean; +} diff --git a/src/util/schemas/GuildUpdateWelcomeScreenSchema.ts b/src/util/schemas/GuildUpdateWelcomeScreenSchema.ts new file mode 100644
index 00000000..b1e36920 --- /dev/null +++ b/src/util/schemas/GuildUpdateWelcomeScreenSchema.ts
@@ -0,0 +1,11 @@ + +export interface GuildUpdateWelcomeScreenSchema { + welcome_channels?: { + channel_id: string; + description: string; + emoji_id?: string; + emoji_name: string; + }[]; + enabled?: boolean; + description?: string; +} diff --git a/gateway/src/schema/Identify.ts b/src/util/schemas/IdentifySchema.ts
index 21141321..f3d60fb3 100644 --- a/gateway/src/schema/Identify.ts +++ b/src/util/schemas/IdentifySchema.ts
@@ -1,8 +1,8 @@ -import { ActivitySchema } from "./Activity"; +import { ActivitySchema } from "./ActivitySchema"; export const IdentifySchema = { token: String, - $intents: BigInt, // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt + $intents: String, // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt $properties: Object, // { // // discord uses $ in the property key for bots, so we need to double prefix it, because instanceOf treats $ (prefix) as a optional key @@ -33,7 +33,7 @@ export const IdentifySchema = { $presence: ActivitySchema, $compress: Boolean, $large_threshold: Number, - $shard: [BigInt, BigInt], + $shard: [Number, Number], $guild_subscriptions: Boolean, $capabilities: Number, $client_state: { @@ -71,11 +71,11 @@ export interface IdentifySchema { client_version?: string; system_locale?: string; }; - intents?: bigint; // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt + intents?: string; // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt presence?: ActivitySchema; compress?: boolean; large_threshold?: number; - shard?: [bigint, bigint]; + shard?: [number, number]; guild_subscriptions?: boolean; capabilities?: number; client_state?: { diff --git a/src/util/schemas/InviteCreateSchema.ts b/src/util/schemas/InviteCreateSchema.ts new file mode 100644
index 00000000..7f6af338 --- /dev/null +++ b/src/util/schemas/InviteCreateSchema.ts
@@ -0,0 +1,12 @@ + +export interface InviteCreateSchema { + target_user_id?: string; + target_type?: string; + validate?: string; // ? what is this + max_age?: number; + max_uses?: number; + temporary?: boolean; + unique?: boolean; + target_user?: string; + target_user_type?: number; +} diff --git a/gateway/src/schema/LazyRequest.ts b/src/util/schemas/LazyRequestSchema.ts
index 1fe658bb..1fe658bb 100644 --- a/gateway/src/schema/LazyRequest.ts +++ b/src/util/schemas/LazyRequestSchema.ts
diff --git a/src/util/schemas/LoginSchema.ts b/src/util/schemas/LoginSchema.ts new file mode 100644
index 00000000..358019a8 --- /dev/null +++ b/src/util/schemas/LoginSchema.ts
@@ -0,0 +1,9 @@ + +export interface LoginSchema { + login: string; + password: string; + undelete?: boolean; + captcha_key?: string; + login_source?: string; + gift_code_sku_id?: string; +} diff --git a/src/util/schemas/MemberChangeSchema.ts b/src/util/schemas/MemberChangeSchema.ts new file mode 100644
index 00000000..a75c0ea0 --- /dev/null +++ b/src/util/schemas/MemberChangeSchema.ts
@@ -0,0 +1,4 @@ + +export interface MemberChangeSchema { + roles?: string[]; +} diff --git a/src/util/schemas/MemberNickChangeSchema.ts b/src/util/schemas/MemberNickChangeSchema.ts new file mode 100644
index 00000000..e6a6a007 --- /dev/null +++ b/src/util/schemas/MemberNickChangeSchema.ts
@@ -0,0 +1,4 @@ + +export interface MemberNickChangeSchema { + nick: string; +} diff --git a/src/util/schemas/MessageAcknowledgeSchema.ts b/src/util/schemas/MessageAcknowledgeSchema.ts new file mode 100644
index 00000000..3f4eb2b6 --- /dev/null +++ b/src/util/schemas/MessageAcknowledgeSchema.ts
@@ -0,0 +1,8 @@ +// TODO: public read receipts & privacy scoping +// TODO: send read state event to all channel members +// TODO: advance-only notification cursor + +export interface MessageAcknowledgeSchema { + manual?: boolean; + mention_count?: number; +} diff --git a/src/util/schemas/MessageCreateSchema.ts b/src/util/schemas/MessageCreateSchema.ts new file mode 100644
index 00000000..7b1cc7b9 --- /dev/null +++ b/src/util/schemas/MessageCreateSchema.ts
@@ -0,0 +1,34 @@ +import { Embed } from "@fosscord/util"; + + +export interface MessageCreateSchema { + type?: number; + content?: string; + nonce?: string; + channel_id?: string; + tts?: boolean; + flags?: string; + embeds?: Embed[]; + embed?: Embed; + // TODO: ^ embed is deprecated in favor of embeds (https://discord.com/developers/docs/resources/channel#message-object) + allowed_mentions?: { + parse?: string[]; + roles?: string[]; + users?: string[]; + replied_user?: boolean; + }; + message_reference?: { + message_id: string; + channel_id: string; + guild_id?: string; + fail_if_not_exists?: boolean; + }; + payload_json?: string; + file?: any; + /** + TODO: we should create an interface for attachments + TODO: OpenWAAO<-->attachment-style metadata conversion + **/ + attachments?: any[]; + sticker_ids?: string[]; +} diff --git a/src/util/schemas/MfaCodesSchema.ts b/src/util/schemas/MfaCodesSchema.ts new file mode 100644
index 00000000..53230841 --- /dev/null +++ b/src/util/schemas/MfaCodesSchema.ts
@@ -0,0 +1,5 @@ + +export interface MfaCodesSchema { + password: string; + regenerate?: boolean; +} diff --git a/src/util/schemas/ModifyGuildStickerSchema.ts b/src/util/schemas/ModifyGuildStickerSchema.ts new file mode 100644
index 00000000..6f24e4ce --- /dev/null +++ b/src/util/schemas/ModifyGuildStickerSchema.ts
@@ -0,0 +1,16 @@ + +export interface ModifyGuildStickerSchema { + /** + * @minLength 2 + * @maxLength 30 + */ + name: string; + /** + * @maxLength 100 + */ + description?: string; + /** + * @maxLength 200 + */ + tags: string; +} diff --git a/src/util/schemas/PruneSchema.ts b/src/util/schemas/PruneSchema.ts new file mode 100644
index 00000000..eebac763 --- /dev/null +++ b/src/util/schemas/PruneSchema.ts
@@ -0,0 +1,7 @@ + +export interface PruneSchema { + /** + * @min 0 + */ + days: number; +} diff --git a/src/util/schemas/PurgeSchema.ts b/src/util/schemas/PurgeSchema.ts new file mode 100644
index 00000000..0eeef6f2 --- /dev/null +++ b/src/util/schemas/PurgeSchema.ts
@@ -0,0 +1,5 @@ + +export interface PurgeSchema { + before: string; + after: string; +} diff --git a/src/util/schemas/RegisterSchema.ts b/src/util/schemas/RegisterSchema.ts new file mode 100644
index 00000000..e53330d2 --- /dev/null +++ b/src/util/schemas/RegisterSchema.ts
@@ -0,0 +1,27 @@ + +export interface RegisterSchema { + /** + * @minLength 2 + * @maxLength 32 + */ + username: string; + /** + * @minLength 1 + * @maxLength 72 + */ + password?: string; + consent: boolean; + /** + * @TJS-format email + */ + email?: string; + fingerprint?: string; + invite?: string; + /** + * @TJS-type string + */ + date_of_birth?: Date; // "2000-04-03" + gift_code_sku_id?: string; + captcha_key?: string; + promotional_email_opt_in?: boolean; +} diff --git a/src/util/schemas/RelationshipPostSchema.ts b/src/util/schemas/RelationshipPostSchema.ts new file mode 100644
index 00000000..40093700 --- /dev/null +++ b/src/util/schemas/RelationshipPostSchema.ts
@@ -0,0 +1,5 @@ + +export interface RelationshipPostSchema { + discriminator: string; + username: string; +} diff --git a/src/util/schemas/RelationshipPutSchema.ts b/src/util/schemas/RelationshipPutSchema.ts new file mode 100644
index 00000000..f46966e0 --- /dev/null +++ b/src/util/schemas/RelationshipPutSchema.ts
@@ -0,0 +1,6 @@ +import { RelationshipType } from "@fosscord/util"; + + +export interface RelationshipPutSchema { + type?: RelationshipType; +} diff --git a/src/util/schemas/RoleModifySchema.ts b/src/util/schemas/RoleModifySchema.ts new file mode 100644
index 00000000..d08a5022 --- /dev/null +++ b/src/util/schemas/RoleModifySchema.ts
@@ -0,0 +1,11 @@ + +export interface RoleModifySchema { + name?: string; + permissions?: string; + color?: number; + hoist?: boolean; // whether the role should be displayed separately in the sidebar + mentionable?: boolean; // whether the role should be mentionable + position?: number; + icon?: string; + unicode_emoji?: string; +} diff --git a/src/util/schemas/RolePositionUpdateSchema.ts b/src/util/schemas/RolePositionUpdateSchema.ts new file mode 100644
index 00000000..1019d504 --- /dev/null +++ b/src/util/schemas/RolePositionUpdateSchema.ts
@@ -0,0 +1,4 @@ +export type RolePositionUpdateSchema = { + id: string; + position: number; +}[]; \ No newline at end of file diff --git a/src/util/schemas/TemplateCreateSchema.ts b/src/util/schemas/TemplateCreateSchema.ts new file mode 100644
index 00000000..72c19f68 --- /dev/null +++ b/src/util/schemas/TemplateCreateSchema.ts
@@ -0,0 +1,5 @@ + +export interface TemplateCreateSchema { + name: string; + description?: string; +} diff --git a/src/util/schemas/TemplateModifySchema.ts b/src/util/schemas/TemplateModifySchema.ts new file mode 100644
index 00000000..2231a1d2 --- /dev/null +++ b/src/util/schemas/TemplateModifySchema.ts
@@ -0,0 +1,5 @@ + +export interface TemplateModifySchema { + name: string; + description?: string; +} diff --git a/src/util/schemas/TotpDisableSchema.ts b/src/util/schemas/TotpDisableSchema.ts new file mode 100644
index 00000000..b73db64e --- /dev/null +++ b/src/util/schemas/TotpDisableSchema.ts
@@ -0,0 +1,4 @@ + +export interface TotpDisableSchema { + code: string; +} diff --git a/src/util/schemas/TotpEnableSchema.ts b/src/util/schemas/TotpEnableSchema.ts new file mode 100644
index 00000000..44d9ebac --- /dev/null +++ b/src/util/schemas/TotpEnableSchema.ts
@@ -0,0 +1,6 @@ + +export interface TotpEnableSchema { + password: string; + code?: string; + secret?: string; +} diff --git a/src/util/schemas/TotpSchema.ts b/src/util/schemas/TotpSchema.ts new file mode 100644
index 00000000..fe54735e --- /dev/null +++ b/src/util/schemas/TotpSchema.ts
@@ -0,0 +1,7 @@ + +export interface TotpSchema { + code: string; + ticket: string; + gift_code_sku_id?: string | null; + login_source?: string | null; +} diff --git a/src/util/schemas/UserModifySchema.ts b/src/util/schemas/UserModifySchema.ts new file mode 100644
index 00000000..659f5841 --- /dev/null +++ b/src/util/schemas/UserModifySchema.ts
@@ -0,0 +1,19 @@ + +export interface UserModifySchema { + /** + * @minLength 1 + * @maxLength 100 + */ + username?: string; + discriminator?: string; + avatar?: string | null; + /** + * @maxLength 1024 + */ + bio?: string; + accent_color?: number; + banner?: string | null; + password?: string; + new_password?: string; + code?: string; +} diff --git a/src/util/schemas/UserSettingsSchema.ts b/src/util/schemas/UserSettingsSchema.ts new file mode 100644
index 00000000..b497dff2 --- /dev/null +++ b/src/util/schemas/UserSettingsSchema.ts
@@ -0,0 +1,4 @@ +import { UserSettings } from "@fosscord/util"; + + +export interface UserSettingsSchema extends Partial<UserSettings> { } diff --git a/src/util/schemas/VanityUrlSchema.ts b/src/util/schemas/VanityUrlSchema.ts new file mode 100644
index 00000000..de32695a --- /dev/null +++ b/src/util/schemas/VanityUrlSchema.ts
@@ -0,0 +1,8 @@ + +export interface VanityUrlSchema { + /** + * @minLength 1 + * @maxLength 20 + */ + code?: string; +} diff --git a/src/util/schemas/VoiceStateUpdateSchema.ts b/src/util/schemas/VoiceStateUpdateSchema.ts new file mode 100644
index 00000000..02bb141b --- /dev/null +++ b/src/util/schemas/VoiceStateUpdateSchema.ts
@@ -0,0 +1,18 @@ +export const VoiceStateUpdateSchema = { + $guild_id: String, + $channel_id: String, + self_mute: Boolean, + self_deaf: Boolean, + self_video: Boolean, +}; + +//TODO need more testing when community guild and voice stage channel are working +export interface VoiceStateUpdateSchema { + channel_id: string; + guild_id?: string; + suppress?: boolean; + request_to_speak_timestamp?: Date; + self_mute?: boolean; + self_deaf?: boolean; + self_video?: boolean; +} \ No newline at end of file diff --git a/src/util/schemas/WebhookCreateSchema.ts b/src/util/schemas/WebhookCreateSchema.ts new file mode 100644
index 00000000..12ab1869 --- /dev/null +++ b/src/util/schemas/WebhookCreateSchema.ts
@@ -0,0 +1,8 @@ +// TODO: webhooks +export interface WebhookCreateSchema { + /** + * @maxLength 80 + */ + name: string; + avatar?: string; +} diff --git a/src/util/schemas/WidgetModifySchema.ts b/src/util/schemas/WidgetModifySchema.ts new file mode 100644
index 00000000..390efc30 --- /dev/null +++ b/src/util/schemas/WidgetModifySchema.ts
@@ -0,0 +1,5 @@ + +export interface WidgetModifySchema { + enabled: boolean; // whether the widget is enabled + channel_id: string; // the widget channel id +} diff --git a/src/util/schemas/index.ts b/src/util/schemas/index.ts new file mode 100644
index 00000000..a15ab4b0 --- /dev/null +++ b/src/util/schemas/index.ts
@@ -0,0 +1,43 @@ +export * from "./ActivitySchema"; +export * from "./BanCreateSchema"; +export * from "./BanModeratorSchema"; +export * from "./BanRegistrySchema"; +export * from "./BulkDeleteSchema"; +export * from "./ChannelModifySchema"; +export * from "./ChannelPermissionOverwriteSchema"; +export * from "./ChannelReorderSchema"; +export * from "./DmChannelCreateSchema"; +export * from "./EmojiCreateSchema"; +export * from "./EmojiModifySchema"; +export * from "./GuildCreateSchema"; +export * from "./GuildTemplateCreateSchema"; +export * from "./GuildUpdateSchema"; +export * from "./GuildUpdateWelcomeScreenSchema"; +export * from "./IdentifySchema"; +export * from "./InviteCreateSchema"; +export * from "./LazyRequestSchema"; +export * from "./LoginSchema"; +export * from "./MemberChangeSchema"; +export * from "./MemberNickChangeSchema"; +export * from "./MessageAcknowledgeSchema"; +export * from "./MessageCreateSchema"; +export * from "./MfaCodesSchema"; +export * from "./ModifyGuildStickerSchema"; +export * from "./PruneSchema"; +export * from "./PurgeSchema"; +export * from "./RegisterSchema"; +export * from "./RelationshipPostSchema"; +export * from "./RelationshipPutSchema"; +export * from "./RoleModifySchema"; +export * from "./RolePositionUpdateSchema"; +export * from "./TemplateCreateSchema"; +export * from "./TemplateModifySchema"; +export * from "./TotpDisableSchema"; +export * from "./TotpEnableSchema"; +export * from "./TotpSchema"; +export * from "./UserModifySchema"; +export * from "./UserSettingsSchema"; +export * from "./VanityUrlSchema"; +export * from "./VoiceStateUpdateSchema"; +export * from "./WebhookCreateSchema"; +export * from "./WidgetModifySchema"; diff --git a/util/src/util/ApiError.ts b/src/util/util/ApiError.ts
index f1a9b4f6..f1a9b4f6 100644 --- a/util/src/util/ApiError.ts +++ b/src/util/util/ApiError.ts
diff --git a/util/src/util/Array.ts b/src/util/util/Array.ts
index 5a45d1b5..5a45d1b5 100644 --- a/util/src/util/Array.ts +++ b/src/util/util/Array.ts
diff --git a/util/src/util/AutoUpdate.ts b/src/util/util/AutoUpdate.ts
index 7d020106..7d020106 100644 --- a/util/src/util/AutoUpdate.ts +++ b/src/util/util/AutoUpdate.ts
diff --git a/util/src/util/BitField.ts b/src/util/util/BitField.ts
index 9bdbf6d7..9bdbf6d7 100644 --- a/util/src/util/BitField.ts +++ b/src/util/util/BitField.ts
diff --git a/util/src/util/Categories.ts b/src/util/util/Categories.ts
index a3c69da7..a3c69da7 100644 --- a/util/src/util/Categories.ts +++ b/src/util/util/Categories.ts
diff --git a/util/src/util/Config.ts b/src/util/util/Config.ts
index 97a73858..e0fb2a81 100644 --- a/util/src/util/Config.ts +++ b/src/util/util/Config.ts
@@ -1,9 +1,10 @@ -import { ConfigValue, ConfigEntity, DefaultConfigOptions } from "../entities/Config"; -import path from "path"; +import { ConfigEntity } from "../entities/Config"; import fs from "fs"; +import { ConfigValue } from "../config"; +import { OrmUtils } from "."; // TODO: yaml instead of json -// const overridePath = path.join(process.cwd(), "config.json"); +const overridePath = process.env.CONFIG_PATH ?? ""; let config: ConfigValue; let pairs: ConfigEntity[]; @@ -14,20 +15,29 @@ let pairs: ConfigEntity[]; export const Config = { init: async function init() { if (config) return config; + console.log('[Config] Loading configuration...') pairs = await ConfigEntity.find(); config = pairsToConfig(pairs); - config = (config || {}).merge(DefaultConfigOptions); - - // try { - // const overrideConfig = JSON.parse(fs.readFileSync(overridePath, { encoding: "utf8" })); - // config = overrideConfig.merge(config); - // } catch (error) { - // fs.writeFileSync(overridePath, JSON.stringify(config, null, 4)); - // } + //config = (config || {}).merge(new ConfigValue()); + config = OrmUtils.mergeDeep(new ConfigValue(), config) + + if(process.env.CONFIG_PATH) + try { + const overrideConfig = JSON.parse(fs.readFileSync(overridePath, { encoding: "utf8" })); + config = overrideConfig.merge(config); + } catch (error) { + fs.writeFileSync(overridePath, JSON.stringify(config, null, 4)); + } + return this.set(config); }, get: function get() { + if(!config) { + if(/--debug|--inspect/.test(process.execArgv.join(' '))) + console.log("Oops.. trying to get config without config existing... Returning defaults... (Is the database still initialising?)"); + return new ConfigValue(); + } return config; }, set: function set(val: Partial<ConfigValue>) { @@ -50,7 +60,11 @@ function applyConfig(val: ConfigValue) { pair.value = obj; return pair.save(); } - // fs.writeFileSync(overridePath, JSON.stringify(val, null, 4)); + if(process.env.CONFIG_PATH) { + if(/--debug|--inspect/.test(process.execArgv.join(' '))) + console.log(`Writing config: ${process.env.CONFIG_PATH}`) + fs.writeFileSync(overridePath, JSON.stringify(val, null, 4)); + } return apply(val); } diff --git a/util/src/util/Constants.ts b/src/util/util/Constants.ts
index a5d3fcd2..a5d3fcd2 100644 --- a/util/src/util/Constants.ts +++ b/src/util/util/Constants.ts
diff --git a/util/src/util/Database.ts b/src/util/util/Database.ts
index 84ce473d..84ce473d 100644 --- a/util/src/util/Database.ts +++ b/src/util/util/Database.ts
diff --git a/util/src/util/Email.ts b/src/util/util/Email.ts
index 6885da33..6885da33 100644 --- a/util/src/util/Email.ts +++ b/src/util/util/Email.ts
diff --git a/util/src/util/Event.ts b/src/util/util/Event.ts
index 90c24347..90c24347 100644 --- a/util/src/util/Event.ts +++ b/src/util/util/Event.ts
diff --git a/util/src/util/FieldError.ts b/src/util/util/FieldError.ts
index 49968e1a..49968e1a 100644 --- a/util/src/util/FieldError.ts +++ b/src/util/util/FieldError.ts
diff --git a/util/src/util/Intents.ts b/src/util/util/Intents.ts
index 1e840b76..1e840b76 100644 --- a/util/src/util/Intents.ts +++ b/src/util/util/Intents.ts
diff --git a/util/src/util/InvisibleCharacters.ts b/src/util/util/InvisibleCharacters.ts
index 2b014e14..2b014e14 100644 --- a/util/src/util/InvisibleCharacters.ts +++ b/src/util/util/InvisibleCharacters.ts
diff --git a/util/src/util/MFA.ts b/src/util/util/MFA.ts
index 2e47b2fc..2e47b2fc 100644 --- a/util/src/util/MFA.ts +++ b/src/util/util/MFA.ts
diff --git a/util/src/util/MessageFlags.ts b/src/util/util/MessageFlags.ts
index b59295c4..b59295c4 100644 --- a/util/src/util/MessageFlags.ts +++ b/src/util/util/MessageFlags.ts
diff --git a/util/src/util/Permissions.ts b/src/util/util/Permissions.ts
index c7400303..c7400303 100644 --- a/util/src/util/Permissions.ts +++ b/src/util/util/Permissions.ts
diff --git a/util/src/util/RabbitMQ.ts b/src/util/util/RabbitMQ.ts
index 0f5eb6aa..0f5eb6aa 100644 --- a/util/src/util/RabbitMQ.ts +++ b/src/util/util/RabbitMQ.ts
diff --git a/util/src/util/Regex.ts b/src/util/util/Regex.ts
index 83fc9fe8..83fc9fe8 100644 --- a/util/src/util/Regex.ts +++ b/src/util/util/Regex.ts
diff --git a/util/src/util/Rights.ts b/src/util/util/Rights.ts
index 1c3906fb..1c3906fb 100644 --- a/util/src/util/Rights.ts +++ b/src/util/util/Rights.ts
diff --git a/util/src/util/Snowflake.ts b/src/util/util/Snowflake.ts
index 0ef178fe..0ef178fe 100644 --- a/util/src/util/Snowflake.ts +++ b/src/util/util/Snowflake.ts
diff --git a/util/src/util/String.ts b/src/util/util/String.ts
index 55f11e8d..55f11e8d 100644 --- a/util/src/util/String.ts +++ b/src/util/util/String.ts
diff --git a/util/src/util/Token.ts b/src/util/util/Token.ts
index 5a3922d1..5a3922d1 100644 --- a/util/src/util/Token.ts +++ b/src/util/util/Token.ts
diff --git a/util/src/util/TraverseDirectory.ts b/src/util/util/TraverseDirectory.ts
index 3d0d6279..3d0d6279 100644 --- a/util/src/util/TraverseDirectory.ts +++ b/src/util/util/TraverseDirectory.ts
diff --git a/util/src/util/cdn.ts b/src/util/util/cdn.ts
index 9cfe4896..9cfe4896 100644 --- a/util/src/util/cdn.ts +++ b/src/util/util/cdn.ts
diff --git a/util/src/util/imports/Checks.ts b/src/util/util/imports/Checks.ts
index 19a84171..19a84171 100644 --- a/util/src/util/imports/Checks.ts +++ b/src/util/util/imports/Checks.ts
diff --git a/util/src/util/imports/HTTPError.ts b/src/util/util/imports/HTTPError.ts
index 56a7dd55..56a7dd55 100644 --- a/util/src/util/imports/HTTPError.ts +++ b/src/util/util/imports/HTTPError.ts
diff --git a/util/src/util/imports/OrmUtils.ts b/src/util/util/imports/OrmUtils.ts
index 91d88172..91d88172 100644 --- a/util/src/util/imports/OrmUtils.ts +++ b/src/util/util/imports/OrmUtils.ts
diff --git a/util/src/util/imports/index.ts b/src/util/util/imports/index.ts
index 18c47a3b..18c47a3b 100644 --- a/util/src/util/imports/index.ts +++ b/src/util/util/imports/index.ts
diff --git a/util/src/util/index.ts b/src/util/util/index.ts
index 9e6059fa..9e6059fa 100644 --- a/util/src/util/index.ts +++ b/src/util/util/index.ts