test
This commit is contained in:
@@ -14,7 +14,7 @@ import { ApPersonService } from './activitypub/models/ApPersonService.js';
|
||||
|
||||
@Injectable()
|
||||
export class ResolveUserService {
|
||||
#logger: Logger;
|
||||
private logger: Logger;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
@@ -28,14 +28,14 @@ export class ResolveUserService {
|
||||
private remoteLoggerService: RemoteLoggerService,
|
||||
private apPersonService: ApPersonService,
|
||||
) {
|
||||
this.#logger = this.remoteLoggerService.logger.createSubLogger('resolve-user');
|
||||
this.logger = this.remoteLoggerService.logger.createSubLogger('resolve-user');
|
||||
}
|
||||
|
||||
public async resolveUser(username: string, host: string | null): Promise<User> {
|
||||
const usernameLower = username.toLowerCase();
|
||||
|
||||
if (host == null) {
|
||||
this.#logger.info(`return local user: ${usernameLower}`);
|
||||
this.logger.info(`return local user: ${usernameLower}`);
|
||||
return await this.usersRepository.findOneBy({ usernameLower, host: IsNull() }).then(u => {
|
||||
if (u == null) {
|
||||
throw new Error('user not found');
|
||||
@@ -48,7 +48,7 @@ export class ResolveUserService {
|
||||
host = this.utilityService.toPuny(host);
|
||||
|
||||
if (this.config.host === host) {
|
||||
this.#logger.info(`return local user: ${usernameLower}`);
|
||||
this.logger.info(`return local user: ${usernameLower}`);
|
||||
return await this.usersRepository.findOneBy({ usernameLower, host: IsNull() }).then(u => {
|
||||
if (u == null) {
|
||||
throw new Error('user not found');
|
||||
@@ -63,9 +63,9 @@ export class ResolveUserService {
|
||||
const acctLower = `${usernameLower}@${host}`;
|
||||
|
||||
if (user == null) {
|
||||
const self = await this.#resolveSelf(acctLower);
|
||||
const self = await this.resolveSelf(acctLower);
|
||||
|
||||
this.#logger.succ(`return new remote user: ${chalk.magenta(acctLower)}`);
|
||||
this.logger.succ(`return new remote user: ${chalk.magenta(acctLower)}`);
|
||||
return await this.apPersonService.createPerson(self.href);
|
||||
}
|
||||
|
||||
@@ -76,13 +76,13 @@ export class ResolveUserService {
|
||||
lastFetchedAt: new Date(),
|
||||
});
|
||||
|
||||
this.#logger.info(`try resync: ${acctLower}`);
|
||||
const self = await this.#resolveSelf(acctLower);
|
||||
this.logger.info(`try resync: ${acctLower}`);
|
||||
const self = await this.resolveSelf(acctLower);
|
||||
|
||||
if (user.uri !== self.href) {
|
||||
// if uri mismatch, Fix (user@host <=> AP's Person id(IRemoteUser.uri)) mapping.
|
||||
this.#logger.info(`uri missmatch: ${acctLower}`);
|
||||
this.#logger.info(`recovery missmatch uri for (username=${username}, host=${host}) from ${user.uri} to ${self.href}`);
|
||||
this.logger.info(`uri missmatch: ${acctLower}`);
|
||||
this.logger.info(`recovery missmatch uri for (username=${username}, host=${host}) from ${user.uri} to ${self.href}`);
|
||||
|
||||
// validate uri
|
||||
const uri = new URL(self.href);
|
||||
@@ -97,12 +97,12 @@ export class ResolveUserService {
|
||||
uri: self.href,
|
||||
});
|
||||
} else {
|
||||
this.#logger.info(`uri is fine: ${acctLower}`);
|
||||
this.logger.info(`uri is fine: ${acctLower}`);
|
||||
}
|
||||
|
||||
await this.apPersonService.updatePerson(self.href);
|
||||
|
||||
this.#logger.info(`return resynced remote user: ${acctLower}`);
|
||||
this.logger.info(`return resynced remote user: ${acctLower}`);
|
||||
return await this.usersRepository.findOneBy({ uri: self.href }).then(u => {
|
||||
if (u == null) {
|
||||
throw new Error('user not found');
|
||||
@@ -112,19 +112,19 @@ export class ResolveUserService {
|
||||
});
|
||||
}
|
||||
|
||||
this.#logger.info(`return existing remote user: ${acctLower}`);
|
||||
this.logger.info(`return existing remote user: ${acctLower}`);
|
||||
return user;
|
||||
}
|
||||
|
||||
async #resolveSelf(acctLower: string) {
|
||||
this.#logger.info(`WebFinger for ${chalk.yellow(acctLower)}`);
|
||||
private async resolveSelf(acctLower: string) {
|
||||
this.logger.info(`WebFinger for ${chalk.yellow(acctLower)}`);
|
||||
const finger = await this.webfingerService.webfinger(acctLower).catch(err => {
|
||||
this.#logger.error(`Failed to WebFinger for ${chalk.yellow(acctLower)}: ${ err.statusCode ?? err.message }`);
|
||||
this.logger.error(`Failed to WebFinger for ${chalk.yellow(acctLower)}: ${ err.statusCode ?? err.message }`);
|
||||
throw new Error(`Failed to WebFinger for ${acctLower}: ${ err.statusCode ?? err.message }`);
|
||||
});
|
||||
const self = finger.links.find(link => link.rel != null && link.rel.toLowerCase() === 'self');
|
||||
if (!self) {
|
||||
this.#logger.error(`Failed to WebFinger for ${chalk.yellow(acctLower)}: self link not found`);
|
||||
this.logger.error(`Failed to WebFinger for ${chalk.yellow(acctLower)}: self link not found`);
|
||||
throw new Error('self link not found');
|
||||
}
|
||||
return self;
|
||||
|
||||
@@ -26,12 +26,12 @@ export class WebfingerService {
|
||||
}
|
||||
|
||||
public async webfinger(query: string): Promise<IWebFinger> {
|
||||
const url = this.#genUrl(query);
|
||||
const url = this.genUrl(query);
|
||||
|
||||
return await this.httpRequestService.getJson(url, 'application/jrd+json, application/json') as IWebFinger;
|
||||
}
|
||||
|
||||
#genUrl(query: string): string {
|
||||
private genUrl(query: string): string {
|
||||
if (query.match(/^https?:\/\//)) {
|
||||
const u = new URL(query);
|
||||
return `${u.protocol}//${u.hostname}/.well-known/webfinger?` + urlQuery({ resource: query });
|
||||
|
||||
@@ -25,8 +25,8 @@ export class ApAudienceService {
|
||||
}
|
||||
|
||||
public async parseAudience(actor: CacheableRemoteUser, to?: ApObject, cc?: ApObject, resolver?: Resolver): Promise<AudienceInfo> {
|
||||
const toGroups = this.#groupingAudience(getApIds(to), actor);
|
||||
const ccGroups = this.#groupingAudience(getApIds(cc), actor);
|
||||
const toGroups = this.groupingAudience(getApIds(to), actor);
|
||||
const ccGroups = this.groupingAudience(getApIds(cc), actor);
|
||||
|
||||
const others = unique(concat([toGroups.other, ccGroups.other]));
|
||||
|
||||
@@ -66,7 +66,7 @@ export class ApAudienceService {
|
||||
};
|
||||
}
|
||||
|
||||
#groupingAudience(ids: string[], actor: CacheableRemoteUser) {
|
||||
private groupingAudience(ids: string[], actor: CacheableRemoteUser) {
|
||||
const groups = {
|
||||
public: [] as string[],
|
||||
followers: [] as string[],
|
||||
@@ -74,9 +74,9 @@ export class ApAudienceService {
|
||||
};
|
||||
|
||||
for (const id of ids) {
|
||||
if (this.#isPublic(id)) {
|
||||
if (this.isPublic(id)) {
|
||||
groups.public.push(id);
|
||||
} else if (this.#isFollowers(id, actor)) {
|
||||
} else if (this.isFollowers(id, actor)) {
|
||||
groups.followers.push(id);
|
||||
} else {
|
||||
groups.other.push(id);
|
||||
@@ -88,7 +88,7 @@ export class ApAudienceService {
|
||||
return groups;
|
||||
}
|
||||
|
||||
#isPublic(id: string) {
|
||||
private isPublic(id: string) {
|
||||
return [
|
||||
'https://www.w3.org/ns/activitystreams#Public',
|
||||
'as#Public',
|
||||
@@ -96,7 +96,7 @@ export class ApAudienceService {
|
||||
].includes(id);
|
||||
}
|
||||
|
||||
#isFollowers(id: string, actor: CacheableRemoteUser) {
|
||||
private isFollowers(id: string, actor: CacheableRemoteUser) {
|
||||
return (
|
||||
id === (actor.followersUri ?? `${actor.uri}/followers`)
|
||||
);
|
||||
|
||||
@@ -31,8 +31,8 @@ export type UriParseResult = {
|
||||
|
||||
@Injectable()
|
||||
export class ApDbResolverService {
|
||||
#publicKeyCache: Cache<UserPublickey | null>;
|
||||
#publicKeyByUserIdCache: Cache<UserPublickey | null>;
|
||||
private publicKeyCache: Cache<UserPublickey | null>;
|
||||
private publicKeyByUserIdCache: Cache<UserPublickey | null>;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
@@ -53,8 +53,8 @@ export class ApDbResolverService {
|
||||
private userCacheService: UserCacheService,
|
||||
private apPersonService: ApPersonService,
|
||||
) {
|
||||
this.#publicKeyCache = new Cache<UserPublickey | null>(Infinity);
|
||||
this.#publicKeyByUserIdCache = new Cache<UserPublickey | null>(Infinity);
|
||||
this.publicKeyCache = new Cache<UserPublickey | null>(Infinity);
|
||||
this.publicKeyByUserIdCache = new Cache<UserPublickey | null>(Infinity);
|
||||
}
|
||||
|
||||
public parseUri(value: string | IObject): UriParseResult {
|
||||
@@ -140,7 +140,7 @@ export class ApDbResolverService {
|
||||
user: CacheableRemoteUser;
|
||||
key: UserPublickey;
|
||||
} | null> {
|
||||
const key = await this.#publicKeyCache.fetch(keyId, async () => {
|
||||
const key = await this.publicKeyCache.fetch(keyId, async () => {
|
||||
const key = await this.userPublickeysRepository.findOneBy({
|
||||
keyId,
|
||||
});
|
||||
@@ -169,7 +169,7 @@ export class ApDbResolverService {
|
||||
|
||||
if (user == null) return null;
|
||||
|
||||
const key = await this.#publicKeyByUserIdCache.fetch(user.id, () => this.userPublickeysRepository.findOneBy({ userId: user.id }), v => v != null);
|
||||
const key = await this.publicKeyByUserIdCache.fetch(user.id, () => this.userPublickeysRepository.findOneBy({ userId: user.id }), v => v != null);
|
||||
|
||||
return {
|
||||
user,
|
||||
|
||||
@@ -34,7 +34,7 @@ import type { IAccept, IAdd, IAnnounce, IBlock, ICreate, IDelete, IFlag, IFollow
|
||||
|
||||
@Injectable()
|
||||
export class ApInboxService {
|
||||
#logger: Logger;
|
||||
private logger: Logger;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
@@ -81,7 +81,7 @@ export class ApInboxService {
|
||||
private queueService: QueueService,
|
||||
private messagingService: MessagingService,
|
||||
) {
|
||||
this.#logger = this.apLoggerService.logger;
|
||||
this.logger = this.apLoggerService.logger;
|
||||
}
|
||||
|
||||
public async performActivity(actor: CacheableRemoteUser, activity: IObject) {
|
||||
@@ -93,7 +93,7 @@ export class ApInboxService {
|
||||
await this.performOneActivity(actor, act);
|
||||
} catch (err) {
|
||||
if (err instanceof Error || typeof err === 'string') {
|
||||
this.#logger.error(err);
|
||||
this.logger.error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,39 +115,39 @@ export class ApInboxService {
|
||||
if (actor.isSuspended) return;
|
||||
|
||||
if (isCreate(activity)) {
|
||||
await this.#create(actor, activity);
|
||||
await this.create(actor, activity);
|
||||
} else if (isDelete(activity)) {
|
||||
await this.#delete(actor, activity);
|
||||
await this.delete(actor, activity);
|
||||
} else if (isUpdate(activity)) {
|
||||
await this.#update(actor, activity);
|
||||
await this.update(actor, activity);
|
||||
} else if (isRead(activity)) {
|
||||
await this.#read(actor, activity);
|
||||
await this.read(actor, activity);
|
||||
} else if (isFollow(activity)) {
|
||||
await this.#follow(actor, activity);
|
||||
await this.follow(actor, activity);
|
||||
} else if (isAccept(activity)) {
|
||||
await this.#accept(actor, activity);
|
||||
await this.accept(actor, activity);
|
||||
} else if (isReject(activity)) {
|
||||
await this.#reject(actor, activity);
|
||||
await this.reject(actor, activity);
|
||||
} else if (isAdd(activity)) {
|
||||
await this.#add(actor, activity).catch(err => this.#logger.error(err));
|
||||
await this.add(actor, activity).catch(err => this.logger.error(err));
|
||||
} else if (isRemove(activity)) {
|
||||
await this.#remove(actor, activity).catch(err => this.#logger.error(err));
|
||||
await this.remove(actor, activity).catch(err => this.logger.error(err));
|
||||
} else if (isAnnounce(activity)) {
|
||||
await this.#announce(actor, activity);
|
||||
await this.announce(actor, activity);
|
||||
} else if (isLike(activity)) {
|
||||
await this.#like(actor, activity);
|
||||
await this.like(actor, activity);
|
||||
} else if (isUndo(activity)) {
|
||||
await this.#undo(actor, activity);
|
||||
await this.undo(actor, activity);
|
||||
} else if (isBlock(activity)) {
|
||||
await this.#block(actor, activity);
|
||||
await this.block(actor, activity);
|
||||
} else if (isFlag(activity)) {
|
||||
await this.#flag(actor, activity);
|
||||
await this.flag(actor, activity);
|
||||
} else {
|
||||
this.#logger.warn(`unrecognized activity type: ${(activity as any).type}`);
|
||||
this.logger.warn(`unrecognized activity type: ${(activity as any).type}`);
|
||||
}
|
||||
}
|
||||
|
||||
async #follow(actor: CacheableRemoteUser, activity: IFollow): Promise<string> {
|
||||
private async follow(actor: CacheableRemoteUser, activity: IFollow): Promise<string> {
|
||||
const followee = await this.apDbResolverService.getUserFromApId(activity.object);
|
||||
|
||||
if (followee == null) {
|
||||
@@ -162,7 +162,7 @@ export class ApInboxService {
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
async #like(actor: CacheableRemoteUser, activity: ILike): Promise<string> {
|
||||
private async like(actor: CacheableRemoteUser, activity: ILike): Promise<string> {
|
||||
const targetUri = getApId(activity.object);
|
||||
|
||||
const note = await this.apNoteService.fetchNote(targetUri);
|
||||
@@ -179,7 +179,7 @@ export class ApInboxService {
|
||||
}).then(() => 'ok');
|
||||
}
|
||||
|
||||
async #read(actor: CacheableRemoteUser, activity: IRead): Promise<string> {
|
||||
private async read(actor: CacheableRemoteUser, activity: IRead): Promise<string> {
|
||||
const id = await getApId(activity.object);
|
||||
|
||||
if (!this.utilityService.isSelfHost(this.utilityService.extractDbHost(id))) {
|
||||
@@ -201,24 +201,24 @@ export class ApInboxService {
|
||||
return `ok: mark as read (${message.userId} => ${message.recipientId} ${message.id})`;
|
||||
}
|
||||
|
||||
async #accept(actor: CacheableRemoteUser, activity: IAccept): Promise<string> {
|
||||
private async accept(actor: CacheableRemoteUser, activity: IAccept): Promise<string> {
|
||||
const uri = activity.id ?? activity;
|
||||
|
||||
this.#logger.info(`Accept: ${uri}`);
|
||||
this.logger.info(`Accept: ${uri}`);
|
||||
|
||||
const resolver = this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(err => {
|
||||
this.#logger.error(`Resolution failed: ${err}`);
|
||||
this.logger.error(`Resolution failed: ${err}`);
|
||||
throw err;
|
||||
});
|
||||
|
||||
if (isFollow(object)) return await this.#acceptFollow(actor, object);
|
||||
if (isFollow(object)) return await this.acceptFollow(actor, object);
|
||||
|
||||
return `skip: Unknown Accept type: ${getApType(object)}`;
|
||||
}
|
||||
|
||||
async #acceptFollow(actor: CacheableRemoteUser, activity: IFollow): Promise<string> {
|
||||
private async acceptFollow(actor: CacheableRemoteUser, activity: IFollow): Promise<string> {
|
||||
// ※ activityはこっちから投げたフォローリクエストなので、activity.actorは存在するローカルユーザーである必要がある
|
||||
|
||||
const follower = await this.apDbResolverService.getUserFromApId(activity.actor);
|
||||
@@ -241,7 +241,7 @@ export class ApInboxService {
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
async #add(actor: CacheableRemoteUser, activity: IAdd): Promise<void> {
|
||||
private async add(actor: CacheableRemoteUser, activity: IAdd): Promise<void> {
|
||||
if ('actor' in activity && actor.uri !== activity.actor) {
|
||||
throw new Error('invalid actor');
|
||||
}
|
||||
@@ -260,17 +260,17 @@ export class ApInboxService {
|
||||
throw new Error(`unknown target: ${activity.target}`);
|
||||
}
|
||||
|
||||
async #announce(actor: CacheableRemoteUser, activity: IAnnounce): Promise<void> {
|
||||
private async announce(actor: CacheableRemoteUser, activity: IAnnounce): Promise<void> {
|
||||
const uri = getApId(activity);
|
||||
|
||||
this.#logger.info(`Announce: ${uri}`);
|
||||
this.logger.info(`Announce: ${uri}`);
|
||||
|
||||
const targetUri = getApId(activity.object);
|
||||
|
||||
this.#announceNote(actor, activity, targetUri);
|
||||
this.announceNote(actor, activity, targetUri);
|
||||
}
|
||||
|
||||
async #announceNote(actor: CacheableRemoteUser, activity: IAnnounce, targetUri: string): Promise<void> {
|
||||
private async announceNote(actor: CacheableRemoteUser, activity: IAnnounce, targetUri: string): Promise<void> {
|
||||
const uri = getApId(activity);
|
||||
|
||||
if (actor.isSuspended) {
|
||||
@@ -298,18 +298,18 @@ export class ApInboxService {
|
||||
// 対象が4xxならスキップ
|
||||
if (err instanceof StatusError) {
|
||||
if (err.isClientError) {
|
||||
this.#logger.warn(`Ignored announce target ${targetUri} - ${err.statusCode}`);
|
||||
this.logger.warn(`Ignored announce target ${targetUri} - ${err.statusCode}`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.#logger.warn(`Error in announce target ${targetUri} - ${err.statusCode ?? err}`);
|
||||
this.logger.warn(`Error in announce target ${targetUri} - ${err.statusCode ?? err}`);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!await this.noteEntityService.isVisibleForMe(renote, actor.id)) return 'skip: invalid actor for this activity';
|
||||
|
||||
this.#logger.info(`Creating the (Re)Note: ${uri}`);
|
||||
this.logger.info(`Creating the (Re)Note: ${uri}`);
|
||||
|
||||
const activityAudience = await this.apAudienceService.parseAudience(actor, activity.to, activity.cc);
|
||||
|
||||
@@ -325,7 +325,7 @@ export class ApInboxService {
|
||||
}
|
||||
}
|
||||
|
||||
async #block(actor: CacheableRemoteUser, activity: IBlock): Promise<string> {
|
||||
private async block(actor: CacheableRemoteUser, activity: IBlock): Promise<string> {
|
||||
// ※ activity.objectにブロック対象があり、それは存在するローカルユーザーのはず
|
||||
|
||||
const blockee = await this.apDbResolverService.getUserFromApId(activity.object);
|
||||
@@ -342,10 +342,10 @@ export class ApInboxService {
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
async #create(actor: CacheableRemoteUser, activity: ICreate): Promise<void> {
|
||||
private async create(actor: CacheableRemoteUser, activity: ICreate): Promise<void> {
|
||||
const uri = getApId(activity);
|
||||
|
||||
this.#logger.info(`Create: ${uri}`);
|
||||
this.logger.info(`Create: ${uri}`);
|
||||
|
||||
// copy audiences between activity <=> object.
|
||||
if (typeof activity.object === 'object') {
|
||||
@@ -366,18 +366,18 @@ export class ApInboxService {
|
||||
const resolver = this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(e => {
|
||||
this.#logger.error(`Resolution failed: ${e}`);
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
throw e;
|
||||
});
|
||||
|
||||
if (isPost(object)) {
|
||||
this.#createNote(resolver, actor, object, false, activity);
|
||||
this.createNote(resolver, actor, object, false, activity);
|
||||
} else {
|
||||
this.#logger.warn(`Unknown type: ${getApType(object)}`);
|
||||
this.logger.warn(`Unknown type: ${getApType(object)}`);
|
||||
}
|
||||
}
|
||||
|
||||
async #createNote(resolver: Resolver, actor: CacheableRemoteUser, note: IObject, silent = false, activity?: ICreate): Promise<string> {
|
||||
private async createNote(resolver: Resolver, actor: CacheableRemoteUser, note: IObject, silent = false, activity?: ICreate): Promise<string> {
|
||||
const uri = getApId(note);
|
||||
|
||||
if (typeof note === 'object') {
|
||||
@@ -411,7 +411,7 @@ export class ApInboxService {
|
||||
}
|
||||
}
|
||||
|
||||
async #delete(actor: CacheableRemoteUser, activity: IDelete): Promise<string> {
|
||||
private async delete(actor: CacheableRemoteUser, activity: IDelete): Promise<string> {
|
||||
if ('actor' in activity && actor.uri !== activity.actor) {
|
||||
throw new Error('invalid actor');
|
||||
}
|
||||
@@ -444,16 +444,16 @@ export class ApInboxService {
|
||||
}
|
||||
|
||||
if (validPost.includes(formerType)) {
|
||||
return await this.#deleteNote(actor, uri);
|
||||
return await this.deleteNote(actor, uri);
|
||||
} else if (validActor.includes(formerType)) {
|
||||
return await this.#deleteActor(actor, uri);
|
||||
return await this.deleteActor(actor, uri);
|
||||
} else {
|
||||
return `Unknown type ${formerType}`;
|
||||
}
|
||||
}
|
||||
|
||||
async #deleteActor(actor: CacheableRemoteUser, uri: string): Promise<string> {
|
||||
this.#logger.info(`Deleting the Actor: ${uri}`);
|
||||
private async deleteActor(actor: CacheableRemoteUser, uri: string): Promise<string> {
|
||||
this.logger.info(`Deleting the Actor: ${uri}`);
|
||||
|
||||
if (actor.uri !== uri) {
|
||||
return `skip: delete actor ${actor.uri} !== ${uri}`;
|
||||
@@ -461,7 +461,7 @@ export class ApInboxService {
|
||||
|
||||
const user = await this.usersRepository.findOneByOrFail({ id: actor.id });
|
||||
if (user.isDeleted) {
|
||||
this.#logger.info('skip: already deleted');
|
||||
this.logger.info('skip: already deleted');
|
||||
}
|
||||
|
||||
const job = await this.queueService.createDeleteAccountJob(actor);
|
||||
@@ -473,8 +473,8 @@ export class ApInboxService {
|
||||
return `ok: queued ${job.name} ${job.id}`;
|
||||
}
|
||||
|
||||
async #deleteNote(actor: CacheableRemoteUser, uri: string): Promise<string> {
|
||||
this.#logger.info(`Deleting the Note: ${uri}`);
|
||||
private async deleteNote(actor: CacheableRemoteUser, uri: string): Promise<string> {
|
||||
this.logger.info(`Deleting the Note: ${uri}`);
|
||||
|
||||
const unlock = await this.appLockService.getApLock(uri);
|
||||
|
||||
@@ -505,7 +505,7 @@ export class ApInboxService {
|
||||
}
|
||||
}
|
||||
|
||||
async #flag(actor: CacheableRemoteUser, activity: IFlag): Promise<string> {
|
||||
private async flag(actor: CacheableRemoteUser, activity: IFlag): Promise<string> {
|
||||
// objectは `(User|Note) | (User|Note)[]` だけど、全パターンDBスキーマと対応させられないので
|
||||
// 対象ユーザーは一番最初のユーザー として あとはコメントとして格納する
|
||||
const uris = getApIds(activity.object);
|
||||
@@ -529,24 +529,24 @@ export class ApInboxService {
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
async #reject(actor: CacheableRemoteUser, activity: IReject): Promise<string> {
|
||||
private async reject(actor: CacheableRemoteUser, activity: IReject): Promise<string> {
|
||||
const uri = activity.id ?? activity;
|
||||
|
||||
this.#logger.info(`Reject: ${uri}`);
|
||||
this.logger.info(`Reject: ${uri}`);
|
||||
|
||||
const resolver = this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(e => {
|
||||
this.#logger.error(`Resolution failed: ${e}`);
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
throw e;
|
||||
});
|
||||
|
||||
if (isFollow(object)) return await this.#rejectFollow(actor, object);
|
||||
if (isFollow(object)) return await this.rejectFollow(actor, object);
|
||||
|
||||
return `skip: Unknown Reject type: ${getApType(object)}`;
|
||||
}
|
||||
|
||||
async #rejectFollow(actor: CacheableRemoteUser, activity: IFollow): Promise<string> {
|
||||
private async rejectFollow(actor: CacheableRemoteUser, activity: IFollow): Promise<string> {
|
||||
// ※ activityはこっちから投げたフォローリクエストなので、activity.actorは存在するローカルユーザーである必要がある
|
||||
|
||||
const follower = await this.apDbResolverService.getUserFromApId(activity.actor);
|
||||
@@ -569,7 +569,7 @@ export class ApInboxService {
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
async #remove(actor: CacheableRemoteUser, activity: IRemove): Promise<void> {
|
||||
private async remove(actor: CacheableRemoteUser, activity: IRemove): Promise<void> {
|
||||
if ('actor' in activity && actor.uri !== activity.actor) {
|
||||
throw new Error('invalid actor');
|
||||
}
|
||||
@@ -588,32 +588,32 @@ export class ApInboxService {
|
||||
throw new Error(`unknown target: ${activity.target}`);
|
||||
}
|
||||
|
||||
async #undo(actor: CacheableRemoteUser, activity: IUndo): Promise<string> {
|
||||
private async undo(actor: CacheableRemoteUser, activity: IUndo): Promise<string> {
|
||||
if ('actor' in activity && actor.uri !== activity.actor) {
|
||||
throw new Error('invalid actor');
|
||||
}
|
||||
|
||||
const uri = activity.id ?? activity;
|
||||
|
||||
this.#logger.info(`Undo: ${uri}`);
|
||||
this.logger.info(`Undo: ${uri}`);
|
||||
|
||||
const resolver = this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(e => {
|
||||
this.#logger.error(`Resolution failed: ${e}`);
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
throw e;
|
||||
});
|
||||
|
||||
if (isFollow(object)) return await this.#undoFollow(actor, object);
|
||||
if (isBlock(object)) return await this.#undoBlock(actor, object);
|
||||
if (isLike(object)) return await this.#undoLike(actor, object);
|
||||
if (isAnnounce(object)) return await this.#undoAnnounce(actor, object);
|
||||
if (isAccept(object)) return await this.#undoAccept(actor, object);
|
||||
if (isFollow(object)) return await this.undoFollow(actor, object);
|
||||
if (isBlock(object)) return await this.undoBlock(actor, object);
|
||||
if (isLike(object)) return await this.undoLike(actor, object);
|
||||
if (isAnnounce(object)) return await this.undoAnnounce(actor, object);
|
||||
if (isAccept(object)) return await this.undoAccept(actor, object);
|
||||
|
||||
return `skip: unknown object type ${getApType(object)}`;
|
||||
}
|
||||
|
||||
async #undoAccept(actor: CacheableRemoteUser, activity: IAccept): Promise<string> {
|
||||
private async undoAccept(actor: CacheableRemoteUser, activity: IAccept): Promise<string> {
|
||||
const follower = await this.apDbResolverService.getUserFromApId(activity.object);
|
||||
if (follower == null) {
|
||||
return 'skip: follower not found';
|
||||
@@ -632,7 +632,7 @@ export class ApInboxService {
|
||||
return 'skip: フォローされていない';
|
||||
}
|
||||
|
||||
async #undoAnnounce(actor: CacheableRemoteUser, activity: IAnnounce): Promise<string> {
|
||||
private async undoAnnounce(actor: CacheableRemoteUser, activity: IAnnounce): Promise<string> {
|
||||
const uri = getApId(activity);
|
||||
|
||||
const note = await this.notesRepository.findOneBy({
|
||||
@@ -646,7 +646,7 @@ export class ApInboxService {
|
||||
return 'ok: deleted';
|
||||
}
|
||||
|
||||
async #undoBlock(actor: CacheableRemoteUser, activity: IBlock): Promise<string> {
|
||||
private async undoBlock(actor: CacheableRemoteUser, activity: IBlock): Promise<string> {
|
||||
const blockee = await this.apDbResolverService.getUserFromApId(activity.object);
|
||||
|
||||
if (blockee == null) {
|
||||
@@ -661,7 +661,7 @@ export class ApInboxService {
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
async #undoFollow(actor: CacheableRemoteUser, activity: IFollow): Promise<string> {
|
||||
private async undoFollow(actor: CacheableRemoteUser, activity: IFollow): Promise<string> {
|
||||
const followee = await this.apDbResolverService.getUserFromApId(activity.object);
|
||||
if (followee == null) {
|
||||
return 'skip: followee not found';
|
||||
@@ -694,7 +694,7 @@ export class ApInboxService {
|
||||
return 'skip: リクエストもフォローもされていない';
|
||||
}
|
||||
|
||||
async #undoLike(actor: CacheableRemoteUser, activity: ILike): Promise<string> {
|
||||
private async undoLike(actor: CacheableRemoteUser, activity: ILike): Promise<string> {
|
||||
const targetUri = getApId(activity.object);
|
||||
|
||||
const note = await this.apNoteService.fetchNote(targetUri);
|
||||
@@ -708,17 +708,17 @@ export class ApInboxService {
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
async #update(actor: CacheableRemoteUser, activity: IUpdate): Promise<string> {
|
||||
private async update(actor: CacheableRemoteUser, activity: IUpdate): Promise<string> {
|
||||
if ('actor' in activity && actor.uri !== activity.actor) {
|
||||
return 'skip: invalid actor';
|
||||
}
|
||||
|
||||
this.#logger.debug('Update');
|
||||
this.logger.debug('Update');
|
||||
|
||||
const resolver = this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(e => {
|
||||
this.#logger.error(`Resolution failed: ${e}`);
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
throw e;
|
||||
});
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ export class ApRendererService {
|
||||
text: apText,
|
||||
}));
|
||||
|
||||
const emojis = await this.#getEmojis(note.emojis);
|
||||
const emojis = await this.getEmojis(note.emojis);
|
||||
const apemojis = emojis.map(emoji => this.renderEmoji(emoji));
|
||||
|
||||
const tag = [
|
||||
@@ -448,7 +448,7 @@ export class ApRendererService {
|
||||
}
|
||||
}
|
||||
|
||||
const emojis = await this.#getEmojis(user.emojis);
|
||||
const emojis = await this.getEmojis(user.emojis);
|
||||
const apemojis = emojis.map(emoji => this.renderEmoji(emoji));
|
||||
|
||||
const hashtagTags = (user.tags ?? []).map(tag => this.renderHashtag(tag));
|
||||
@@ -687,7 +687,7 @@ export class ApRendererService {
|
||||
return page;
|
||||
}
|
||||
|
||||
async #getEmojis(names: string[]): Promise<Emoji[]> {
|
||||
private async getEmojis(names: string[]): Promise<Emoji[]> {
|
||||
if (names == null || names.length === 0) return [];
|
||||
|
||||
const emojis = await Promise.all(
|
||||
|
||||
@@ -36,14 +36,14 @@ export class ApRequestService {
|
||||
) {
|
||||
}
|
||||
|
||||
#createSignedPost(args: { key: PrivateKey, url: string, body: string, additionalHeaders: Record<string, string> }): Signed {
|
||||
private createSignedPost(args: { key: PrivateKey, url: string, body: string, additionalHeaders: Record<string, string> }): Signed {
|
||||
const u = new URL(args.url);
|
||||
const digestHeader = `SHA-256=${crypto.createHash('sha256').update(args.body).digest('base64')}`;
|
||||
|
||||
const request: Request = {
|
||||
url: u.href,
|
||||
method: 'POST',
|
||||
headers: this.#objectAssignWithLcKey({
|
||||
headers: this.objectAssignWithLcKey({
|
||||
'Date': new Date().toUTCString(),
|
||||
'Host': u.hostname,
|
||||
'Content-Type': 'application/activity+json',
|
||||
@@ -51,7 +51,7 @@ export class ApRequestService {
|
||||
}, args.additionalHeaders),
|
||||
};
|
||||
|
||||
const result = this.#signToRequest(request, args.key, ['(request-target)', 'date', 'host', 'digest']);
|
||||
const result = this.signToRequest(request, args.key, ['(request-target)', 'date', 'host', 'digest']);
|
||||
|
||||
return {
|
||||
request,
|
||||
@@ -61,20 +61,20 @@ export class ApRequestService {
|
||||
};
|
||||
}
|
||||
|
||||
#createSignedGet(args: { key: PrivateKey, url: string, additionalHeaders: Record<string, string> }): Signed {
|
||||
private createSignedGet(args: { key: PrivateKey, url: string, additionalHeaders: Record<string, string> }): Signed {
|
||||
const u = new URL(args.url);
|
||||
|
||||
const request: Request = {
|
||||
url: u.href,
|
||||
method: 'GET',
|
||||
headers: this.#objectAssignWithLcKey({
|
||||
headers: this.objectAssignWithLcKey({
|
||||
'Accept': 'application/activity+json, application/ld+json',
|
||||
'Date': new Date().toUTCString(),
|
||||
'Host': new URL(args.url).hostname,
|
||||
}, args.additionalHeaders),
|
||||
};
|
||||
|
||||
const result = this.#signToRequest(request, args.key, ['(request-target)', 'date', 'host', 'accept']);
|
||||
const result = this.signToRequest(request, args.key, ['(request-target)', 'date', 'host', 'accept']);
|
||||
|
||||
return {
|
||||
request,
|
||||
@@ -84,12 +84,12 @@ export class ApRequestService {
|
||||
};
|
||||
}
|
||||
|
||||
#signToRequest(request: Request, key: PrivateKey, includeHeaders: string[]): Signed {
|
||||
const signingString = this.#genSigningString(request, includeHeaders);
|
||||
private signToRequest(request: Request, key: PrivateKey, includeHeaders: string[]): Signed {
|
||||
const signingString = this.genSigningString(request, includeHeaders);
|
||||
const signature = crypto.sign('sha256', Buffer.from(signingString), key.privateKeyPem).toString('base64');
|
||||
const signatureHeader = `keyId="${key.keyId}",algorithm="rsa-sha256",headers="${includeHeaders.join(' ')}",signature="${signature}"`;
|
||||
|
||||
request.headers = this.#objectAssignWithLcKey(request.headers, {
|
||||
request.headers = this.objectAssignWithLcKey(request.headers, {
|
||||
Signature: signatureHeader,
|
||||
});
|
||||
|
||||
@@ -101,8 +101,8 @@ export class ApRequestService {
|
||||
};
|
||||
}
|
||||
|
||||
#genSigningString(request: Request, includeHeaders: string[]): string {
|
||||
request.headers = this.#lcObjectKey(request.headers);
|
||||
private genSigningString(request: Request, includeHeaders: string[]): string {
|
||||
request.headers = this.lcObjectKey(request.headers);
|
||||
|
||||
const results: string[] = [];
|
||||
|
||||
@@ -117,14 +117,14 @@ export class ApRequestService {
|
||||
return results.join('\n');
|
||||
}
|
||||
|
||||
#lcObjectKey(src: Record<string, string>): Record<string, string> {
|
||||
private lcObjectKey(src: Record<string, string>): Record<string, string> {
|
||||
const dst: Record<string, string> = {};
|
||||
for (const key of Object.keys(src).filter(x => x !== '__proto__' && typeof src[x] === 'string')) dst[key.toLowerCase()] = src[key];
|
||||
return dst;
|
||||
}
|
||||
|
||||
#objectAssignWithLcKey(a: Record<string, string>, b: Record<string, string>): Record<string, string> {
|
||||
return Object.assign(this.#lcObjectKey(a), this.#lcObjectKey(b));
|
||||
private objectAssignWithLcKey(a: Record<string, string>, b: Record<string, string>): Record<string, string> {
|
||||
return Object.assign(this.lcObjectKey(a), this.lcObjectKey(b));
|
||||
}
|
||||
|
||||
public async signedPost(user: { id: User['id'] }, url: string, object: any) {
|
||||
@@ -132,7 +132,7 @@ export class ApRequestService {
|
||||
|
||||
const keypair = await this.userKeypairStoreService.getUserKeypair(user.id);
|
||||
|
||||
const req = this.#createSignedPost({
|
||||
const req = this.createSignedPost({
|
||||
key: {
|
||||
privateKeyPem: keypair.privateKey,
|
||||
keyId: `${this.config.url}/users/${user.id}#main-key`,
|
||||
@@ -160,7 +160,7 @@ export class ApRequestService {
|
||||
public async signedGet(url: string, user: { id: User['id'] }) {
|
||||
const keypair = await this.userKeypairStoreService.getUserKeypair(user.id);
|
||||
|
||||
const req = this.#createSignedGet({
|
||||
const req = this.createSignedGet({
|
||||
key: {
|
||||
privateKeyPem: keypair.privateKey,
|
||||
keyId: `${this.config.url}/users/${user.id}#main-key`,
|
||||
|
||||
@@ -14,7 +14,7 @@ import { ApLoggerService } from '../ApLoggerService.js';
|
||||
|
||||
@Injectable()
|
||||
export class ApImageService {
|
||||
#logger: Logger;
|
||||
private logger: Logger;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
@@ -28,7 +28,7 @@ export class ApImageService {
|
||||
private driveService: DriveService,
|
||||
private apLoggerService: ApLoggerService,
|
||||
) {
|
||||
this.#logger = this.apLoggerService.logger;
|
||||
this.logger = this.apLoggerService.logger;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@ export class ApImageService {
|
||||
throw new Error('invalid image: url not privided');
|
||||
}
|
||||
|
||||
this.#logger.info(`Creating the Image: ${image.url}`);
|
||||
this.logger.info(`Creating the Image: ${image.url}`);
|
||||
|
||||
const instance = await this.metaService.fetch();
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import type { IObject, IPost } from '../type.js';
|
||||
|
||||
@Injectable()
|
||||
export class ApNoteService {
|
||||
#logger: Logger;
|
||||
private logger: Logger;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
@@ -71,7 +71,7 @@ export class ApNoteService {
|
||||
private apDbResolverService: ApDbResolverService,
|
||||
private apLoggerService: ApLoggerService,
|
||||
) {
|
||||
this.#logger = this.apLoggerService.logger;
|
||||
this.logger = this.apLoggerService.logger;
|
||||
}
|
||||
|
||||
public validateNote(object: any, uri: string) {
|
||||
@@ -116,7 +116,7 @@ export class ApNoteService {
|
||||
const entryUri = getApId(value);
|
||||
const err = this.validateNote(object, entryUri);
|
||||
if (err) {
|
||||
this.#logger.error(`${err.message}`, {
|
||||
this.logger.error(`${err.message}`, {
|
||||
resolver: {
|
||||
history: resolver.getHistory(),
|
||||
},
|
||||
@@ -128,9 +128,9 @@ export class ApNoteService {
|
||||
|
||||
const note: IPost = object;
|
||||
|
||||
this.#logger.debug(`Note fetched: ${JSON.stringify(note, null, 2)}`);
|
||||
this.logger.debug(`Note fetched: ${JSON.stringify(note, null, 2)}`);
|
||||
|
||||
this.#logger.info(`Creating the Note: ${note.id}`);
|
||||
this.logger.info(`Creating the Note: ${note.id}`);
|
||||
|
||||
// 投稿者をフェッチ
|
||||
const actor = await this.apPersonService.resolvePerson(getOneApId(note.attributedTo), resolver) as CacheableRemoteUser;
|
||||
@@ -174,7 +174,7 @@ export class ApNoteService {
|
||||
const reply: Note | null = note.inReplyTo
|
||||
? await this.resolveNote(note.inReplyTo, resolver).then(x => {
|
||||
if (x == null) {
|
||||
this.#logger.warn('Specified inReplyTo, but nout found');
|
||||
this.logger.warn('Specified inReplyTo, but nout found');
|
||||
throw new Error('inReplyTo not found');
|
||||
} else {
|
||||
return x;
|
||||
@@ -191,7 +191,7 @@ export class ApNoteService {
|
||||
}
|
||||
}
|
||||
|
||||
this.#logger.warn(`Error in inReplyTo ${note.inReplyTo} - ${err.statusCode ?? err}`);
|
||||
this.logger.warn(`Error in inReplyTo ${note.inReplyTo} - ${err.statusCode ?? err}`);
|
||||
throw err;
|
||||
})
|
||||
: null;
|
||||
@@ -255,9 +255,9 @@ export class ApNoteService {
|
||||
|
||||
const tryCreateVote = async (name: string, index: number): Promise<null> => {
|
||||
if (poll.expiresAt && Date.now() > new Date(poll.expiresAt).getTime()) {
|
||||
this.#logger.warn(`vote to expired poll from AP: actor=${actor.username}@${actor.host}, note=${note.id}, choice=${name}`);
|
||||
this.logger.warn(`vote to expired poll from AP: actor=${actor.username}@${actor.host}, note=${note.id}, choice=${name}`);
|
||||
} else if (index >= 0) {
|
||||
this.#logger.info(`vote from AP: actor=${actor.username}@${actor.host}, note=${note.id}, choice=${name}`);
|
||||
this.logger.info(`vote from AP: actor=${actor.username}@${actor.host}, note=${note.id}, choice=${name}`);
|
||||
await this.pollService.vote(actor, reply, index);
|
||||
|
||||
// リモートフォロワーにUpdate配信
|
||||
@@ -272,7 +272,7 @@ export class ApNoteService {
|
||||
}
|
||||
|
||||
const emojis = await this.extractEmojis(note.tag ?? [], actor.host).catch(e => {
|
||||
this.#logger.info(`extractEmojis: ${e}`);
|
||||
this.logger.info(`extractEmojis: ${e}`);
|
||||
return [] as Emoji[];
|
||||
});
|
||||
|
||||
@@ -386,7 +386,7 @@ export class ApNoteService {
|
||||
return exists;
|
||||
}
|
||||
|
||||
this.#logger.info(`register emoji host=${host}, name=${name}`);
|
||||
this.logger.info(`register emoji host=${host}, name=${name}`);
|
||||
|
||||
return await this.emojisRepository.insert({
|
||||
id: this.idService.genId(),
|
||||
|
||||
@@ -91,7 +91,7 @@ export class ApPersonService implements OnModuleInit {
|
||||
private usersChart: UsersChart;
|
||||
private instanceChart: InstanceChart;
|
||||
private apLoggerService: ApLoggerService;
|
||||
#logger: Logger;
|
||||
private logger: Logger;
|
||||
|
||||
constructor(
|
||||
private moduleRef: ModuleRef,
|
||||
@@ -153,7 +153,7 @@ export class ApPersonService implements OnModuleInit {
|
||||
this.usersChart = this.moduleRef.get('UsersChart');
|
||||
this.instanceChart = this.moduleRef.get('InstanceChart');
|
||||
this.apLoggerService = this.moduleRef.get('ApLoggerService');
|
||||
this.#logger = this.apLoggerService.logger;
|
||||
this.logger = this.apLoggerService.logger;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ export class ApPersonService implements OnModuleInit {
|
||||
* @param x Fetched object
|
||||
* @param uri Fetch target URI
|
||||
*/
|
||||
#validateActor(x: IObject, uri: string): IActor {
|
||||
private validateActor(x: IObject, uri: string): IActor {
|
||||
const expectHost = this.utilityService.toPuny(new URL(uri).hostname);
|
||||
|
||||
if (x == null) {
|
||||
@@ -264,9 +264,9 @@ export class ApPersonService implements OnModuleInit {
|
||||
|
||||
const object = await resolver.resolve(uri) as any;
|
||||
|
||||
const person = this.#validateActor(object, uri);
|
||||
const person = this.validateActor(object, uri);
|
||||
|
||||
this.#logger.info(`Creating the Person: ${person.id}`);
|
||||
this.logger.info(`Creating the Person: ${person.id}`);
|
||||
|
||||
const host = this.utilityService.toPuny(new URL(object.id).hostname);
|
||||
|
||||
@@ -338,7 +338,7 @@ export class ApPersonService implements OnModuleInit {
|
||||
throw new Error('already registered');
|
||||
}
|
||||
} else {
|
||||
this.#logger.error(e instanceof Error ? e : new Error(e as string));
|
||||
this.logger.error(e instanceof Error ? e : new Error(e as string));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -379,7 +379,7 @@ export class ApPersonService implements OnModuleInit {
|
||||
|
||||
//#region カスタム絵文字取得
|
||||
const emojis = await this.apNoteService.extractEmojis(person.tag ?? [], host).catch(err => {
|
||||
this.#logger.info(`extractEmojis: ${err}`);
|
||||
this.logger.info(`extractEmojis: ${err}`);
|
||||
return [] as Emoji[];
|
||||
});
|
||||
|
||||
@@ -390,7 +390,7 @@ export class ApPersonService implements OnModuleInit {
|
||||
});
|
||||
//#endregion
|
||||
|
||||
await this.updateFeatured(user!.id).catch(err => this.#logger.error(err));
|
||||
await this.updateFeatured(user!.id).catch(err => this.logger.error(err));
|
||||
|
||||
return user!;
|
||||
}
|
||||
@@ -422,9 +422,9 @@ export class ApPersonService implements OnModuleInit {
|
||||
|
||||
const object = hint ?? await resolver.resolve(uri);
|
||||
|
||||
const person = this.#validateActor(object, uri);
|
||||
const person = this.validateActor(object, uri);
|
||||
|
||||
this.#logger.info(`Updating the Person: ${person.id}`);
|
||||
this.logger.info(`Updating the Person: ${person.id}`);
|
||||
|
||||
// アバターとヘッダー画像をフェッチ
|
||||
const [avatar, banner] = await Promise.all([
|
||||
@@ -438,7 +438,7 @@ export class ApPersonService implements OnModuleInit {
|
||||
|
||||
// カスタム絵文字取得
|
||||
const emojis = await this.apNoteService.extractEmojis(person.tag ?? [], exist.host).catch(e => {
|
||||
this.#logger.info(`extractEmojis: ${e}`);
|
||||
this.logger.info(`extractEmojis: ${e}`);
|
||||
return [] as Emoji[];
|
||||
});
|
||||
|
||||
@@ -503,7 +503,7 @@ export class ApPersonService implements OnModuleInit {
|
||||
followerSharedInbox: person.sharedInbox ?? (person.endpoints ? person.endpoints.sharedInbox : undefined),
|
||||
});
|
||||
|
||||
await this.updateFeatured(exist.id).catch(err => this.#logger.error(err));
|
||||
await this.updateFeatured(exist.id).catch(err => this.logger.error(err));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -556,7 +556,7 @@ export class ApPersonService implements OnModuleInit {
|
||||
if (!this.userEntityService.isRemoteUser(user)) return;
|
||||
if (!user.featured) return;
|
||||
|
||||
this.#logger.info(`Updating the featured: ${user.uri}`);
|
||||
this.logger.info(`Updating the featured: ${user.uri}`);
|
||||
|
||||
const resolver = this.apResolverService.createResolver();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import type { IObject, IQuestion } from '../type.js';
|
||||
|
||||
@Injectable()
|
||||
export class ApQuestionService {
|
||||
#logger: Logger;
|
||||
private logger: Logger;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
@@ -27,7 +27,7 @@ export class ApQuestionService {
|
||||
private apResolverService: ApResolverService,
|
||||
private apLoggerService: ApLoggerService,
|
||||
) {
|
||||
this.#logger = this.apLoggerService.logger;
|
||||
this.logger = this.apLoggerService.logger;
|
||||
}
|
||||
|
||||
public async extractPollFromQuestion(source: string | IObject, resolver?: Resolver): Promise<IPoll> {
|
||||
@@ -82,7 +82,7 @@ export class ApQuestionService {
|
||||
// resolve new Question object
|
||||
const resolver = this.apResolverService.createResolver();
|
||||
const question = await resolver.resolve(value) as IQuestion;
|
||||
this.#logger.debug(`fetched question: ${JSON.stringify(question, null, 2)}`);
|
||||
this.logger.debug(`fetched question: ${JSON.stringify(question, null, 2)}`);
|
||||
|
||||
if (question.type !== 'Question') throw new Error('object is not a Question');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user