From 5a6ec56a7e9a493a7571c30b7e761ac21d3dfa00 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 24 May 2020 21:09:03 +0200 Subject: [PATCH] Cleanups lib/web/note Signed-off-by: David Mehren --- src/lib/web/note/controller.ts | 9 +-------- src/lib/web/note/slide.ts | 15 ++++----------- src/lib/web/note/util.ts | 3 +-- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/lib/web/note/controller.ts b/src/lib/web/note/controller.ts index 55de8943a..ec024123d 100644 --- a/src/lib/web/note/controller.ts +++ b/src/lib/web/note/controller.ts @@ -2,7 +2,7 @@ import { Request, Response } from 'express' import { config } from '../../config' import { errors } from '../../errors' import { logger } from '../../logger' -import { Note, User } from '../../models' +import { Note } from '../../models' import * as ActionController from './actions' import * as NoteUtils from './util' @@ -24,13 +24,6 @@ export function publishNoteActions (req: Request, res: Response): void { } export function showPublishNote (req: Request, res: Response): void { - const include = [{ - model: User, - as: 'owner' - }, { - model: User, - as: 'lastchangeuser' - }] NoteUtils.findNoteOrCreate(req, res, function (note) { // force to use short id const shortid = req.params.shortid diff --git a/src/lib/web/note/slide.ts b/src/lib/web/note/slide.ts index 850c00f08..2172f59a3 100644 --- a/src/lib/web/note/slide.ts +++ b/src/lib/web/note/slide.ts @@ -1,11 +1,11 @@ -import { NextFunction, Response } from 'express' +import { Request, Response } from 'express' import { config } from '../../config' import { errors } from '../../errors' import { logger } from '../../logger' -import { Note, User } from '../../models' +import { Note } from '../../models' import * as NoteUtils from './util' -export function publishSlideActions (req: any, res: Response) { +export function publishSlideActions (req: Request, res: Response): void { NoteUtils.findNoteOrCreate(req, res, function (note) { const action = req.params.action if (action === 'edit') { @@ -16,14 +16,7 @@ export function publishSlideActions (req: any, res: Response) { }) } -export function showPublishSlide (req: any, res: Response) { - const include = [{ - model: User, - as: 'owner' - }, { - model: User, - as: 'lastchangeuser' - }] +export function showPublishSlide (req: Request, res: Response): void { NoteUtils.findNoteOrCreate(req, res, function (note) { // force to use short id const shortid = req.params.shortid diff --git a/src/lib/web/note/util.ts b/src/lib/web/note/util.ts index 7c367fd74..b06a3c242 100644 --- a/src/lib/web/note/util.ts +++ b/src/lib/web/note/util.ts @@ -2,7 +2,6 @@ import { Request, Response } from 'express' import fs from 'fs' import path from 'path' -import { Includeable } from 'sequelize' import { config } from '../../config' import { errors } from '../../errors' import { logger } from '../../logger' @@ -33,7 +32,7 @@ export function newNote (req, res: Response, body: string | null): void { }) } -export function checkViewPermission (req, note: any): boolean { +export function checkViewPermission (req, note: Note): boolean { if (note.permission === 'private') { return req.isAuthenticated() && note.ownerId === req.user.id } else if (note.permission === 'limited' || note.permission === 'protected') {