chore (backend): remove 'quiet' settings
This commit is contained in:
parent
eb5dccacfe
commit
f412d7ace3
7 changed files with 119 additions and 134 deletions
|
@ -76,9 +76,7 @@ cluster.on("exit", (worker) => {
|
|||
});
|
||||
|
||||
// Display detail of unhandled promise rejection
|
||||
if (!envOption.quiet) {
|
||||
process.on("unhandledRejection", console.dir);
|
||||
}
|
||||
process.on("unhandledRejection", console.dir);
|
||||
|
||||
// Display detail of uncaught exception
|
||||
process.on("uncaughtException", (err) => {
|
||||
|
|
|
@ -28,58 +28,56 @@ const bootLogger = logger.createSubLogger("boot", "magenta", false);
|
|||
const themeColor = chalk.hex("#31748f");
|
||||
|
||||
function greet() {
|
||||
if (!envOption.quiet) {
|
||||
//#region Firefish logo
|
||||
console.log(
|
||||
themeColor(
|
||||
"██████╗ ██╗██████╗ ███████╗███████╗██╗███████╗██╗ ██╗ ○ ▄ ▄ ",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
themeColor(
|
||||
"██╔════╝██║██╔══██╗██╔════╝██╔════╝██║██╔════╝██║ ██║ ⚬ █▄▄ █▄▄ ",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
themeColor(
|
||||
"█████╗ ██║██████╔╝█████╗ █████╗ ██║███████╗███████║ ▄▄▄▄▄▄ ▄ ",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
themeColor(
|
||||
"██╔══╝ ██║██╔══██╗██╔══╝ ██╔══╝ ██║╚════██║██╔══██║ █ █ █▄▄ ",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
themeColor(
|
||||
"██║ ██║██║ ██║███████╗██║ ██║███████║██║ ██║ █ ● ● █ ",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
themeColor(
|
||||
"╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ▀▄▄▄▄▄▄▀ ",
|
||||
),
|
||||
);
|
||||
//#endregion
|
||||
//#region Firefish logo
|
||||
console.log(
|
||||
themeColor(
|
||||
"██████╗ ██╗██████╗ ███████╗███████╗██╗███████╗██╗ ██╗ ○ ▄ ▄ ",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
themeColor(
|
||||
"██╔════╝██║██╔══██╗██╔════╝██╔════╝██║██╔════╝██║ ██║ ⚬ █▄▄ █▄▄ ",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
themeColor(
|
||||
"█████╗ ██║██████╔╝█████╗ █████╗ ██║███████╗███████║ ▄▄▄▄▄▄ ▄ ",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
themeColor(
|
||||
"██╔══╝ ██║██╔══██╗██╔══╝ ██╔══╝ ██║╚════██║██╔══██║ █ █ █▄▄ ",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
themeColor(
|
||||
"██║ ██║██║ ██║███████╗██║ ██║███████║██║ ██║ █ ● ● █ ",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
themeColor(
|
||||
"╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ▀▄▄▄▄▄▄▀ ",
|
||||
),
|
||||
);
|
||||
//#endregion
|
||||
|
||||
console.log(
|
||||
" Firefish is an open-source decentralized microblogging platform.",
|
||||
);
|
||||
console.log(
|
||||
chalk.rgb(
|
||||
255,
|
||||
136,
|
||||
0,
|
||||
)(
|
||||
" If you like Firefish, please consider contributing to the repo. https://firefish.dev/firefish/firefish",
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
" Firefish is an open-source decentralized microblogging platform.",
|
||||
);
|
||||
console.log(
|
||||
chalk.rgb(
|
||||
255,
|
||||
136,
|
||||
0,
|
||||
)(
|
||||
" If you like Firefish, please consider contributing to the repo. https://firefish.dev/firefish/firefish",
|
||||
),
|
||||
);
|
||||
|
||||
console.log("");
|
||||
console.log(
|
||||
chalkTemplate`--- ${os.hostname()} {gray (PID: ${process.pid.toString()})} ---`,
|
||||
);
|
||||
}
|
||||
console.log("");
|
||||
console.log(
|
||||
chalkTemplate`--- ${os.hostname()} {gray (PID: ${process.pid.toString()})} ---`,
|
||||
);
|
||||
|
||||
bootLogger.info("Welcome to Firefish!");
|
||||
bootLogger.info(`Firefish v${meta.version}`, null, true);
|
||||
|
|
|
@ -5,7 +5,6 @@ const envOption = {
|
|||
disableClustering: false,
|
||||
verbose: false,
|
||||
withLogTime: false,
|
||||
quiet: false,
|
||||
slow: false,
|
||||
};
|
||||
|
||||
|
@ -19,7 +18,6 @@ for (const key of Object.keys(envOption) as (keyof typeof envOption)[]) {
|
|||
}
|
||||
|
||||
if (process.env.NODE_ENV === "test") envOption.disableClustering = true;
|
||||
if (process.env.NODE_ENV === "test") envOption.quiet = true;
|
||||
if (process.env.NODE_ENV === "test") envOption.noDaemons = true;
|
||||
|
||||
export { envOption };
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import type { CacheableRemoteUser } from "@/models/entities/user.js";
|
||||
import deleteNode from "@/services/note/delete.js";
|
||||
import deleteNote from "@/services/note/delete.js";
|
||||
import { apLogger } from "../../logger.js";
|
||||
import DbResolver from "../../db-resolver.js";
|
||||
import { getApLock } from "@/misc/app-lock.js";
|
||||
|
@ -36,7 +36,7 @@ export default async function (
|
|||
return "The user trying to delete the post is not the post author";
|
||||
}
|
||||
|
||||
await deleteNode(actor, note);
|
||||
await deleteNote(actor, note);
|
||||
return "ok: note deleted";
|
||||
} finally {
|
||||
await lock.release();
|
||||
|
|
|
@ -53,7 +53,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
throw new ApiError(meta.errors.accessDenied);
|
||||
}
|
||||
|
||||
await deleteNote(user, note, false, false);
|
||||
await deleteNote(user, note, false);
|
||||
await Notes.update(note.id, {
|
||||
visibility: "specified",
|
||||
visibleUserIds: [],
|
||||
|
|
|
@ -56,7 +56,6 @@ export default class Logger {
|
|||
subDomains: Domain[] = [],
|
||||
store = true,
|
||||
): void {
|
||||
if (envOption.quiet) return;
|
||||
if (
|
||||
!(typeof config.logLevel === "undefined") &&
|
||||
!config.logLevel.includes(level)
|
||||
|
|
|
@ -38,7 +38,6 @@ async function recalculateNotesCountOfLocalUser(user: {
|
|||
export default async function (
|
||||
user: { id: User["id"]; uri: User["uri"]; host: User["host"] },
|
||||
note: Note,
|
||||
quiet = false,
|
||||
deleteFromDb = true,
|
||||
) {
|
||||
const deletedAt = new Date();
|
||||
|
@ -67,87 +66,80 @@ export default async function (
|
|||
}
|
||||
const instanceNotesCountDecreasement: Record<string, number> = {};
|
||||
|
||||
if (!quiet) {
|
||||
// Only broadcast "deleted" to local if the note is deleted from db
|
||||
// Only broadcast "deleted" to local if the note is deleted from db
|
||||
if (deleteFromDb) {
|
||||
publishNoteStream(note.id, "deleted", {
|
||||
deletedAt: deletedAt,
|
||||
});
|
||||
}
|
||||
|
||||
//#region ローカルの投稿なら削除アクティビティを配送
|
||||
if (Users.isLocalUser(user) && !note.localOnly) {
|
||||
let renote: Note | null = null;
|
||||
|
||||
// if deletd note is renote
|
||||
if (
|
||||
note.renoteId &&
|
||||
note.text == null &&
|
||||
!note.hasPoll &&
|
||||
(note.fileIds == null || note.fileIds.length === 0)
|
||||
) {
|
||||
renote = await Notes.findOneBy({
|
||||
id: note.renoteId,
|
||||
});
|
||||
}
|
||||
|
||||
const content = renderActivity(
|
||||
renote
|
||||
? renderUndo(
|
||||
renderAnnounce(
|
||||
renote.uri || `${config.url}/notes/${renote.id}`,
|
||||
note,
|
||||
),
|
||||
user,
|
||||
)
|
||||
: renderDelete(renderTombstone(`${config.url}/notes/${note.id}`), user),
|
||||
);
|
||||
|
||||
deliverToConcerned(user, note, content);
|
||||
}
|
||||
|
||||
// also deliever delete activity to cascaded notes
|
||||
for (const cascadingNote of cascadingNotes) {
|
||||
if (deleteFromDb) {
|
||||
publishNoteStream(note.id, "deleted", {
|
||||
// For other notes, publishNoteStream is also required.
|
||||
publishNoteStream(cascadingNote.id, "deleted", {
|
||||
deletedAt: deletedAt,
|
||||
});
|
||||
}
|
||||
|
||||
//#region ローカルの投稿なら削除アクティビティを配送
|
||||
if (Users.isLocalUser(user) && !note.localOnly) {
|
||||
let renote: Note | null = null;
|
||||
|
||||
// if deletd note is renote
|
||||
if (
|
||||
note.renoteId &&
|
||||
note.text == null &&
|
||||
!note.hasPoll &&
|
||||
(note.fileIds == null || note.fileIds.length === 0)
|
||||
) {
|
||||
renote = await Notes.findOneBy({
|
||||
id: note.renoteId,
|
||||
});
|
||||
}
|
||||
|
||||
const content = renderActivity(
|
||||
renote
|
||||
? renderUndo(
|
||||
renderAnnounce(
|
||||
renote.uri || `${config.url}/notes/${renote.id}`,
|
||||
note,
|
||||
),
|
||||
user,
|
||||
)
|
||||
: renderDelete(
|
||||
renderTombstone(`${config.url}/notes/${note.id}`),
|
||||
user,
|
||||
),
|
||||
);
|
||||
|
||||
deliverToConcerned(user, note, content);
|
||||
if (!cascadingNote.user) continue;
|
||||
if (!Users.isLocalUser(cascadingNote.user)) {
|
||||
if (!Users.isRemoteUser(cascadingNote.user)) continue;
|
||||
instanceNotesCountDecreasement[cascadingNote.user.host] ??= 0;
|
||||
instanceNotesCountDecreasement[cascadingNote.user.host]++;
|
||||
continue; // filter out remote users
|
||||
}
|
||||
affectedLocalUsers[cascadingNote.user.id] ??= cascadingNote.user;
|
||||
if (cascadingNote.localOnly) continue; // filter out local-only notes
|
||||
const content = renderActivity(
|
||||
renderDelete(
|
||||
renderTombstone(`${config.url}/notes/${cascadingNote.id}`),
|
||||
cascadingNote.user,
|
||||
),
|
||||
);
|
||||
deliverToConcerned(cascadingNote.user, cascadingNote, content);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
// also deliever delete activity to cascaded notes
|
||||
for (const cascadingNote of cascadingNotes) {
|
||||
if (deleteFromDb) {
|
||||
// For other notes, publishNoteStream is also required.
|
||||
publishNoteStream(cascadingNote.id, "deleted", {
|
||||
deletedAt: deletedAt,
|
||||
});
|
||||
}
|
||||
|
||||
if (!cascadingNote.user) continue;
|
||||
if (!Users.isLocalUser(cascadingNote.user)) {
|
||||
if (!Users.isRemoteUser(cascadingNote.user)) continue;
|
||||
instanceNotesCountDecreasement[cascadingNote.user.host] ??= 0;
|
||||
instanceNotesCountDecreasement[cascadingNote.user.host]++;
|
||||
continue; // filter out remote users
|
||||
}
|
||||
affectedLocalUsers[cascadingNote.user.id] ??= cascadingNote.user;
|
||||
if (cascadingNote.localOnly) continue; // filter out local-only notes
|
||||
const content = renderActivity(
|
||||
renderDelete(
|
||||
renderTombstone(`${config.url}/notes/${cascadingNote.id}`),
|
||||
cascadingNote.user,
|
||||
),
|
||||
);
|
||||
deliverToConcerned(cascadingNote.user, cascadingNote, content);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
if (Users.isRemoteUser(user)) {
|
||||
instanceNotesCountDecreasement[user.host] ??= 0;
|
||||
instanceNotesCountDecreasement[user.host]++;
|
||||
}
|
||||
for (const [host, count] of Object.entries(
|
||||
instanceNotesCountDecreasement,
|
||||
)) {
|
||||
registerOrFetchInstanceDoc(host).then((i) => {
|
||||
Instances.decrement({ id: i.id }, "notesCount", count);
|
||||
});
|
||||
}
|
||||
if (Users.isRemoteUser(user)) {
|
||||
instanceNotesCountDecreasement[user.host] ??= 0;
|
||||
instanceNotesCountDecreasement[user.host]++;
|
||||
}
|
||||
for (const [host, count] of Object.entries(instanceNotesCountDecreasement)) {
|
||||
registerOrFetchInstanceDoc(host).then((i) => {
|
||||
Instances.decrement({ id: i.id }, "notesCount", count);
|
||||
});
|
||||
}
|
||||
|
||||
if (deleteFromDb) {
|
||||
|
|
Loading…
Reference in a new issue