mirror of
https://example.com
synced 2024-11-22 12:06:39 +09:00
refactor (backend): change !== null
to != null
This commit is contained in:
parent
18aeeaabd2
commit
9c6ac248ff
14 changed files with 22 additions and 22 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,7 +196,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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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]));
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -647,13 +647,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);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,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;
|
||||
|
|
|
@ -46,14 +46,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("/");
|
||||
}
|
||||
|
||||
|
@ -572,7 +572,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;
|
||||
|
@ -582,12 +582,12 @@ export async function addFile({
|
|||
file.isSensitive = user
|
||||
? Users.isLocalUser(user) && profile?.alwaysMarkNsfw
|
||||
? true
|
||||
: sensitive !== null && sensitive !== undefined
|
||||
: sensitive != null
|
||||
? sensitive
|
||||
: false
|
||||
: false;
|
||||
|
||||
if (url !== null) {
|
||||
if (url != null) {
|
||||
file.src = url;
|
||||
|
||||
if (isLink) {
|
||||
|
@ -599,7 +599,7 @@ export async function addFile({
|
|||
}
|
||||
}
|
||||
|
||||
if (uri !== null) {
|
||||
if (uri != null) {
|
||||
file.uri = uri;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -486,7 +486,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) {
|
||||
|
@ -613,13 +613,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);
|
||||
}
|
||||
|
|
|
@ -148,7 +148,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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue