mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
fix: 🚨 Fix Deepsource warnings
This commit is contained in:
parent
2fffbcbede
commit
870b6dbe85
13 changed files with 58 additions and 59 deletions
|
|
@ -18,7 +18,7 @@ await build({
|
|||
"acorn",
|
||||
// Excluded because Standard Schema imports those, but the code is never executed
|
||||
"@valibot/to-json-schema",
|
||||
"effect"
|
||||
"effect",
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -180,19 +180,19 @@ export class Instance extends BaseInterface<typeof Instances> {
|
|||
|
||||
// Go to endpoint, then follow the links to the actual metadata
|
||||
try {
|
||||
const { json, ok, status } = await fetch(wellKnownUrl, {
|
||||
const result = await fetch(wellKnownUrl, {
|
||||
// @ts-expect-error Bun extension
|
||||
proxy: config.http.proxy_address,
|
||||
});
|
||||
|
||||
if (!ok) {
|
||||
if (!result.ok) {
|
||||
federationResolversLogger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold(
|
||||
origin,
|
||||
)} - HTTP ${status}`;
|
||||
)} - HTTP ${result.status}`;
|
||||
return null;
|
||||
}
|
||||
|
||||
const wellKnown = (await json()) as {
|
||||
const wellKnown = (await result.json()) as {
|
||||
links: { rel: string; href: string }[];
|
||||
};
|
||||
|
||||
|
|
@ -216,23 +216,19 @@ export class Instance extends BaseInterface<typeof Instances> {
|
|||
return null;
|
||||
}
|
||||
|
||||
const {
|
||||
json: json2,
|
||||
ok: ok2,
|
||||
status: status2,
|
||||
} = await fetch(metadataUrl.href, {
|
||||
const result2 = await fetch(metadataUrl.href, {
|
||||
// @ts-expect-error Bun extension
|
||||
proxy: config.http.proxy_address,
|
||||
});
|
||||
|
||||
if (!ok2) {
|
||||
if (!result2.ok) {
|
||||
federationResolversLogger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold(
|
||||
origin,
|
||||
)} - HTTP ${status2}`;
|
||||
)} - HTTP ${result2.status}`;
|
||||
return null;
|
||||
}
|
||||
|
||||
const metadata = (await json2()) as {
|
||||
const metadata = (await result2.json()) as {
|
||||
metadata: {
|
||||
nodeName?: string;
|
||||
title?: string;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ enum TimelineType {
|
|||
}
|
||||
|
||||
export class Timeline<Type extends Note | User | Notification> {
|
||||
public constructor(private type: TimelineType) {}
|
||||
public constructor(private readonly type: TimelineType) {}
|
||||
|
||||
public static getNoteTimeline(
|
||||
sql: SQL<unknown> | undefined,
|
||||
|
|
|
|||
|
|
@ -55,14 +55,14 @@ export class InboxProcessor {
|
|||
* @param requestIp Request IP address. Grabs it from the Hono context if not provided.
|
||||
*/
|
||||
public constructor(
|
||||
private request: Request,
|
||||
private body: JSONObject,
|
||||
private sender: {
|
||||
private readonly request: Request,
|
||||
private readonly body: JSONObject,
|
||||
private readonly sender: {
|
||||
instance: Instance;
|
||||
key: CryptoKey;
|
||||
} | null,
|
||||
private authorizationHeader?: string,
|
||||
private requestIp: SocketAddress | null = null,
|
||||
private readonly authorizationHeader?: string,
|
||||
private readonly requestIp: SocketAddress | null = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
|
|
@ -208,7 +208,7 @@ export class InboxProcessor {
|
|||
throw new ApiError(400, "Unknown entity type");
|
||||
});
|
||||
} catch (e) {
|
||||
return this.handleError(e as Error);
|
||||
return InboxProcessor.handleError(e as Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -589,7 +589,7 @@ export class InboxProcessor {
|
|||
* @returns {void}
|
||||
* @throws {ApiError} - The error response.
|
||||
*/
|
||||
private handleError(e: Error): void {
|
||||
private static handleError(e: Error): void {
|
||||
if (isValidationError(e)) {
|
||||
throw new ApiError(400, "Failed to process request", e.message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,15 @@ export type HonoPluginEnv<ConfigType extends z.ZodTypeAny> = HonoEnv & {
|
|||
};
|
||||
|
||||
export class Plugin<ConfigSchema extends z.ZodTypeAny> {
|
||||
private handlers: Partial<ServerHooks> = {};
|
||||
private readonly handlers: Partial<ServerHooks> = {};
|
||||
// biome-ignore lint/nursery/useReadonlyClassProperties: biome is wrong lol
|
||||
private store: z.infer<ConfigSchema> | null = null;
|
||||
private routes: {
|
||||
private readonly routes: {
|
||||
path: string;
|
||||
fn: (app: Hono<HonoPluginEnv<ConfigSchema>>) => void;
|
||||
}[] = [];
|
||||
|
||||
public constructor(private configSchema: ConfigSchema) {}
|
||||
public constructor(private readonly configSchema: ConfigSchema) {}
|
||||
|
||||
public get middleware(): MiddlewareHandler<HonoPluginEnv<ConfigSchema>> {
|
||||
// Middleware that adds the plugin's configuration to the request object
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@ export enum SonicIndexType {
|
|||
* Class for managing Sonic search operations
|
||||
*/
|
||||
export class SonicSearchManager {
|
||||
private searchChannel: SonicChannelSearch;
|
||||
private ingestChannel: SonicChannelIngest;
|
||||
private readonly searchChannel: SonicChannelSearch;
|
||||
private readonly ingestChannel: SonicChannelIngest;
|
||||
// biome-ignore lint/nursery/useReadonlyClassProperties: biome is wrong lol
|
||||
private connected = false;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -74,7 +74,10 @@ export class StreamingTimeline {
|
|||
return `timeline:${this.timeline}`;
|
||||
}
|
||||
|
||||
private messageHandler = (channel: string, message: string): void => {
|
||||
private readonly messageHandler = (
|
||||
channel: string,
|
||||
message: string,
|
||||
): void => {
|
||||
if (channel === this.channelName) {
|
||||
try {
|
||||
const parsed = JSON.parse(message);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue