lint and type fixes

This commit is contained in:
Hazelnoot 2025-04-01 20:47:04 -04:00
parent 54071efaea
commit 6ac37b4d6c
84 changed files with 188 additions and 374 deletions

View file

@ -139,6 +139,24 @@ export class ApLogService {
}
}
/**
* Deletes all logged inbox activities from a user or users
* @param userIds IDs of the users to delete
*/
public async deleteInboxLogs(userIds: string | string[]): Promise<number> {
if (Array.isArray(userIds)) {
const logsDeleted = await this.apInboxLogsRepository.delete({
authUserId: In(userIds),
});
return logsDeleted.affected ?? 0;
} else {
const logsDeleted = await this.apInboxLogsRepository.delete({
authUserId: userIds,
});
return logsDeleted.affected ?? 0;
}
}
/**
* Deletes all expired AP logs and garbage-collects the AP context cache.
* Returns the total number of deleted rows.

View file

@ -571,7 +571,7 @@ export class NoteCreateService implements OnApplicationShutdown {
if (this.meta.enableStatsForFederatedInstances) {
if (this.userEntityService.isRemoteUser(user)) {
this.federatedInstanceService.fetchOrRegister(user.host).then(async i => {
if (note.renote && note.text || !note.renote) {
if (!this.isRenote(note) || this.isQuote(note)) {
this.updateNotesCountQueue.enqueue(i.id, 1);
}
if (this.meta.enableChartsForFederatedInstances) {
@ -583,17 +583,12 @@ export class NoteCreateService implements OnApplicationShutdown {
// ハッシュタグ更新
if (data.visibility === 'public' || data.visibility === 'home') {
if (user.isBot && this.meta.enableBotTrending) {
this.hashtagService.updateHashtags(user, tags);
} else if (!user.isBot) {
if (!user.isBot || this.meta.enableBotTrending) {
this.hashtagService.updateHashtags(user, tags);
}
}
if (data.renote && data.text) {
// Increment notes count (user)
this.incNotesCountOfUser(user);
} else if (!data.renote) {
if (!this.isRenote(note) || this.isQuote(note)) {
// Increment notes count (user)
this.incNotesCountOfUser(user);
}
@ -631,7 +626,7 @@ export class NoteCreateService implements OnApplicationShutdown {
});
}
if (data.renote && data.text == null && data.renote.userId !== user.id && !user.isBot) {
if (this.isRenote(data) && !this.isQuote(data) && data.renote.userId !== user.id && !user.isBot) {
this.incRenoteCount(data.renote);
}
@ -706,13 +701,7 @@ export class NoteCreateService implements OnApplicationShutdown {
},
});
const [
userIdsWhoMeMuting,
] = data.renote.userId ? await Promise.all([
this.cacheService.userMutingsCache.fetch(data.renote.userId),
]) : [new Set<string>()];
const muted = isUserRelated(note, userIdsWhoMeMuting);
const muted = data.renote.userId && isUserRelated(note, await this.cacheService.userMutingsCache.fetch(data.renote.userId));
if (!isThreadMuted && !muted) {
nm.push(data.renote.userId, type);
@ -848,13 +837,7 @@ export class NoteCreateService implements OnApplicationShutdown {
},
});
const [
userIdsWhoMeMuting,
] = u.id ? await Promise.all([
this.cacheService.userMutingsCache.fetch(u.id),
]) : [new Set<string>()];
const muted = isUserRelated(note, userIdsWhoMeMuting);
const muted = u.id && isUserRelated(note, await this.cacheService.userMutingsCache.fetch(u.id));
if (isThreadMuted || muted) {
continue;

View file

@ -5,6 +5,8 @@
import type { Response } from 'node-fetch';
// TODO throw identifiable or unrecoverable errors
export function validateContentTypeSetAsActivityPub(response: Response): void {
const contentType = (response.headers.get('content-type') ?? '').toLowerCase();

View file

@ -322,6 +322,7 @@ export class ApPersonService implements OnModuleInit, OnApplicationShutdown {
const host = this.utilityService.punyHost(uri);
if (host === this.utilityService.toPuny(this.config.host)) {
// TODO convert to unrecoverable error
throw new StatusError(`cannot resolve local user: ${uri}`, 400, 'cannot resolve local user');
}
@ -570,7 +571,7 @@ export class ApPersonService implements OnModuleInit, OnApplicationShutdown {
.catch(err => {
if (!(err instanceof StatusError) || err.isRetryable) {
this.logger.error('error occurred while fetching following/followers collection', { stack: err });
// Do not update the visibiility on transient errors.
// Do not update the visibility on transient errors.
return undefined;
}
return 'private';

View file

@ -479,14 +479,6 @@ export class NoteEntityService implements OnModuleInit {
mentions: note.mentions && note.mentions.length > 0 ? note.mentions : undefined,
uri: note.uri ?? undefined,
url: note.url ?? undefined,
poll: note.hasPoll ? this.populatePoll(note, meId) : undefined,
...(meId && Object.keys(reactions).length > 0 ? {
myReaction: this.populateMyReaction({
id: note.id,
reactions: reactions,
reactionAndUserPairCache: reactionAndUserPairCache,
}, meId, options?._hint_),
} : {}),
...(opts.detail ? {
clippedCount: note.clippedCount,
@ -505,6 +497,16 @@ export class NoteEntityService implements OnModuleInit {
withReactionAndUserPairCache: opts.withReactionAndUserPairCache,
_hint_: options?._hint_,
}) : undefined,
poll: note.hasPoll ? this.populatePoll(note, meId) : undefined,
...(meId && Object.keys(reactions).length > 0 ? {
myReaction: this.populateMyReaction({
id: note.id,
reactions: reactions,
reactionAndUserPairCache: reactionAndUserPairCache,
}, meId, options?._hint_),
} : {}),
} : {}),
});