Remove unnecessary nullish coalescing (#12058)
This commit is contained in:
parent
53099cad5a
commit
0bddd0ceae
@ -331,7 +331,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||||||
|
|
||||||
const queryOrNull = async () => (await this.emojisRepository.findOneBy({
|
const queryOrNull = async () => (await this.emojisRepository.findOneBy({
|
||||||
name,
|
name,
|
||||||
host: host ?? IsNull(),
|
host,
|
||||||
})) ?? null;
|
})) ?? null;
|
||||||
|
|
||||||
const emoji = await this.cache.fetch(`${name} ${host}`, queryOrNull);
|
const emoji = await this.cache.fetch(`${name} ${host}`, queryOrNull);
|
||||||
|
@ -45,7 +45,7 @@ export class HashtagService {
|
|||||||
await this.updateHashtag(user, tag, true, true);
|
await this.updateHashtag(user, tag, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const tag of (user.tags ?? []).filter(x => !tags.includes(x))) {
|
for (const tag of user.tags.filter(x => !tags.includes(x))) {
|
||||||
await this.updateHashtag(user, tag, true, false);
|
await this.updateHashtag(user, tag, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||||||
data.text = data.text.trim();
|
data.text = data.text.trim();
|
||||||
|
|
||||||
if (user.isCat) {
|
if (user.isCat) {
|
||||||
patsedText = patsedText ?? mfm.parse(data.text);
|
patsedText = mfm.parse(data.text);
|
||||||
function nyaizeNode(node: mfm.MfmNode) {
|
function nyaizeNode(node: mfm.MfmNode) {
|
||||||
if (node.type === 'quote') return;
|
if (node.type === 'quote') return;
|
||||||
if (node.type === 'text') {
|
if (node.type === 'text') {
|
||||||
@ -359,7 +359,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||||||
mentionedUsers = data.apMentions ?? await this.extractMentionedUsers(user, combinedTokens);
|
mentionedUsers = data.apMentions ?? await this.extractMentionedUsers(user, combinedTokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
tags = tags.filter(tag => Array.from(tag ?? '').length <= 128).splice(0, 32);
|
tags = tags.filter(tag => Array.from(tag).length <= 128).splice(0, 32);
|
||||||
|
|
||||||
if (data.reply && (user.id !== data.reply.userId) && !mentionedUsers.some(u => u.id === data.reply!.userId)) {
|
if (data.reply && (user.id !== data.reply.userId) && !mentionedUsers.some(u => u.id === data.reply!.userId)) {
|
||||||
mentionedUsers.push(await this.usersRepository.findOneByOrFail({ id: data.reply!.userId }));
|
mentionedUsers.push(await this.usersRepository.findOneByOrFail({ id: data.reply!.userId }));
|
||||||
|
@ -148,7 +148,7 @@ export class ReactionService {
|
|||||||
reaction = FALLBACK;
|
reaction = FALLBACK;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reaction = this.normalize(reaction ?? null);
|
reaction = this.normalize(reaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ export class DriveFileEntityService {
|
|||||||
if (file.type.startsWith('video')) {
|
if (file.type.startsWith('video')) {
|
||||||
if (file.thumbnailUrl) return file.thumbnailUrl;
|
if (file.thumbnailUrl) return file.thumbnailUrl;
|
||||||
|
|
||||||
return this.videoProcessingService.getExternalVideoThumbnailUrl(file.webpublicUrl ?? file.url ?? file.uri);
|
return this.videoProcessingService.getExternalVideoThumbnailUrl(file.webpublicUrl ?? file.url);
|
||||||
} else if (file.uri != null && file.userHost != null && this.config.externalMediaProxyEnabled) {
|
} else if (file.uri != null && file.userHost != null && this.config.externalMediaProxyEnabled) {
|
||||||
// 動画ではなくリモートかつメディアプロキシ
|
// 動画ではなくリモートかつメディアプロキシ
|
||||||
return this.getProxiedUrl(file.uri, 'static');
|
return this.getProxiedUrl(file.uri, 'static');
|
||||||
@ -145,7 +145,7 @@ export class DriveFileEntityService {
|
|||||||
.select('SUM(file.size)', 'sum')
|
.select('SUM(file.size)', 'sum')
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
|
|
||||||
return parseInt(sum, 10) ?? 0;
|
return parseInt(sum, 10) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
@ -157,7 +157,7 @@ export class DriveFileEntityService {
|
|||||||
.select('SUM(file.size)', 'sum')
|
.select('SUM(file.size)', 'sum')
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
|
|
||||||
return parseInt(sum, 10) ?? 0;
|
return parseInt(sum, 10) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
@ -169,7 +169,7 @@ export class DriveFileEntityService {
|
|||||||
.select('SUM(file.size)', 'sum')
|
.select('SUM(file.size)', 'sum')
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
|
|
||||||
return parseInt(sum, 10) ?? 0;
|
return parseInt(sum, 10) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
@ -181,7 +181,7 @@ export class DriveFileEntityService {
|
|||||||
.select('SUM(file.size)', 'sum')
|
.select('SUM(file.size)', 'sum')
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
|
|
||||||
return parseInt(sum, 10) ?? 0;
|
return parseInt(sum, 10) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -318,7 +318,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||||||
text: text,
|
text: text,
|
||||||
cw: note.cw,
|
cw: note.cw,
|
||||||
visibility: note.visibility,
|
visibility: note.visibility,
|
||||||
localOnly: note.localOnly ?? undefined,
|
localOnly: note.localOnly,
|
||||||
reactionAcceptance: note.reactionAcceptance,
|
reactionAcceptance: note.reactionAcceptance,
|
||||||
visibleUserIds: note.visibility === 'specified' ? note.visibleUserIds : undefined,
|
visibleUserIds: note.visibility === 'specified' ? note.visibleUserIds : undefined,
|
||||||
renoteCount: note.renoteCount,
|
renoteCount: note.renoteCount,
|
||||||
|
@ -333,8 +333,8 @@ export class UserEntityService implements OnModuleInit {
|
|||||||
host: user.host,
|
host: user.host,
|
||||||
avatarUrl: user.avatarUrl ?? this.getIdenticonUrl(user),
|
avatarUrl: user.avatarUrl ?? this.getIdenticonUrl(user),
|
||||||
avatarBlurhash: user.avatarBlurhash,
|
avatarBlurhash: user.avatarBlurhash,
|
||||||
isBot: user.isBot ?? falsy,
|
isBot: user.isBot,
|
||||||
isCat: user.isCat ?? falsy,
|
isCat: user.isCat,
|
||||||
instance: user.host ? this.federatedInstanceService.federatedInstanceCache.fetch(user.host).then(instance => instance ? {
|
instance: user.host ? this.federatedInstanceService.federatedInstanceCache.fetch(user.host).then(instance => instance ? {
|
||||||
name: instance.name,
|
name: instance.name,
|
||||||
softwareName: instance.softwareName,
|
softwareName: instance.softwareName,
|
||||||
@ -367,7 +367,7 @@ export class UserEntityService implements OnModuleInit {
|
|||||||
bannerBlurhash: user.bannerBlurhash,
|
bannerBlurhash: user.bannerBlurhash,
|
||||||
isLocked: user.isLocked,
|
isLocked: user.isLocked,
|
||||||
isSilenced: this.roleService.getUserPolicies(user.id).then(r => !r.canPublicNote),
|
isSilenced: this.roleService.getUserPolicies(user.id).then(r => !r.canPublicNote),
|
||||||
isSuspended: user.isSuspended ?? falsy,
|
isSuspended: user.isSuspended,
|
||||||
description: profile!.description,
|
description: profile!.description,
|
||||||
location: profile!.location,
|
location: profile!.location,
|
||||||
birthday: profile!.birthday,
|
birthday: profile!.birthday,
|
||||||
|
@ -108,6 +108,5 @@ async function net() {
|
|||||||
|
|
||||||
// FS STAT
|
// FS STAT
|
||||||
async function fs() {
|
async function fs() {
|
||||||
const data = await si.disksIO().catch(() => ({ rIO_sec: 0, wIO_sec: 0 }));
|
return await si.disksIO().catch(() => ({ rIO_sec: 0, wIO_sec: 0 }));
|
||||||
return data ?? { rIO_sec: 0, wIO_sec: 0 };
|
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ export class InboxProcessorService {
|
|||||||
if (err.isClientError) {
|
if (err.isClientError) {
|
||||||
throw new Bull.UnrecoverableError(`skip: Ignored deleted actors on both ends ${activity.actor} - ${err.statusCode}`);
|
throw new Bull.UnrecoverableError(`skip: Ignored deleted actors on both ends ${activity.actor} - ${err.statusCode}`);
|
||||||
}
|
}
|
||||||
throw new Error(`Error in actor ${activity.actor} - ${err.statusCode ?? err}`);
|
throw new Error(`Error in actor ${activity.actor} - ${err.statusCode}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class HomeTimelineChannel extends Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ignore notes from instances the user has muted
|
// Ignore notes from instances the user has muted
|
||||||
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances ?? []))) return;
|
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances))) return;
|
||||||
|
|
||||||
if (note.visibility === 'followers') {
|
if (note.visibility === 'followers') {
|
||||||
if (!Object.hasOwn(this.following, note.userId)) return;
|
if (!Object.hasOwn(this.following, note.userId)) return;
|
||||||
|
@ -69,7 +69,7 @@ class HybridTimelineChannel extends Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ignore notes from instances the user has muted
|
// Ignore notes from instances the user has muted
|
||||||
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances ?? []))) return;
|
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances))) return;
|
||||||
|
|
||||||
// 関係ない返信は除外
|
// 関係ない返信は除外
|
||||||
if (note.reply && !this.following[note.userId]?.withReplies && !this.withReplies) {
|
if (note.reply && !this.following[note.userId]?.withReplies && !this.withReplies) {
|
||||||
|
@ -83,7 +83,7 @@ export class FeedService {
|
|||||||
date: this.idService.parse(note.id).date,
|
date: this.idService.parse(note.id).date,
|
||||||
description: note.cw ?? undefined,
|
description: note.cw ?? undefined,
|
||||||
content: note.text ?? undefined,
|
content: note.text ?? undefined,
|
||||||
image: file ? this.driveFileEntityService.getPublicUrl(file) ?? undefined : undefined,
|
image: file ? this.driveFileEntityService.getPublicUrl(file) : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user