Fixed 267U.pre2

This commit is contained in:
2026-07-26 18:25:37 +09:00
parent 50bfaeafdf
commit 317d00a284
1286 changed files with 80222 additions and 1 deletions
@@ -0,0 +1,26 @@
import { Instances } from "../models/index.js";
import { genId } from "../misc/gen-id.js";
import { toPuny } from "../misc/convert-host.js";
import { Cache } from "../misc/cache.js";
const cache = new Cache("registerOrFetchInstanceDoc", 60 * 60);
export async function registerOrFetchInstanceDoc(host) {
const _host = toPuny(host);
const cached = await cache.get(_host);
if (cached) return cached;
const index = await Instances.findOneBy({
host: _host
});
if (index == null) {
const i = await Instances.insert({
id: genId(),
host: _host,
caughtAt: new Date(),
lastCommunicatedAt: new Date()
}).then((x)=>Instances.findOneByOrFail(x.identifiers[0]));
await cache.set(_host, i);
return i;
} else {
await cache.set(_host, index);
return index;
}
}