mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
feat: remove Canary Testers guild integration (#1572)
This commit is contained in:
1 parent
a9a51f576c
commit
f88b0f69b2
56 files changed
+1156
-4266
No files matched your search
@@ -4,7 +4,6 @@ import {registerAdminControllers} from '../admin/controllers/index';
|
||||
import {AuthController} from '../auth/AuthController';
|
||||
import {BlueskyOAuthController} from '../bluesky/BlueskyOAuthController';
|
||||
import {Config} from '../Config';
|
||||
import {CanaryTesterController} from '../canary_tester/CanaryTesterController';
|
||||
import {ChannelController} from '../channel/ChannelController';
|
||||
import type {APIConfig} from '../config/APIConfig';
|
||||
import {ConnectionController} from '../connection/ConnectionController';
|
||||
@@ -67,7 +66,6 @@ export function registerControllers(routes: HonoApp, config: APIConfig): void {
|
||||
TestHarnessController(routes);
|
||||
}
|
||||
UserController(routes);
|
||||
CanaryTesterController(routes);
|
||||
registerInboundSmsWebhook(routes);
|
||||
WebhookController(routes);
|
||||
OAuth2Controller(routes);
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {CANARY_TESTER_MIN_ACCOUNT_AGE_MS, CANARY_TESTERS_GUILD_ID} from '@fluxer/constants/src/AppConstants';
|
||||
import {JoinSourceTypes} from '@fluxer/constants/src/GuildConstants';
|
||||
import {CanaryTesterEmailVerificationRequiredError} from '@fluxer/errors/src/domains/auth/EmailVerificationRequiredError';
|
||||
import {AccountTooNewForGuildError} from '@fluxer/errors/src/domains/guild/AccountTooNewForGuildError';
|
||||
import {AccountSuspiciousActivityError} from '@fluxer/errors/src/domains/user/AccountSuspiciousActivityError';
|
||||
import {SuccessResponse} from '@fluxer/schema/src/domains/common/CommonParamSchemas';
|
||||
import {extractTimestampFromSnowflakeAsDateBigInt} from '@fluxer/snowflake/src/SnowflakeUtils';
|
||||
import {createGuildID} from '../BrandedTypes';
|
||||
import {DefaultUserOnly, LoginRequired} from '../middleware/AuthMiddleware';
|
||||
import {RateLimitMiddleware} from '../middleware/RateLimitMiddleware';
|
||||
import {OpenAPI} from '../middleware/ResponseTypeMiddleware';
|
||||
import {RateLimitConfigs} from '../RateLimitConfig';
|
||||
import type {HonoApp} from '../types/HonoEnv';
|
||||
import {getEffectiveSuspiciousFlags} from '../user/UserHelpers';
|
||||
|
||||
export function CanaryTesterController(app: HonoApp) {
|
||||
app.post(
|
||||
'/users/@me/canary-tester/join',
|
||||
RateLimitMiddleware(RateLimitConfigs.USER_CANARY_TESTER_JOIN),
|
||||
LoginRequired,
|
||||
DefaultUserOnly,
|
||||
OpenAPI({
|
||||
operationId: 'join_canary_testers',
|
||||
summary: 'Join the canary testers guild',
|
||||
description:
|
||||
'Adds the authenticated user to the hardcoded Fluxer Testers guild used for canary feedback. Restricted to non-bot users with verified email, an account at least 30 minutes old, no effective suspicious-activity flags, and not banned from the target guild. Rate-limited; surfaced via the canary nagbar.',
|
||||
responseSchema: SuccessResponse,
|
||||
statusCode: 200,
|
||||
security: ['bearerToken', 'sessionToken'],
|
||||
tags: ['Users'],
|
||||
}),
|
||||
async (ctx) => {
|
||||
const user = ctx.get('user');
|
||||
const userId = user.id;
|
||||
if (!user.email || !user.emailVerified) {
|
||||
throw new CanaryTesterEmailVerificationRequiredError();
|
||||
}
|
||||
const accountCreatedAt = extractTimestampFromSnowflakeAsDateBigInt(BigInt(userId.toString()));
|
||||
if (Date.now() - accountCreatedAt.getTime() < CANARY_TESTER_MIN_ACCOUNT_AGE_MS) {
|
||||
throw new AccountTooNewForGuildError();
|
||||
}
|
||||
const effectiveFlags = getEffectiveSuspiciousFlags(user);
|
||||
if (effectiveFlags !== 0) {
|
||||
throw new AccountSuspiciousActivityError(effectiveFlags);
|
||||
}
|
||||
const guildService = ctx.get('guildService');
|
||||
const requestCache = ctx.get('requestCache');
|
||||
const guildId = createGuildID(BigInt(CANARY_TESTERS_GUILD_ID));
|
||||
await guildService.members.addUserToGuild({
|
||||
userId,
|
||||
guildId,
|
||||
sendJoinMessage: true,
|
||||
requestCache,
|
||||
joinSourceType: JoinSourceTypes.INSTANT_INVITE,
|
||||
});
|
||||
return ctx.json({success: true} satisfies SuccessResponse);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -16130,73 +16130,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/@me/canary-tester/join": {
|
||||
"post": {
|
||||
"operationId": "join_canary_testers",
|
||||
"summary": "Join the canary testers guild",
|
||||
"tags": ["Users"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
"content": {"application/json": {"schema": {"$ref": "#/components/schemas/SuccessResponse"}}}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request - The request was malformed or contained invalid data",
|
||||
"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized - Authentication is required or the token is invalid",
|
||||
"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden - You do not have permission to perform this action",
|
||||
"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}
|
||||
},
|
||||
"429": {
|
||||
"description": "Too Many Requests - You are being rate limited",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {"type": "string", "enum": ["RATE_LIMITED"]},
|
||||
"message": {"type": "string"},
|
||||
"retry_after": {"type": "number", "description": "Seconds to wait before retrying"},
|
||||
"global": {"type": "boolean", "description": "Whether this is a global rate limit"}
|
||||
},
|
||||
"required": ["code", "message", "retry_after"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"headers": {
|
||||
"Retry-After": {
|
||||
"description": "Number of seconds to wait before retrying (only on 429)",
|
||||
"schema": {"type": "integer"}
|
||||
},
|
||||
"X-RateLimit-Limit": {
|
||||
"description": "The number of requests that can be made in the current window",
|
||||
"schema": {"type": "integer"}
|
||||
},
|
||||
"X-RateLimit-Remaining": {
|
||||
"description": "The number of remaining requests that can be made",
|
||||
"schema": {"type": "integer"}
|
||||
},
|
||||
"X-RateLimit-Reset": {
|
||||
"description": "Unix timestamp when the rate limit resets",
|
||||
"schema": {"type": "integer"}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error - An unexpected error occurred",
|
||||
"content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}
|
||||
}
|
||||
},
|
||||
"x-mint": {"metadata": {"title": "Join the canary testers guild"}},
|
||||
"description": "Adds the authenticated user to the hardcoded Fluxer Testers guild used for canary feedback. Restricted to non-bot users with verified email, an account at least 30 minutes old, no effective suspicious-activity flags, and not banned from the target guild. Rate-limited; surfaced via the canary nagbar.",
|
||||
"security": [{"sessionToken": []}]
|
||||
}
|
||||
},
|
||||
"/users/@me/channels": {
|
||||
"get": {
|
||||
"operationId": "list_private_channels",
|
||||
@@ -25206,7 +25139,6 @@
|
||||
"DISCRIMINATOR_REQUIRED",
|
||||
"EMAIL_SERVICE_NOT_TESTABLE",
|
||||
"EMAIL_VERIFICATION_REQUIRED",
|
||||
"CANARY_TESTER_EMAIL_VERIFICATION_REQUIRED",
|
||||
"DIRECT_MESSAGE_EMAIL_VERIFICATION_REQUIRED",
|
||||
"FRIEND_REQUEST_EMAIL_VERIFICATION_REQUIRED",
|
||||
"GUILD_CREATION_EMAIL_VERIFICATION_REQUIRED",
|
||||
@@ -25532,7 +25464,6 @@
|
||||
"Email verification is required for this action.",
|
||||
"Email verification is required for this action.",
|
||||
"Email verification is required for this action.",
|
||||
"Email verification is required for this action.",
|
||||
"Registration is closed on this instance.",
|
||||
"This registration is waiting for admin approval.",
|
||||
"This registration request was rejected.",
|
||||
|
||||
@@ -216,10 +216,6 @@ export const UserRateLimitConfigs = {
|
||||
bucket: 'user:harvest:download',
|
||||
config: {limit: 10, windowMs: ms('1 minute')},
|
||||
} as RouteRateLimitConfig,
|
||||
USER_CANARY_TESTER_JOIN: {
|
||||
bucket: 'user:canary_tester:join',
|
||||
config: {limit: 3, windowMs: ms('1 hour')},
|
||||
} as RouteRateLimitConfig,
|
||||
USER_ENTRANCE_SOUND_LIST: {
|
||||
bucket: 'user:entrance_sound:list',
|
||||
config: {limit: 30, windowMs: ms('1 minute')},
|
||||
|
||||
Reference in new issue
Block a user