mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 09:57:29 -07:00
[backend] Decrease default RecursionLimiter count to 10
This commit is contained in:
parent
1cbfd68a39
commit
80c9280682
7 changed files with 12 additions and 12 deletions
|
@ -12,7 +12,7 @@ const queue = new Semaphore(5);
|
||||||
|
|
||||||
export const UserProfileRepository = db.getRepository(UserProfile).extend({
|
export const UserProfileRepository = db.getRepository(UserProfile).extend({
|
||||||
// We must never await this without promiseEarlyReturn, otherwise giant webring-style profile mention trees will cause the queue to stop working
|
// We must never await this without promiseEarlyReturn, otherwise giant webring-style profile mention trees will cause the queue to stop working
|
||||||
async updateMentions(id: UserProfile["userId"], limiter: RecursionLimiter = new RecursionLimiter(20)){
|
async updateMentions(id: UserProfile["userId"], limiter: RecursionLimiter = new RecursionLimiter()){
|
||||||
const profile = await this.findOneBy({ userId: id });
|
const profile = await this.findOneBy({ userId: id });
|
||||||
if (!profile) return;
|
if (!profile) return;
|
||||||
const tokens: mfm.MfmNode[] = [];
|
const tokens: mfm.MfmNode[] = [];
|
||||||
|
@ -51,7 +51,7 @@ async function populateMentions(tokens: mfm.MfmNode[], objectHost: string | null
|
||||||
export class RecursionLimiter {
|
export class RecursionLimiter {
|
||||||
private counter;
|
private counter;
|
||||||
private mutex = new Mutex();
|
private mutex = new Mutex();
|
||||||
constructor(count: number = 20) {
|
constructor(count: number = 10) {
|
||||||
this.counter = count;
|
this.counter = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ export async function parseAudience(
|
||||||
to?: ApObject,
|
to?: ApObject,
|
||||||
cc?: ApObject,
|
cc?: ApObject,
|
||||||
resolver?: Resolver,
|
resolver?: Resolver,
|
||||||
limiter: RecursionLimiter = new RecursionLimiter(20)
|
limiter: RecursionLimiter = new RecursionLimiter()
|
||||||
): Promise<AudienceInfo> {
|
): Promise<AudienceInfo> {
|
||||||
const toGroups = groupingAudience(getApIds(to), actor);
|
const toGroups = groupingAudience(getApIds(to), actor);
|
||||||
const ccGroups = groupingAudience(getApIds(cc), actor);
|
const ccGroups = groupingAudience(getApIds(cc), actor);
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { RecursionLimiter } from "@/models/repositories/user-profile.js";
|
||||||
|
|
||||||
export async function extractApMentions(
|
export async function extractApMentions(
|
||||||
tags: IObject | IObject[] | null | undefined,
|
tags: IObject | IObject[] | null | undefined,
|
||||||
limiter: RecursionLimiter = new RecursionLimiter(20)
|
limiter: RecursionLimiter = new RecursionLimiter()
|
||||||
) {
|
) {
|
||||||
const hrefs = unique(
|
const hrefs = unique(
|
||||||
extractApMentionObjects(tags).map((x) => x.href as string),
|
extractApMentionObjects(tags).map((x) => x.href as string),
|
||||||
|
|
|
@ -109,7 +109,7 @@ export async function createNote(
|
||||||
value: string | IObject,
|
value: string | IObject,
|
||||||
resolver?: Resolver,
|
resolver?: Resolver,
|
||||||
silent = false,
|
silent = false,
|
||||||
limiter: RecursionLimiter = new RecursionLimiter(20)
|
limiter: RecursionLimiter = new RecursionLimiter()
|
||||||
): Promise<Note | null> {
|
): Promise<Note | null> {
|
||||||
if (resolver == null) resolver = new Resolver();
|
if (resolver == null) resolver = new Resolver();
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ export async function createNote(
|
||||||
export async function resolveNote(
|
export async function resolveNote(
|
||||||
value: string | IObject,
|
value: string | IObject,
|
||||||
resolver?: Resolver,
|
resolver?: Resolver,
|
||||||
limiter: RecursionLimiter = new RecursionLimiter(20)
|
limiter: RecursionLimiter = new RecursionLimiter()
|
||||||
): Promise<Note | null> {
|
): Promise<Note | null> {
|
||||||
const uri = typeof value === "string" ? value : value.id;
|
const uri = typeof value === "string" ? value : value.id;
|
||||||
if (uri == null) throw new Error("missing uri");
|
if (uri == null) throw new Error("missing uri");
|
||||||
|
|
|
@ -171,7 +171,7 @@ export async function createPerson(
|
||||||
uri: string,
|
uri: string,
|
||||||
resolver?: Resolver,
|
resolver?: Resolver,
|
||||||
subjectHost?: string,
|
subjectHost?: string,
|
||||||
limiter: RecursionLimiter = new RecursionLimiter(20)
|
limiter: RecursionLimiter = new RecursionLimiter()
|
||||||
): Promise<User> {
|
): Promise<User> {
|
||||||
if (typeof uri !== "string") throw new Error("uri is not string");
|
if (typeof uri !== "string") throw new Error("uri is not string");
|
||||||
|
|
||||||
|
@ -644,7 +644,7 @@ export async function updatePerson(
|
||||||
export async function resolvePerson(
|
export async function resolvePerson(
|
||||||
uri: string,
|
uri: string,
|
||||||
resolver?: Resolver,
|
resolver?: Resolver,
|
||||||
limiter: RecursionLimiter = new RecursionLimiter(20)
|
limiter: RecursionLimiter = new RecursionLimiter()
|
||||||
): Promise<CacheableUser> {
|
): Promise<CacheableUser> {
|
||||||
if (typeof uri !== "string") throw new Error("uri is not string");
|
if (typeof uri !== "string") throw new Error("uri is not string");
|
||||||
|
|
||||||
|
@ -719,7 +719,7 @@ export async function analyzeAttachments(
|
||||||
return { fields, services };
|
return { fields, services };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateFeatured(userId: User["id"], resolver?: Resolver, limiter: RecursionLimiter = new RecursionLimiter(20)) {
|
export async function updateFeatured(userId: User["id"], resolver?: Resolver, limiter: RecursionLimiter = new RecursionLimiter()) {
|
||||||
const user = await Users.findOneByOrFail({ id: userId });
|
const user = await Users.findOneByOrFail({ id: userId });
|
||||||
if (!Users.isRemoteUser(user)) return;
|
if (!Users.isRemoteUser(user)) return;
|
||||||
if (!user.featured) return;
|
if (!user.featured) return;
|
||||||
|
|
|
@ -34,7 +34,7 @@ export async function resolveUser(
|
||||||
username: string,
|
username: string,
|
||||||
host: string | null,
|
host: string | null,
|
||||||
refresh: refreshType = 'refresh',
|
refresh: refreshType = 'refresh',
|
||||||
limiter: RecursionLimiter = new RecursionLimiter(20)
|
limiter: RecursionLimiter = new RecursionLimiter()
|
||||||
): Promise<User> {
|
): Promise<User> {
|
||||||
const usernameLower = username.toLowerCase();
|
const usernameLower = username.toLowerCase();
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ export default async (
|
||||||
},
|
},
|
||||||
data: Option,
|
data: Option,
|
||||||
silent = false,
|
silent = false,
|
||||||
limiter: RecursionLimiter = new RecursionLimiter(20)
|
limiter: RecursionLimiter = new RecursionLimiter()
|
||||||
) =>
|
) =>
|
||||||
// rome-ignore lint/suspicious/noAsyncPromiseExecutor: FIXME
|
// rome-ignore lint/suspicious/noAsyncPromiseExecutor: FIXME
|
||||||
new Promise<Note>(async (res, rej) => {
|
new Promise<Note>(async (res, rej) => {
|
||||||
|
@ -927,7 +927,7 @@ function incNotesCountOfUser(user: { id: User["id"] }) {
|
||||||
export async function extractMentionedUsers(
|
export async function extractMentionedUsers(
|
||||||
user: { host: User["host"] },
|
user: { host: User["host"] },
|
||||||
tokens: mfm.MfmNode[],
|
tokens: mfm.MfmNode[],
|
||||||
limiter: RecursionLimiter = new RecursionLimiter(20)
|
limiter: RecursionLimiter = new RecursionLimiter()
|
||||||
): Promise<User[]> {
|
): Promise<User[]> {
|
||||||
if (tokens == null) return [];
|
if (tokens == null) return [];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue