readChapterMarker

master
masterhc 1 year ago
parent 986d983dc1
commit 7c399bbc19

@ -1,6 +1,7 @@
const {Search, Chapter, Manga,SearchByTag, isValidID, Modules, Baker, Crypto, cookieParser} = require('../lib.js')
const mongoose = require('mongoose')
const FavoriteModel = require('../models/favorite.js');
const ChapterModel = require('../models/readChapter.js');
const fs = require('fs');
const path = require('path');
const { isNullOrUndefined } = require('util');
@ -394,7 +395,24 @@ exports.errorPage = (req, res)=>
exports.chapterRead = async (req, res)=>
{
console.log('ChapterRead')
const {scanlator, title, chapter, link} = req.params;
const scanlatorExists = await new Modules(scanlator).exists();
if(!scanlatorExists) return res.sendStatus(404);
const scanlatorHasTitle = await new Modules(scanlator).titleExists(title);
if(!scanlatorHasTitle) return res.sendStatus(404);
const manga = await new Manga(scanlator, link, title).get();
const {latestChap} = manga;
if(chapter > latestChap || chapter < 0) return res.sendStatus(404);
const chap = new ChapterModel();
let chapterNum = chapter;
const chaps = await ChapterModel.find({scanlator, title, link, chapterNum});
if(chaps.length>0) return res.sendStatus(404);
chap.scanlator = scanlator;
chap.title = title;
chap.link = link;
chap.chapterNum = chapter;
chap.completely = true;
chap.save()
res.sendStatus(200);
//Send to db;
}

@ -7,11 +7,13 @@ new Schema(
scanlator: {type: String, required: true, max: 100},
title: {type: String, required: true, max: 100},
link:{type: String, require:true, max:100},
chapterNum:{type: Number, require:true}
chapterNum:{type: Number, require:true},
lastImageRead:{type:Number, required:false},
completely:{type:Boolean, required:false}
}
);
const Chapter = module.exports = mongoose.model('chapter', chapter, 'mangareader');
const Chapter = module.exports = mongoose.model('chapter', chapter, 'mangareaderchapters');
module.exports.get = (callback, limit)=>
{
Chapter.find(callback).limit(limit);

Loading…
Cancel
Save