refactor (backend): change !== null to != null

This actually fixes some errors 🥴

Co-authored-by: naskya <m@naskya.net>
This commit is contained in:
sup39 2024-02-09 04:12:47 +09:00 committed by naskya
parent d518bdea29
commit 78c9911788
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
14 changed files with 23 additions and 23 deletions

View file

@ -46,7 +46,7 @@ export class Cache<T> {
for (const [i, key] of keys.entries()) {
const val = values[i];
if (val !== null) {
if (val != null) {
map.set(key, decode(val) as T);
}
}

View file

@ -127,7 +127,7 @@ router.get("/notes/:note", async (ctx, next) => {
}
// redirect if remote
if (note.userHost !== null) {
if (note.userHost != null) {
if (note.uri == null || isSelfHost(note.userHost)) {
ctx.status = 500;
return;

View file

@ -82,7 +82,7 @@ export default define(
async (ps, user, _, file, cleanup, ip, headers) => {
// Get 'name' parameter
let name = ps.name || file.originalname;
if (name !== undefined && name !== null) {
if (name != null) {
name = name.trim();
if (name.length === 0) {
name = null;

View file

@ -56,7 +56,7 @@ export default define(meta, paramDef, async (ps, user) => {
id: genId(),
createdAt: new Date(),
name: ps.name,
parentId: parent !== null ? parent.id : null,
parentId: parent != null ? parent.id : null,
userId: user.id,
}).then((x) => DriveFolders.findOneByOrFail(x.identifiers[0]));

View file

@ -93,7 +93,7 @@ export default define(meta, paramDef, async (ps, user) => {
}
}
if (parent.parentId !== null) {
if (parent.parentId != null) {
if (await checkCircle(parent.parentId)) {
throw new ApiError(meta.errors.recursiveNesting);
}

View file

@ -648,13 +648,13 @@ export default define(meta, paramDef, async (ps, user) => {
}
// Post is a reply and remote user is the contributor of the original post
if (note.reply && note.reply.userHost !== null) {
if (note.reply?.userHost != null) {
const u = await Users.findOneBy({ id: note.reply.userId });
if (u && Users.isRemoteUser(u)) dm.addDirectRecipe(u);
}
// Post is a renote and remote user is the contributor of the original post
if (note.renote && note.renote.userHost !== null) {
if (note.renote?.userHost != null) {
const u = await Users.findOneBy({ id: note.renote.userId });
if (u && Users.isRemoteUser(u)) dm.addDirectRecipe(u);
}

View file

@ -29,7 +29,7 @@ export default class extends Channel {
}
private async onNote(note: Packed<"Note">) {
if (note.user.host !== null) return;
if (note.user.host != null) return;
if (note.visibility !== "public") return;
if (note.channelId != null && !this.followingChannels.has(note.channelId))
return;

View file

@ -51,14 +51,14 @@ function urlPathJoin(
url.pathname.endsWith("/") ? url.pathname.slice(0, -1) : url.pathname,
);
url.pathname = pathParts
.filter((x) => x !== null && x.toString().length > 0)
.filter((x) => x != null && x.toString().length > 0)
.join("/");
}
return url.toString();
}
const baseParts = baseOrParts.concat(pathParts ?? []);
return baseParts
.filter((x) => x !== null && x.toString().length > 0)
.filter((x) => x != null && x.toString().length > 0)
.join("/");
}
@ -614,7 +614,7 @@ export async function addFile({
file.createdAt = new Date();
file.userId = user ? user.id : null;
file.userHost = user ? user.host : null;
file.folderId = folder !== null ? folder.id : null;
file.folderId = folder != null ? folder.id : null;
file.comment = comment;
file.properties = properties;
file.blurhash = info.blurhash || null;
@ -626,7 +626,7 @@ export async function addFile({
file.isSensitive = user
? Users.isLocalUser(user) && profile!.alwaysMarkNsfw
? true
: sensitive !== null && sensitive !== undefined
: sensitive != null
? sensitive
: false
: false;
@ -635,7 +635,7 @@ export async function addFile({
if (info.sensitive && instance.setSensitiveFlagAutomatically)
file.isSensitive = true;
if (url !== null) {
if (url != null) {
file.src = url;
if (isLink) {
@ -647,7 +647,7 @@ export async function addFile({
}
}
if (uri !== null) {
if (uri != null) {
file.uri = uri;
}

View file

@ -69,7 +69,7 @@ export async function deleteFileSync(file: DriveFile, isExpired = false) {
async function postProcess(file: DriveFile, isExpired = false) {
// リモートファイル期限切れ削除後は直リンクにする
if (isExpired && file.userHost !== null && file.uri != null) {
if (isExpired && file.userHost != null && file.uri != null) {
DriveFiles.update(file.id, {
isLink: true,
url: file.uri,
@ -88,7 +88,7 @@ async function postProcess(file: DriveFile, isExpired = false) {
// 統計を更新
driveChart.update(file, false);
perUserDriveChart.update(file, false);
if (file.userHost !== null) {
if (file.userHost != null) {
instanceChart.updateDrive(file, false);
}
}

View file

@ -50,7 +50,7 @@ export async function uploadFromUrl({
// If the comment is same as the name, skip comment
// (image.name is passed in when receiving attachment)
if (comment !== null && name === comment) {
if (comment != null && name === comment) {
comment = null;
}

View file

@ -115,7 +115,7 @@ export default class Logger {
console.log(important ? chalk.bold(log) : log);
if (level === "error" && data !== null) {
if (level === "error" && data != null) {
console.log(data);
}

View file

@ -490,7 +490,7 @@ export default async (
const lock = new Mutex(redisClient, "publishedNote");
await lock.acquire();
try {
const published = (await redisClient.get(publishKey)) !== null;
const published = (await redisClient.get(publishKey)) != null;
if (!published) {
await redisClient.set(publishKey, "done", "EX", 30);
if (noteToPublish.renoteId) {
@ -617,13 +617,13 @@ export default async (
}
// 投稿がリプライかつ投稿者がローカルユーザーかつリプライ先の投稿の投稿者がリモートユーザーなら配送
if (data.reply && data.reply.userHost !== null) {
if (data.reply?.userHost != null) {
const u = await Users.findOneBy({ id: data.reply.userId });
if (u && Users.isRemoteUser(u)) dm.addDirectRecipe(u);
}
// 投稿がRenoteかつ投稿者がローカルユーザーかつRenote元の投稿の投稿者がリモートユーザーなら配送
if (data.renote && data.renote.userHost !== null) {
if (data.renote?.userHost != null) {
const u = await Users.findOneBy({ id: data.renote.userId });
if (u && Users.isRemoteUser(u)) dm.addDirectRecipe(u);
}

View file

@ -151,7 +151,7 @@ export default async (
) {
const content = renderActivity(await renderLike(record, note));
const dm = new DeliverManager(user, content);
if (note.userHost !== null) {
if (note.userHost != null) {
const reactee = await Users.findOneBy({ id: note.userId });
dm.addDirectRecipe(reactee as IRemoteUser);
}

View file

@ -59,7 +59,7 @@ export default async (
renderUndo(await renderLike(reaction, note), user),
);
const dm = new DeliverManager(user, content);
if (note.userHost !== null) {
if (note.userHost != null) {
const reactee = await Users.findOneBy({ id: note.userId });
dm.addDirectRecipe(reactee as IRemoteUser);
}