2023-07-27 08:31:52 +03:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-07-15 12:39:38 +03:00
|
|
|
import { randomUUID } from 'node:crypto';
|
2022-09-17 21:27:08 +03:00
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
2022-12-04 03:16:03 +02:00
|
|
|
import type { IActivity } from '@/core/activitypub/type.js';
|
2023-09-20 05:33:36 +03:00
|
|
|
import type { MiDriveFile } from '@/models/DriveFile.js';
|
|
|
|
import type { MiWebhook, webhookEventTypes } from '@/models/Webhook.js';
|
2022-09-20 23:33:11 +03:00
|
|
|
import type { Config } from '@/config.js';
|
2022-09-17 21:27:08 +03:00
|
|
|
import { DI } from '@/di-symbols.js';
|
2023-01-01 09:53:10 +02:00
|
|
|
import { bindThis } from '@/decorators.js';
|
2023-05-06 02:17:55 +03:00
|
|
|
import type { Antenna } from '@/server/api/endpoints/i/import-antennas.js';
|
2023-04-12 03:13:58 +03:00
|
|
|
import type { DbQueue, DeliverQueue, EndedPollNotificationQueue, InboxQueue, ObjectStorageQueue, RelationshipQueue, SystemQueue, WebhookDeliverQueue } from './QueueModule.js';
|
2023-07-05 06:15:48 +03:00
|
|
|
import type { DbJobData, DeliverJobData, RelationshipJobData, ThinUser } from '../queue/types.js';
|
2022-09-17 21:27:08 +03:00
|
|
|
import type httpSignature from '@peertube/http-signature';
|
2023-05-29 05:54:49 +03:00
|
|
|
import type * as Bull from 'bullmq';
|
2022-09-17 21:27:08 +03:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class QueueService {
|
|
|
|
constructor(
|
|
|
|
@Inject(DI.config)
|
|
|
|
private config: Config,
|
|
|
|
|
|
|
|
@Inject('queue:system') public systemQueue: SystemQueue,
|
|
|
|
@Inject('queue:endedPollNotification') public endedPollNotificationQueue: EndedPollNotificationQueue,
|
|
|
|
@Inject('queue:deliver') public deliverQueue: DeliverQueue,
|
|
|
|
@Inject('queue:inbox') public inboxQueue: InboxQueue,
|
|
|
|
@Inject('queue:db') public dbQueue: DbQueue,
|
2023-04-12 03:13:58 +03:00
|
|
|
@Inject('queue:relationship') public relationshipQueue: RelationshipQueue,
|
2022-09-17 21:27:08 +03:00
|
|
|
@Inject('queue:objectStorage') public objectStorageQueue: ObjectStorageQueue,
|
|
|
|
@Inject('queue:webhookDeliver') public webhookDeliverQueue: WebhookDeliverQueue,
|
2023-05-29 05:54:49 +03:00
|
|
|
) {
|
|
|
|
this.systemQueue.add('tickCharts', {
|
|
|
|
}, {
|
|
|
|
repeat: { pattern: '55 * * * *' },
|
|
|
|
removeOnComplete: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.systemQueue.add('resyncCharts', {
|
|
|
|
}, {
|
|
|
|
repeat: { pattern: '0 0 * * *' },
|
|
|
|
removeOnComplete: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.systemQueue.add('cleanCharts', {
|
|
|
|
}, {
|
|
|
|
repeat: { pattern: '0 0 * * *' },
|
|
|
|
removeOnComplete: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.systemQueue.add('aggregateRetention', {
|
|
|
|
}, {
|
|
|
|
repeat: { pattern: '0 0 * * *' },
|
|
|
|
removeOnComplete: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.systemQueue.add('clean', {
|
|
|
|
}, {
|
|
|
|
repeat: { pattern: '0 0 * * *' },
|
|
|
|
removeOnComplete: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.systemQueue.add('checkExpiredMutings', {
|
|
|
|
}, {
|
|
|
|
repeat: { pattern: '*/5 * * * *' },
|
|
|
|
removeOnComplete: true,
|
|
|
|
});
|
|
|
|
}
|
2022-09-17 21:27:08 +03:00
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2023-03-14 12:11:31 +02:00
|
|
|
public deliver(user: ThinUser, content: IActivity | null, to: string | null, isSharedInbox: boolean) {
|
2022-09-17 21:27:08 +03:00
|
|
|
if (content == null) return null;
|
|
|
|
if (to == null) return null;
|
|
|
|
|
2023-07-05 06:15:48 +03:00
|
|
|
const data: DeliverJobData = {
|
2022-09-17 21:27:08 +03:00
|
|
|
user: {
|
|
|
|
id: user.id,
|
|
|
|
},
|
|
|
|
content,
|
|
|
|
to,
|
2023-03-14 12:11:31 +02:00
|
|
|
isSharedInbox,
|
2022-09-17 21:27:08 +03:00
|
|
|
};
|
|
|
|
|
2023-05-29 05:54:49 +03:00
|
|
|
return this.deliverQueue.add(to, data, {
|
2022-09-17 21:27:08 +03:00
|
|
|
attempts: this.config.deliverJobMaxAttempts ?? 12,
|
|
|
|
backoff: {
|
2023-05-29 05:54:49 +03:00
|
|
|
type: 'custom',
|
2022-09-17 21:27:08 +03:00
|
|
|
},
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-07-05 06:15:48 +03:00
|
|
|
/**
|
|
|
|
* ApDeliverManager-DeliverManager.execute()からinboxesを突っ込んでaddBulkしたい
|
|
|
|
* @param user `{ id: string; }` この関数ではThinUserに変換しないので前もって変換してください
|
|
|
|
* @param content IActivity | null
|
|
|
|
* @param inboxes `Map<string, boolean>` / key: to (inbox url), value: isSharedInbox (whether it is sharedInbox)
|
|
|
|
* @returns void
|
|
|
|
*/
|
|
|
|
@bindThis
|
|
|
|
public async deliverMany(user: ThinUser, content: IActivity | null, inboxes: Map<string, boolean>) {
|
2023-07-08 02:15:04 +03:00
|
|
|
if (content == null) return null;
|
|
|
|
|
2023-07-05 06:15:48 +03:00
|
|
|
const opts = {
|
|
|
|
attempts: this.config.deliverJobMaxAttempts ?? 12,
|
|
|
|
backoff: {
|
|
|
|
type: 'custom',
|
|
|
|
},
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
};
|
|
|
|
|
2023-07-21 13:07:03 +03:00
|
|
|
await this.deliverQueue.addBulk(Array.from(inboxes.entries(), d => ({
|
2023-07-05 06:15:48 +03:00
|
|
|
name: d[0],
|
|
|
|
data: {
|
|
|
|
user,
|
|
|
|
content,
|
|
|
|
to: d[0],
|
|
|
|
isSharedInbox: d[1],
|
|
|
|
} as DeliverJobData,
|
|
|
|
opts,
|
|
|
|
})));
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public inbox(activity: IActivity, signature: httpSignature.IParsedSignature) {
|
|
|
|
const data = {
|
|
|
|
activity: activity,
|
|
|
|
signature,
|
|
|
|
};
|
2023-04-12 03:13:58 +03:00
|
|
|
|
2023-05-29 05:54:49 +03:00
|
|
|
return this.inboxQueue.add('', data, {
|
2022-09-17 21:27:08 +03:00
|
|
|
attempts: this.config.inboxJobMaxAttempts ?? 8,
|
|
|
|
backoff: {
|
2023-05-29 05:54:49 +03:00
|
|
|
type: 'custom',
|
2022-09-17 21:27:08 +03:00
|
|
|
},
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public createDeleteDriveFilesJob(user: ThinUser) {
|
|
|
|
return this.dbQueue.add('deleteDriveFiles', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public createExportCustomEmojisJob(user: ThinUser) {
|
|
|
|
return this.dbQueue.add('exportCustomEmojis', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public createExportNotesJob(user: ThinUser) {
|
|
|
|
return this.dbQueue.add('exportNotes', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-01-01 09:53:10 +02:00
|
|
|
@bindThis
|
|
|
|
public createExportFavoritesJob(user: ThinUser) {
|
|
|
|
return this.dbQueue.add('exportFavorites', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2023-01-01 09:53:10 +02:00
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public createExportFollowingJob(user: ThinUser, excludeMuting = false, excludeInactive = false) {
|
|
|
|
return this.dbQueue.add('exportFollowing', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
excludeMuting,
|
|
|
|
excludeInactive,
|
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public createExportMuteJob(user: ThinUser) {
|
|
|
|
return this.dbQueue.add('exportMuting', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public createExportBlockingJob(user: ThinUser) {
|
|
|
|
return this.dbQueue.add('exportBlocking', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public createExportUserListsJob(user: ThinUser) {
|
|
|
|
return this.dbQueue.add('exportUserLists', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-05-06 02:17:55 +03:00
|
|
|
@bindThis
|
|
|
|
public createExportAntennasJob(user: ThinUser) {
|
|
|
|
return this.dbQueue.add('exportAntennas', {
|
|
|
|
user: { id: user.id },
|
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2023-10-17 14:56:17 +03:00
|
|
|
public createImportFollowingJob(user: ThinUser, fileId: MiDriveFile['id'], withReplies?: boolean) {
|
2022-09-17 21:27:08 +03:00
|
|
|
return this.dbQueue.add('importFollowing', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
fileId: fileId,
|
2023-10-17 14:56:17 +03:00
|
|
|
withReplies,
|
2022-09-17 21:27:08 +03:00
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-12 03:13:58 +03:00
|
|
|
@bindThis
|
2023-10-17 14:56:17 +03:00
|
|
|
public createImportFollowingToDbJob(user: ThinUser, targets: string[], withReplies?: boolean) {
|
|
|
|
const jobs = targets.map(rel => this.generateToDbJobData('importFollowingToDb', { user, target: rel, withReplies }));
|
2023-04-12 03:13:58 +03:00
|
|
|
return this.dbQueue.addBulk(jobs);
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2023-08-16 11:51:28 +03:00
|
|
|
public createImportMutingJob(user: ThinUser, fileId: MiDriveFile['id']) {
|
2022-09-17 21:27:08 +03:00
|
|
|
return this.dbQueue.add('importMuting', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
fileId: fileId,
|
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2023-08-16 11:51:28 +03:00
|
|
|
public createImportBlockingJob(user: ThinUser, fileId: MiDriveFile['id']) {
|
2022-09-17 21:27:08 +03:00
|
|
|
return this.dbQueue.add('importBlocking', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
fileId: fileId,
|
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-12 03:13:58 +03:00
|
|
|
@bindThis
|
|
|
|
public createImportBlockingToDbJob(user: ThinUser, targets: string[]) {
|
|
|
|
const jobs = targets.map(rel => this.generateToDbJobData('importBlockingToDb', { user, target: rel }));
|
|
|
|
return this.dbQueue.addBulk(jobs);
|
|
|
|
}
|
|
|
|
|
|
|
|
@bindThis
|
|
|
|
private generateToDbJobData<T extends 'importFollowingToDb' | 'importBlockingToDb', D extends DbJobData<T>>(name: T, data: D): {
|
|
|
|
name: string,
|
|
|
|
data: D,
|
2023-05-29 05:54:49 +03:00
|
|
|
opts: Bull.JobsOptions,
|
2023-04-12 03:13:58 +03:00
|
|
|
} {
|
|
|
|
return {
|
|
|
|
name,
|
|
|
|
data,
|
|
|
|
opts: {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2023-08-16 11:51:28 +03:00
|
|
|
public createImportUserListsJob(user: ThinUser, fileId: MiDriveFile['id']) {
|
2022-09-17 21:27:08 +03:00
|
|
|
return this.dbQueue.add('importUserLists', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
fileId: fileId,
|
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2023-08-16 11:51:28 +03:00
|
|
|
public createImportCustomEmojisJob(user: ThinUser, fileId: MiDriveFile['id']) {
|
2022-09-17 21:27:08 +03:00
|
|
|
return this.dbQueue.add('importCustomEmojis', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
fileId: fileId,
|
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-05-06 02:17:55 +03:00
|
|
|
@bindThis
|
|
|
|
public createImportAntennasJob(user: ThinUser, antenna: Antenna) {
|
|
|
|
return this.dbQueue.add('importAntennas', {
|
|
|
|
user: { id: user.id },
|
|
|
|
antenna,
|
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public createDeleteAccountJob(user: ThinUser, opts: { soft?: boolean; } = {}) {
|
|
|
|
return this.dbQueue.add('deleteAccount', {
|
2023-04-12 03:13:58 +03:00
|
|
|
user: { id: user.id },
|
2022-09-17 21:27:08 +03:00
|
|
|
soft: opts.soft,
|
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-12 03:13:58 +03:00
|
|
|
@bindThis
|
2023-10-17 14:56:17 +03:00
|
|
|
public createFollowJob(followings: { from: ThinUser, to: ThinUser, requestId?: string, silent?: boolean, withReplies?: boolean }[]) {
|
2023-04-12 03:13:58 +03:00
|
|
|
const jobs = followings.map(rel => this.generateRelationshipJobData('follow', rel));
|
|
|
|
return this.relationshipQueue.addBulk(jobs);
|
|
|
|
}
|
|
|
|
|
|
|
|
@bindThis
|
|
|
|
public createUnfollowJob(followings: { from: ThinUser, to: ThinUser, requestId?: string }[]) {
|
|
|
|
const jobs = followings.map(rel => this.generateRelationshipJobData('unfollow', rel));
|
|
|
|
return this.relationshipQueue.addBulk(jobs);
|
|
|
|
}
|
|
|
|
|
enhance: account migration (#10592)
* copy block and mute then create follow and unfollow jobs
* copy block and mute and update lists when detecting an account has moved
* no need to care promise orders
* refactor updating actor and target
* automatically accept if a locked account had accepted an old account
* fix exception format
* prevent the old account from calling some endpoints
* do not unfollow when moving
* adjust following and follower counts
* check movedToUri when receiving a follow request
* skip if no need to adjust
* Revert "disable account migration"
This reverts commit 2321214c98591bcfe1385c1ab5bf0ff7b471ae1d.
* fix translation specifier
* fix checking alsoKnownAs and uri
* fix updating account
* fix refollowing locked account
* decrease followersCount if followed by the old account
* adjust following and followers counts when unfollowing
* fix copying mutings
* prohibit moved account from moving again
* fix move service
* allow app creation after moving
* fix lint
* remove unnecessary field
* fix cache update
* add e2e test
* add e2e test of accepting the new account automatically
* force follow if any error happens
* remove unnecessary joins
* use Array.map instead of for const of
* ユーザーリストの移行は追加のみを行う
* nanka iroiro
* fix misskey-js?
* :v:
* 移行を行ったアカウントからのフォローリクエストの自動許可を調整
* newUriを外に出す
* newUriを外に出す2
* clean up
* fix newUri
* prevent moving if the destination account has already moved
* set alsoKnownAs via /i/update
* fix database initialization
* add return type
* prohibit updating alsoKnownAs after moving
* skip to add to alsoKnownAs if toUrl is known
* skip adding to the list if it already has
* use Acct.parse instead
* rename error code
* :art:
* 制限を5から10に緩和
* movedTo(Uri), alsoKnownAsはユーザーidを返すように
* test api res
* fix
* 元アカウントはミュートし続ける
* :art:
* unfollow
* fix
* getUserUriをUserEntityServiceに
* ?
* job!
* :art:
* instance => server
* accountMovedShort, forbiddenBecauseYouAreMigrated
* accountMovedShort
* fix test
* import, pin禁止
* 実績を凍結する
* clean up
* :v:
* change message
* ブロック, フォロー, ミュート, リストのインポートファイルの制限を32MiBに
* Revert "ブロック, フォロー, ミュート, リストのインポートファイルの制限を32MiBに"
This reverts commit 3bd7be35d8aa455cb01ae58f8172a71a50485db1.
* validateAlsoKnownAs
* 移行後2時間以内はインポート可能なファイルサイズを拡大
* clean up
* どうせactorをupdatePersonで更新するならupdatePersonしか移行処理を発行しないことにする
* handle error?
* リモートからの移行処理の条件を是正
* log, port
* fix
* fix
* enhance(dev): non-production環境でhttpサーバー間でもユーザー、ノートの連合が可能なように
* refactor (use checkHttps)
* MISSKEY_WEBFINGER_USE_HTTP
* Environment Variable readme
* NEVER USE IN PRODUCTION
* fix punyHost
* fix indent
* fix
* experimental
---------
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
2023-04-29 18:09:29 +03:00
|
|
|
@bindThis
|
|
|
|
public createDelayedUnfollowJob(followings: { from: ThinUser, to: ThinUser, requestId?: string }[], delay: number) {
|
|
|
|
const jobs = followings.map(rel => this.generateRelationshipJobData('unfollow', rel, { delay }));
|
|
|
|
return this.relationshipQueue.addBulk(jobs);
|
|
|
|
}
|
|
|
|
|
2023-04-12 03:13:58 +03:00
|
|
|
@bindThis
|
|
|
|
public createBlockJob(blockings: { from: ThinUser, to: ThinUser, silent?: boolean }[]) {
|
|
|
|
const jobs = blockings.map(rel => this.generateRelationshipJobData('block', rel));
|
|
|
|
return this.relationshipQueue.addBulk(jobs);
|
|
|
|
}
|
|
|
|
|
|
|
|
@bindThis
|
|
|
|
public createUnblockJob(blockings: { from: ThinUser, to: ThinUser, silent?: boolean }[]) {
|
|
|
|
const jobs = blockings.map(rel => this.generateRelationshipJobData('unblock', rel));
|
|
|
|
return this.relationshipQueue.addBulk(jobs);
|
|
|
|
}
|
|
|
|
|
|
|
|
@bindThis
|
2023-05-29 05:54:49 +03:00
|
|
|
private generateRelationshipJobData(name: 'follow' | 'unfollow' | 'block' | 'unblock', data: RelationshipJobData, opts: Bull.JobsOptions = {}): {
|
2023-04-12 03:13:58 +03:00
|
|
|
name: string,
|
|
|
|
data: RelationshipJobData,
|
2023-05-29 05:54:49 +03:00
|
|
|
opts: Bull.JobsOptions,
|
2023-04-12 03:13:58 +03:00
|
|
|
} {
|
|
|
|
return {
|
|
|
|
name,
|
|
|
|
data: {
|
|
|
|
from: { id: data.from.id },
|
|
|
|
to: { id: data.to.id },
|
|
|
|
silent: data.silent,
|
|
|
|
requestId: data.requestId,
|
2023-10-17 14:56:17 +03:00
|
|
|
withReplies: data.withReplies,
|
2023-04-12 03:13:58 +03:00
|
|
|
},
|
|
|
|
opts: {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
enhance: account migration (#10592)
* copy block and mute then create follow and unfollow jobs
* copy block and mute and update lists when detecting an account has moved
* no need to care promise orders
* refactor updating actor and target
* automatically accept if a locked account had accepted an old account
* fix exception format
* prevent the old account from calling some endpoints
* do not unfollow when moving
* adjust following and follower counts
* check movedToUri when receiving a follow request
* skip if no need to adjust
* Revert "disable account migration"
This reverts commit 2321214c98591bcfe1385c1ab5bf0ff7b471ae1d.
* fix translation specifier
* fix checking alsoKnownAs and uri
* fix updating account
* fix refollowing locked account
* decrease followersCount if followed by the old account
* adjust following and followers counts when unfollowing
* fix copying mutings
* prohibit moved account from moving again
* fix move service
* allow app creation after moving
* fix lint
* remove unnecessary field
* fix cache update
* add e2e test
* add e2e test of accepting the new account automatically
* force follow if any error happens
* remove unnecessary joins
* use Array.map instead of for const of
* ユーザーリストの移行は追加のみを行う
* nanka iroiro
* fix misskey-js?
* :v:
* 移行を行ったアカウントからのフォローリクエストの自動許可を調整
* newUriを外に出す
* newUriを外に出す2
* clean up
* fix newUri
* prevent moving if the destination account has already moved
* set alsoKnownAs via /i/update
* fix database initialization
* add return type
* prohibit updating alsoKnownAs after moving
* skip to add to alsoKnownAs if toUrl is known
* skip adding to the list if it already has
* use Acct.parse instead
* rename error code
* :art:
* 制限を5から10に緩和
* movedTo(Uri), alsoKnownAsはユーザーidを返すように
* test api res
* fix
* 元アカウントはミュートし続ける
* :art:
* unfollow
* fix
* getUserUriをUserEntityServiceに
* ?
* job!
* :art:
* instance => server
* accountMovedShort, forbiddenBecauseYouAreMigrated
* accountMovedShort
* fix test
* import, pin禁止
* 実績を凍結する
* clean up
* :v:
* change message
* ブロック, フォロー, ミュート, リストのインポートファイルの制限を32MiBに
* Revert "ブロック, フォロー, ミュート, リストのインポートファイルの制限を32MiBに"
This reverts commit 3bd7be35d8aa455cb01ae58f8172a71a50485db1.
* validateAlsoKnownAs
* 移行後2時間以内はインポート可能なファイルサイズを拡大
* clean up
* どうせactorをupdatePersonで更新するならupdatePersonしか移行処理を発行しないことにする
* handle error?
* リモートからの移行処理の条件を是正
* log, port
* fix
* fix
* enhance(dev): non-production環境でhttpサーバー間でもユーザー、ノートの連合が可能なように
* refactor (use checkHttps)
* MISSKEY_WEBFINGER_USE_HTTP
* Environment Variable readme
* NEVER USE IN PRODUCTION
* fix punyHost
* fix indent
* fix
* experimental
---------
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
2023-04-29 18:09:29 +03:00
|
|
|
...opts,
|
2023-04-12 03:13:58 +03:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public createDeleteObjectStorageFileJob(key: string) {
|
|
|
|
return this.objectStorageQueue.add('deleteFile', {
|
|
|
|
key: key,
|
|
|
|
}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public createCleanRemoteFilesJob() {
|
|
|
|
return this.objectStorageQueue.add('cleanRemoteFiles', {}, {
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2023-08-16 11:51:28 +03:00
|
|
|
public webhookDeliver(webhook: MiWebhook, type: typeof webhookEventTypes[number], content: unknown) {
|
2022-09-17 21:27:08 +03:00
|
|
|
const data = {
|
|
|
|
type,
|
|
|
|
content,
|
|
|
|
webhookId: webhook.id,
|
|
|
|
userId: webhook.userId,
|
|
|
|
to: webhook.url,
|
|
|
|
secret: webhook.secret,
|
|
|
|
createdAt: Date.now(),
|
2023-07-15 12:39:38 +03:00
|
|
|
eventId: randomUUID(),
|
2022-09-17 21:27:08 +03:00
|
|
|
};
|
2023-04-12 03:13:58 +03:00
|
|
|
|
2023-05-29 05:54:49 +03:00
|
|
|
return this.webhookDeliverQueue.add(webhook.id, data, {
|
2022-09-17 21:27:08 +03:00
|
|
|
attempts: 4,
|
|
|
|
backoff: {
|
2023-05-29 05:54:49 +03:00
|
|
|
type: 'custom',
|
2022-09-17 21:27:08 +03:00
|
|
|
},
|
|
|
|
removeOnComplete: true,
|
|
|
|
removeOnFail: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-04 08:03:09 +02:00
|
|
|
@bindThis
|
2022-09-17 21:27:08 +03:00
|
|
|
public destroy() {
|
|
|
|
this.deliverQueue.once('cleaned', (jobs, status) => {
|
|
|
|
//deliverLogger.succ(`Cleaned ${jobs.length} ${status} jobs`);
|
|
|
|
});
|
2023-06-22 09:56:40 +03:00
|
|
|
this.deliverQueue.clean(0, 0, 'delayed');
|
2023-04-12 03:13:58 +03:00
|
|
|
|
2022-09-17 21:27:08 +03:00
|
|
|
this.inboxQueue.once('cleaned', (jobs, status) => {
|
|
|
|
//inboxLogger.succ(`Cleaned ${jobs.length} ${status} jobs`);
|
|
|
|
});
|
2023-06-22 09:56:40 +03:00
|
|
|
this.inboxQueue.clean(0, 0, 'delayed');
|
2022-09-17 21:27:08 +03:00
|
|
|
}
|
|
|
|
}
|