mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
refactor(federation): 🔊 Add more logging to some federation logic
This commit is contained in:
parent
ef0cca671a
commit
b333ecc816
|
|
@ -716,6 +716,7 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async resolve(uri: string): Promise<User | null> {
|
public static async resolve(uri: string): Promise<User | null> {
|
||||||
|
getLogger("federation").debug`Resolving user ${chalk.bold(uri)}`;
|
||||||
// Check if user not already in database
|
// Check if user not already in database
|
||||||
const foundUser = await User.fromSql(eq(Users.uri, uri));
|
const foundUser = await User.fromSql(eq(Users.uri, uri));
|
||||||
|
|
||||||
|
|
@ -736,6 +737,9 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
||||||
return await User.fromId(uuid[0]);
|
return await User.fromId(uuid[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLogger("federation")
|
||||||
|
.debug`User not found in database, fetching from remote`;
|
||||||
|
|
||||||
return await User.saveFromRemote(uri);
|
return await User.saveFromRemote(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
13
worker.ts
13
worker.ts
|
|
@ -3,6 +3,7 @@ import type { Entity } from "@versia/federation/types";
|
||||||
import { Instance, Note, User } from "@versia/kit/db";
|
import { Instance, Note, User } from "@versia/kit/db";
|
||||||
import { Queue, Worker } from "bullmq";
|
import { Queue, Worker } from "bullmq";
|
||||||
import type { SocketAddress } from "bun";
|
import type { SocketAddress } from "bun";
|
||||||
|
import chalk from "chalk";
|
||||||
import IORedis from "ioredis";
|
import IORedis from "ioredis";
|
||||||
import { InboxProcessor } from "./classes/inbox/processor.ts";
|
import { InboxProcessor } from "./classes/inbox/processor.ts";
|
||||||
import { config } from "./packages/config-manager/index.ts";
|
import { config } from "./packages/config-manager/index.ts";
|
||||||
|
|
@ -98,6 +99,12 @@ export const inboxWorker = new Worker<InboxJobData, Response, InboxJobType>(
|
||||||
|
|
||||||
const logger = getLogger(["federation", "inbox"]);
|
const logger = getLogger(["federation", "inbox"]);
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
`Processing entity ${chalk.bold(
|
||||||
|
data.id,
|
||||||
|
)} from ${chalk.bold(signedBy)}`,
|
||||||
|
);
|
||||||
|
|
||||||
if (authorization) {
|
if (authorization) {
|
||||||
const processor = new InboxProcessor(
|
const processor = new InboxProcessor(
|
||||||
request,
|
request,
|
||||||
|
|
@ -112,6 +119,12 @@ export const inboxWorker = new Worker<InboxJobData, Response, InboxJobType>(
|
||||||
ip,
|
ip,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
`Entity ${chalk.bold(
|
||||||
|
data.id,
|
||||||
|
)} is potentially from a bridge`,
|
||||||
|
);
|
||||||
|
|
||||||
return await processor.process();
|
return await processor.process();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue