Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(schema): add user create, admin sign-in link, delete now

Hampus0829b15d8356
diff --git a/packages/schema/src/domains/admin/AdminUserSchemas.ts b/packages/schema/src/domains/admin/AdminUserSchemas.ts
index ee3e705e9..a020d6d37 100644
--- a/packages/schema/src/domains/admin/AdminUserSchemas.ts
+++ b/packages/schema/src/domains/admin/AdminUserSchemas.ts
@@ -7,6 +7,7 @@ import {
UserFlags,
UserFlagsDescriptions,
} from '@fluxer/constants/src/UserConstants';
+import {AccountTierSchema} from '@fluxer/schema/src/domains/account/AccountTierSchemas';
import {ADMIN_ACL_COUNT, AdminAclType} from '@fluxer/schema/src/domains/admin/AdminAclType';
import {
BulkModerationBasis,
@@ -14,6 +15,7 @@ import {
NetworkBlockRequest,
SkippedNetworkBlock,
} from '@fluxer/schema/src/domains/admin/EnforcementSchemas';
+import {AdminProfileBadgeResponse} from '@fluxer/schema/src/domains/user/ProfileBadgeSchemas';
import {CalendarDateType} from '@fluxer/schema/src/primitives/DateValidators';
import {NSFWLevelSchema} from '@fluxer/schema/src/primitives/GuildValidators';
import {createQueryIntegerType, QueryBooleanType} from '@fluxer/schema/src/primitives/QueryValidators';
@@ -65,6 +67,9 @@ export const UserAdminResponseSchema = z.object({
premium_until: z.string().nullable(),
premium_grace_ends_at: z.string().nullable(),
premium_lifetime_sequence: Int32Type.nullable(),
+ profile_badges: z
+ .array(AdminProfileBadgeResponse)
+ .describe('Every badge the account qualifies for in display order, including ones hidden from the public'),
temp_banned_until: z.string().nullable(),
pending_deletion_at: z.string().nullable(),
pending_bulk_message_deletion_at: z.string().nullable(),
@@ -87,6 +92,12 @@ export const UserAdminResponseSchema = z.object({
acls: z.array(z.string()).max(ADMIN_ACL_COUNT),
traits: z.array(z.string()).max(100),
has_totp: z.boolean(),
+ has_password: z.boolean().describe('Whether the account has a password'),
+ claimed: z.boolean().describe('Whether the account can be signed in to from another device'),
+ account_tier: AccountTierSchema.describe('How far the account has got with setting up a way to sign in'),
+ date_of_birth_required: z
+ .boolean()
+ .describe('Whether the account still has to enter its date of birth, which clients ask for before anything else'),
authenticator_types: z.array(Int32Type).max(10),
last_active_at: z.string().nullable(),
last_active_ip: z.string().nullable(),
@@ -309,6 +320,32 @@ export const AdminPasswordResetLinkResponse = z.object({
export type AdminPasswordResetLinkResponse = z.infer<typeof AdminPasswordResetLinkResponse>;
+export const AdminSignInLinkResponse = z.object({
+ url: z.string().describe('Sign-in link to open in a browser. It works once and is shown only once'),
+ expires_at: z.iso.datetime().describe('ISO 8601 timestamp when the link stops working'),
+});
+
+export type AdminSignInLinkResponse = z.infer<typeof AdminSignInLinkResponse>;
+
+export const AdminUserCreateRequest = z.object({
+ username: UsernameType.describe('Username for the new account'),
+ email: EmailType.optional().describe(
+ 'Email address for the new account. Required on an instance where people sign in with email, and refused where they sign in with a username',
+ ),
+ admin: z.boolean().default(false).describe('Whether to give the new account full admin access'),
+});
+
+export type AdminUserCreateRequest = z.infer<typeof AdminUserCreateRequest>;
+
+export const AdminUserCreateResponse = z.object({
+ user: UserAdminResponseSchema,
+ password_reset: AdminPasswordResetLinkResponse.describe(
+ 'One-time link the new user opens to choose a password. Hand it to them yourself',
+ ),
+});
+
+export type AdminUserCreateResponse = z.infer<typeof AdminUserCreateResponse>;
+
export const ChangeUsernameRequest = z.object({
user_id: SnowflakeType.describe('ID of the user to change username for'),
username: UsernameType.describe('New username for the user'),
@@ -479,6 +516,9 @@ export const AdminUserListQuery = z.object({
last_active_ip: createStringType(1, 64)
.optional()
.describe('Restrict the results to the users whose last active IP address matches this one exactly'),
+ acl: AdminAclType.optional().describe(
+ 'Restrict the results to the users granted this admin permission, ordered by user ID. Pass * to list the admins with full access',
+ ),
limit: createQueryIntegerType({defaultValue: 50, minValue: 1, maxValue: 200}).describe(
'Maximum number of users to return',
),
@@ -591,6 +631,12 @@ export const AdminUserDeletionScheduleRequest = z.object({
.optional()
.describe('Remove the evidence messages after they are snapshotted into the decision. Enforcement basis only'),
block_networks: NetworkBlockRequest.optional(),
+ immediate: z
+ .boolean()
+ .optional()
+ .describe(
+ 'Self-hosted instances only. Delete the account now instead of after days_until_deletion, with no notice email. This cannot be undone',
+ ),
});
export type AdminUserDeletionScheduleRequest = z.infer<typeof AdminUserDeletionScheduleRequest>;