wip
This commit is contained in:
parent
173aa1924d
commit
3982c90018
|
@ -70,6 +70,24 @@ export class FederatedInstanceService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async fetch(host: string): Promise<MiInstance | null> {
|
||||||
|
host = this.utilityService.toPuny(host);
|
||||||
|
|
||||||
|
const cached = await this.federatedInstanceCache.get(host);
|
||||||
|
if (cached !== undefined) return cached;
|
||||||
|
|
||||||
|
const index = await this.instancesRepository.findOneBy({ host });
|
||||||
|
|
||||||
|
if (index == null) {
|
||||||
|
this.federatedInstanceCache.set(host, null);
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
this.federatedInstanceCache.set(host, index);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async update(id: MiInstance['id'], data: Partial<MiInstance>): Promise<void> {
|
public async update(id: MiInstance['id'], data: Partial<MiInstance>): Promise<void> {
|
||||||
const result = await this.instancesRepository.createQueryBuilder().update()
|
const result = await this.instancesRepository.createQueryBuilder().update()
|
||||||
|
|
|
@ -77,8 +77,14 @@ export class DeliverProcessorService {
|
||||||
this.apRequestChart.deliverSucc();
|
this.apRequestChart.deliverSucc();
|
||||||
this.federationChart.deliverd(host, true);
|
this.federationChart.deliverd(host, true);
|
||||||
|
|
||||||
// Update stats
|
// Update instance stats
|
||||||
this.federatedInstanceService.fetchOrRegister(host).then(i => {
|
process.nextTick(async () => {
|
||||||
|
const i = await (this.meta.enableStatsForFederatedInstances
|
||||||
|
? this.federatedInstanceService.fetchOrRegister(host)
|
||||||
|
: this.federatedInstanceService.fetch(host));
|
||||||
|
|
||||||
|
if (i == null) return;
|
||||||
|
|
||||||
if (i.isNotResponding) {
|
if (i.isNotResponding) {
|
||||||
this.federatedInstanceService.update(i.id, {
|
this.federatedInstanceService.update(i.id, {
|
||||||
isNotResponding: false,
|
isNotResponding: false,
|
||||||
|
@ -86,7 +92,9 @@ export class DeliverProcessorService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetchInstanceMetadataService.fetchInstanceMetadata(i);
|
if (this.meta.enableStatsForFederatedInstances) {
|
||||||
|
this.fetchInstanceMetadataService.fetchInstanceMetadata(i);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.meta.enableChartsForFederatedInstances) {
|
if (this.meta.enableChartsForFederatedInstances) {
|
||||||
this.instanceChart.requestSent(i.host, true);
|
this.instanceChart.requestSent(i.host, true);
|
||||||
|
@ -98,7 +106,7 @@ export class DeliverProcessorService {
|
||||||
this.apRequestChart.deliverFail();
|
this.apRequestChart.deliverFail();
|
||||||
this.federationChart.deliverd(host, false);
|
this.federationChart.deliverd(host, false);
|
||||||
|
|
||||||
// Update stats
|
// Update instance stats
|
||||||
this.federatedInstanceService.fetchOrRegister(host).then(i => {
|
this.federatedInstanceService.fetchOrRegister(host).then(i => {
|
||||||
if (!i.isNotResponding) {
|
if (!i.isNotResponding) {
|
||||||
this.federatedInstanceService.update(i.id, {
|
this.federatedInstanceService.update(i.id, {
|
||||||
|
|
|
@ -195,21 +195,25 @@ export class InboxProcessorService implements OnApplicationShutdown {
|
||||||
this.apRequestChart.inbox();
|
this.apRequestChart.inbox();
|
||||||
this.federationChart.inbox(authUser.user.host);
|
this.federationChart.inbox(authUser.user.host);
|
||||||
|
|
||||||
// Update stats
|
// Update instance stats
|
||||||
if (this.meta.enableStatsForFederatedInstances) {
|
process.nextTick(async () => {
|
||||||
this.federatedInstanceService.fetchOrRegister(authUser.user.host).then(i => {
|
const i = await (this.meta.enableStatsForFederatedInstances
|
||||||
this.updateInstanceQueue.enqueue(i.id, {
|
? this.federatedInstanceService.fetchOrRegister(authUser.user.host)
|
||||||
latestRequestReceivedAt: new Date(),
|
: this.federatedInstanceService.fetch(authUser.user.host));
|
||||||
shouldUnsuspend: i.suspensionState === 'autoSuspendedForNotResponding',
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.meta.enableChartsForFederatedInstances) {
|
if (i == null) return;
|
||||||
this.instanceChart.requestReceived(i.host);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fetchInstanceMetadataService.fetchInstanceMetadata(i);
|
this.updateInstanceQueue.enqueue(i.id, {
|
||||||
|
latestRequestReceivedAt: new Date(),
|
||||||
|
shouldUnsuspend: i.suspensionState === 'autoSuspendedForNotResponding',
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
if (this.meta.enableChartsForFederatedInstances) {
|
||||||
|
this.instanceChart.requestReceived(i.host);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fetchInstanceMetadataService.fetchInstanceMetadata(i);
|
||||||
|
});
|
||||||
|
|
||||||
// アクティビティを処理
|
// アクティビティを処理
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue