server-ts: Convert routes/api/bulk_action

This commit is contained in:
Elian Doran
2024-04-05 20:36:10 +03:00
parent fd77c5e8c4
commit 40ef533c5f
4 changed files with 13 additions and 12 deletions

View File

@@ -2,7 +2,7 @@
import fs = require('fs');
import dateUtils = require('../../services/date_utils');
import dataDir = require('../../services/data_dir.js');
import dataDir = require('../../services/data_dir');
const { LOG_DIR } = dataDir;
function getBackendLog() {

View File

@@ -1,17 +1,18 @@
const becca = require('../../becca/becca');
const bulkActionService = require('../../services/bulk_actions');
import { Request } from 'express';
import becca = require('../../becca/becca');
import bulkActionService = require('../../services/bulk_actions');
function execute(req) {
function execute(req: Request) {
const {noteIds, includeDescendants} = req.body;
const affectedNoteIds = getAffectedNoteIds(noteIds, includeDescendants);
const bulkActionNote = becca.getNote('_bulkAction');
const bulkActionNote = becca.getNoteOrThrow('_bulkAction');
bulkActionService.executeActions(bulkActionNote, affectedNoteIds);
}
function getAffectedNoteCount(req) {
function getAffectedNoteCount(req: Request) {
const {noteIds, includeDescendants} = req.body;
const affectedNoteIds = getAffectedNoteIds(noteIds, includeDescendants);
@@ -21,8 +22,8 @@ function getAffectedNoteCount(req) {
};
}
function getAffectedNoteIds(noteIds, includeDescendants) {
const affectedNoteIds = new Set();
function getAffectedNoteIds(noteIds: string[], includeDescendants: boolean) {
const affectedNoteIds = new Set<string>();
for (const noteId of noteIds) {
const note = becca.getNote(noteId);
@@ -42,7 +43,7 @@ function getAffectedNoteIds(noteIds, includeDescendants) {
return affectedNoteIds;
}
module.exports = {
export = {
execute,
getAffectedNoteCount
};