summaryrefslogtreecommitdiff
path: root/packages/backend/src/services/register-or-fetch-instance-doc.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-09-18 03:27:08 +0900
committerGitHub <noreply@github.com>2022-09-18 03:27:08 +0900
commitb75184ec8e3436200bacdcd832e3324702553d20 (patch)
tree8b7e316f29e95df921db57289c8b8da476d18f07 /packages/backend/src/services/register-or-fetch-instance-doc.ts
parentUpdate ROADMAP.md (diff)
downloadmisskey-b75184ec8e3436200bacdcd832e3324702553d20.tar.gz
misskey-b75184ec8e3436200bacdcd832e3324702553d20.tar.bz2
misskey-b75184ec8e3436200bacdcd832e3324702553d20.zip
なんかもうめっちゃ変えた
Diffstat (limited to 'packages/backend/src/services/register-or-fetch-instance-doc.ts')
-rw-r--r--packages/backend/src/services/register-or-fetch-instance-doc.ts31
1 files changed, 0 insertions, 31 deletions
diff --git a/packages/backend/src/services/register-or-fetch-instance-doc.ts b/packages/backend/src/services/register-or-fetch-instance-doc.ts
deleted file mode 100644
index df7d125d0b..0000000000
--- a/packages/backend/src/services/register-or-fetch-instance-doc.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { Instance } from '@/models/entities/instance.js';
-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<Instance>(1000 * 60 * 60);
-
-export async function registerOrFetchInstanceDoc(host: string): Promise<Instance> {
- host = toPuny(host);
-
- const cached = cache.get(host);
- if (cached) return cached;
-
- const index = await Instances.findOneBy({ host });
-
- if (index == null) {
- const i = await Instances.insert({
- id: genId(),
- host,
- caughtAt: new Date(),
- lastCommunicatedAt: new Date(),
- }).then(x => Instances.findOneByOrFail(x.identifiers[0]));
-
- cache.set(host, i);
- return i;
- } else {
- cache.set(host, index);
- return index;
- }
-}