mirror of
https://github.com/versia-pub/server.git
synced 2025-12-07 16:58:20 +01:00
feat(federation): ✨ Add more debugging to inbox processing
This commit is contained in:
parent
be69407c01
commit
c59ebef851
|
|
@ -716,7 +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)}`;
|
getLogger("federation").debug`Resolving user ${chalk.gray(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));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import {
|
||||||
} from "@versia/kit/db";
|
} from "@versia/kit/db";
|
||||||
import { Likes, Notes } from "@versia/kit/tables";
|
import { Likes, Notes } from "@versia/kit/tables";
|
||||||
import type { SocketAddress } from "bun";
|
import type { SocketAddress } from "bun";
|
||||||
|
import chalk from "chalk";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import type { StatusCode } from "hono/utils/http-status";
|
import type { StatusCode } from "hono/utils/http-status";
|
||||||
import { matches } from "ip-matching";
|
import { matches } from "ip-matching";
|
||||||
|
|
@ -104,8 +105,9 @@ export class InboxProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.debug.federation) {
|
if (config.debug.federation) {
|
||||||
this.logger
|
this.logger.debug`Sender public key: ${chalk.gray(
|
||||||
.debug`Sender public key: ${this.senderInstance.data.publicKey.key}`;
|
this.senderInstance.data.publicKey.key,
|
||||||
|
)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const validator = await SignatureValidator.fromStringKey(
|
const validator = await SignatureValidator.fromStringKey(
|
||||||
|
|
@ -199,6 +201,9 @@ export class InboxProcessor {
|
||||||
* @returns {Promise<Response>} - HTTP response to send back.
|
* @returns {Promise<Response>} - HTTP response to send back.
|
||||||
*/
|
*/
|
||||||
public async process(): Promise<Response> {
|
public async process(): Promise<Response> {
|
||||||
|
!this.senderInstance &&
|
||||||
|
this.logger.debug`Processing request from potential bridge`;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.senderInstance &&
|
this.senderInstance &&
|
||||||
isDefederated(this.senderInstance.data.baseUrl)
|
isDefederated(this.senderInstance.data.baseUrl)
|
||||||
|
|
@ -211,6 +216,10 @@ export class InboxProcessor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.debug`Instance ${chalk.gray(
|
||||||
|
this.senderInstance?.data.baseUrl,
|
||||||
|
)} is not defederated`;
|
||||||
|
|
||||||
const shouldCheckSignature = this.shouldCheckSignature();
|
const shouldCheckSignature = this.shouldCheckSignature();
|
||||||
|
|
||||||
if (shouldCheckSignature !== true && shouldCheckSignature !== false) {
|
if (shouldCheckSignature !== true && shouldCheckSignature !== false) {
|
||||||
|
|
@ -220,6 +229,10 @@ export class InboxProcessor {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldCheckSignature
|
||||||
|
? this.logger.debug`Checking signature`
|
||||||
|
: this.logger.debug`Skipping signature check`;
|
||||||
|
|
||||||
if (shouldCheckSignature) {
|
if (shouldCheckSignature) {
|
||||||
const isValid = await this.isSignatureValid();
|
const isValid = await this.isSignatureValid();
|
||||||
|
|
||||||
|
|
@ -231,6 +244,8 @@ export class InboxProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldCheckSignature && this.logger.debug`Signature is valid`;
|
||||||
|
|
||||||
const validator = new EntityValidator();
|
const validator = new EntityValidator();
|
||||||
const handler = new RequestParserHandler(this.body, validator);
|
const handler = new RequestParserHandler(this.body, validator);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue