mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
chore(repo): prune dead code and duplicate abstractions (#3413)
This commit is contained in:
1 parent
c17091768c
commit
c9fdf8fead
2937 files changed
+42233
-176793
No files matched your search
@@ -1,5 +1,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
export {type RecordedJob, RecordingWorkerService} from '@app/api/test/RecordingWorkerService';
|
||||
|
||||
import {createTestAccount, type TestAccount} from '@app/api/auth/tests/AuthTestUtils';
|
||||
import {createChannelID, createGuildID, createMessageID} from '@app/api/BrandedTypes';
|
||||
import {createApiContext} from '@app/api/CreateApiContext';
|
||||
@@ -14,7 +16,6 @@ import {
|
||||
createChannelInvite,
|
||||
createGuild,
|
||||
createRole,
|
||||
sendChannelMessage,
|
||||
} from '@app/api/channel/tests/ChannelTestUtils';
|
||||
import type {GuildRow} from '@app/api/database/types/GuildTypes';
|
||||
import {GuildRepository} from '@app/api/guild/repositories/GuildRepository';
|
||||
@@ -55,45 +56,6 @@ import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants'
|
||||
import type {ChannelResponse} from '@fluxer/schema/src/domains/channel/ChannelSchemas';
|
||||
import type {GuildResponse} from '@fluxer/schema/src/domains/guild/GuildResponseSchemas';
|
||||
import type {MessageResponse} from '@fluxer/schema/src/domains/message/MessageResponseSchemas';
|
||||
import type {IWorkerService} from '@pkgs/worker/src/contracts/IWorkerService';
|
||||
import type {WorkerJobOptions, WorkerJobPayload} from '@pkgs/worker/src/contracts/WorkerTypes';
|
||||
|
||||
export interface RecordedJob {
|
||||
taskType: string;
|
||||
payload: WorkerJobPayload;
|
||||
options: WorkerJobOptions | undefined;
|
||||
}
|
||||
|
||||
export class RecordingWorkerService implements IWorkerService {
|
||||
readonly jobs: Array<RecordedJob> = [];
|
||||
failure: ((taskType: string) => Error | null) | null = null;
|
||||
private nextJobId = 1n;
|
||||
|
||||
async addJob<TPayload extends WorkerJobPayload = WorkerJobPayload>(
|
||||
taskType: string,
|
||||
payload: TPayload,
|
||||
options?: WorkerJobOptions,
|
||||
): Promise<bigint> {
|
||||
const error = this.failure?.(taskType) ?? null;
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
this.jobs.push({taskType, payload, options});
|
||||
return this.nextJobId++;
|
||||
}
|
||||
|
||||
async cancelJob(_jobId: bigint): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
byTask(taskType: string): Array<RecordedJob> {
|
||||
return this.jobs.filter((job) => job.taskType === taskType);
|
||||
}
|
||||
|
||||
syncJobsFor(messageId: string): Array<RecordedJob> {
|
||||
return this.byTask('syncCrosspostedMessage').filter((job) => job.payload.messageId === messageId);
|
||||
}
|
||||
}
|
||||
|
||||
export interface AnnouncementWorld {
|
||||
owner: TestAccount;
|
||||
@@ -128,24 +90,6 @@ export async function createAnnouncementWorld(harness: ApiTestHarness): Promise<
|
||||
return {owner, author, mod, member, guild, announcement, text, modRoleId: modRole.id};
|
||||
}
|
||||
|
||||
export async function createAnnouncementChannel(
|
||||
harness: ApiTestHarness,
|
||||
token: string,
|
||||
guildId: string,
|
||||
name: string,
|
||||
): Promise<ChannelResponse> {
|
||||
return createChannel(harness, token, guildId, name, ChannelTypes.GUILD_ANNOUNCEMENT);
|
||||
}
|
||||
|
||||
export async function postMessage(
|
||||
harness: ApiTestHarness,
|
||||
token: string,
|
||||
channelId: string,
|
||||
content: string,
|
||||
): Promise<MessageResponse> {
|
||||
return sendChannelMessage(harness, token, channelId, content);
|
||||
}
|
||||
|
||||
export function crosspostRequest(harness: ApiTestHarness, token: string, channelId: string, messageId: string) {
|
||||
return createBuilder<MessageResponse>(harness, token).post(`/channels/${channelId}/messages/${messageId}/crosspost`);
|
||||
}
|
||||
@@ -272,3 +216,5 @@ export function createTestChannelService(): ChannelService {
|
||||
voiceAvailabilityService: getVoiceAvailabilityService(),
|
||||
}).channelService;
|
||||
}
|
||||
|
||||
export {sendChannelMessage as postMessage} from '@app/api/channel/tests/ChannelTestUtils';
|
||||
Reference in new issue
Block a user