mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-11 03:43:08 +02:00
23 lines
458 B
TypeScript
23 lines
458 B
TypeScript
|
import Instance, { IInstance } from '../models/instance';
|
||
|
import federationChart from '../chart/federation';
|
||
|
|
||
|
export default async function(host: string): Promise<IInstance> {
|
||
|
if (host == null) return null;
|
||
|
|
||
|
const index = await Instance.findOne({ host });
|
||
|
|
||
|
if (index == null) {
|
||
|
const i = await Instance.insert({
|
||
|
host,
|
||
|
caughtAt: new Date(),
|
||
|
system: null // TODO
|
||
|
});
|
||
|
|
||
|
federationChart.update(true);
|
||
|
|
||
|
return i;
|
||
|
} else {
|
||
|
return index;
|
||
|
}
|
||
|
}
|