more work on the note endpoint, for now im going to work around it

This commit is contained in:
Ben
2018-09-24 14:05:47 +01:00
parent d72127bf2b
commit bff3461278
3 changed files with 12 additions and 11 deletions

View File

@@ -11,7 +11,7 @@ export class NoteController extends ControllerHandler {
let content = req.body.text || null; let content = req.body.text || null;
let creatorid = req.user.id || undefined; let creatorid = req.user.id || undefined;
let group = req.body.parentgroup || undefined; let group = req.body.parentgroup || null;
let order = req.body.order || undefined; let order = req.body.order || undefined;
let user = req.user || undefined; let user = req.user || undefined;
@@ -23,13 +23,16 @@ export class NoteController extends ControllerHandler {
return; return;
} }
if (!order) {
errors.addError(422, 'Unprocessable entity');
errors.endpoint();
next();
return;
}
if (!group) group == 0; let id = await Notes.genID();
Notes.newNote(id, content, creatorid, order);
// what the hecking heck is this code supoased to do you hecking idiot
next(); next();
} }

View File

@@ -24,7 +24,7 @@ export class Router {
app.get('/note/:endpoint', [MiddleWare.RateLimits.request, Controllers.PermaLinkController.getNote]); app.get('/note/:endpoint', [MiddleWare.RateLimits.request, Controllers.PermaLinkController.getNote]);
app.post('/auth/note', [MiddleWare.RateLimits.request, MiddleWare.Auth.authUser, Controllers.NoteController.newNote]); // Passes through auth middleware which if authenticated passes user obj and token to the note handling function for it to deal with app.post('/auth/note', [MiddleWare.RateLimits.request, MiddleWare.Auth.authUser, Controllers.NoteController.newNote]); // Passes through auth middleware which if authenticated passes user obj and token to the note handling function for it to deal with
app.post('/aith/group', [MiddleWare.RateLimits.request, MiddleWare.Auth.authUser]); app.post('/auth/group', [MiddleWare.RateLimits.request, MiddleWare.Auth.authUser]);
app.get('/auth/getallnotes', [MiddleWare.RateLimits.request, MiddleWare.Auth.authUser]); app.get('/auth/getallnotes', [MiddleWare.RateLimits.request, MiddleWare.Auth.authUser]);
app.get('/auth/getallgroups', [MiddleWare.RateLimits.request, MiddleWare.Auth.authUser]); app.get('/auth/getallgroups', [MiddleWare.RateLimits.request, MiddleWare.Auth.authUser]);

View File

@@ -2,10 +2,8 @@ import {Groups} from './groups';
import {Database} from '../database/database'; import {Database} from '../database/database';
export class Notes extends Groups { export class Notes extends Groups {
static async newNote(id, content, creatorid, order) { static async newNote(id, content, creatorid, order) {
Database.note.newNote(id, content, creatorid, order, null);
Database.notes.newNote(id, null, )
} }
static async genID() { static async genID() {