hecking abstractions boi
This commit is contained in:
@@ -2,31 +2,32 @@ import {Logger} from '../models/logger';
|
||||
import {ControllerHandler} from './controllerHandler';
|
||||
import {API} from '../models/api/api';
|
||||
import {Database} from '../models/database/database'
|
||||
import {PermaLink} from '../models/permalinks/permalink';
|
||||
import {Notes} from '../models/notes/notes';
|
||||
|
||||
export class NoteController extends ControllerHandler {
|
||||
static async newNote(req, res, next) {
|
||||
let errors = new API.errors(res);
|
||||
// Logger.debug(JSON.stringify(req.user, false, 4));
|
||||
|
||||
let content = req.body.text || undefined;
|
||||
let content = req.body.text || null;
|
||||
let creatorid = req.user.id || undefined;
|
||||
let group = req.body.parentgroup || undefined;
|
||||
let order = req.body.order || undefined;
|
||||
|
||||
let user = req.user || undefined;
|
||||
|
||||
if (!creatorid || !user) errors.addError(403, 'Forbidden');
|
||||
|
||||
if (errors.count() > 0) {
|
||||
if (!creatorid || !user) {
|
||||
errors.addError(403, 'Forbidden');
|
||||
errors.endpoint();
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!group) group == 0;
|
||||
|
||||
|
||||
|
||||
|
||||
// what the hecking heck is this code supoased to do you hecking idiot
|
||||
|
||||
|
||||
@@ -95,7 +95,10 @@ export class BaseDatabase {
|
||||
primaryKey: true,
|
||||
unique: true
|
||||
},
|
||||
content: Sequelize.TEXT,
|
||||
content: {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true
|
||||
},
|
||||
parentgroup: {
|
||||
type: Sequelize.BIGINT,
|
||||
allowNull: true
|
||||
|
||||
@@ -3,11 +3,33 @@ import {Database} from '../database/database';
|
||||
|
||||
export class Notes extends Groups {
|
||||
static async newNote(id, content, creatorid, order) {
|
||||
|
||||
|
||||
Database.notes.newNote(id, null, )
|
||||
}
|
||||
|
||||
static async genID() {
|
||||
return new Date().getTime();
|
||||
}
|
||||
|
||||
static async genEndpoint() {
|
||||
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
let endpoint;
|
||||
while (true) {
|
||||
endpoint = 'N';
|
||||
for (let i = 0; i < 7; i++)
|
||||
endpoint += possible[Math.floor(Math.random() * possible.length)];
|
||||
|
||||
if (await Database.notes.getNoteByEndpoint(endpoint) == -1)
|
||||
break;
|
||||
}
|
||||
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
static async getNoteByEndpoint(endpoint) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
static async makeNotePerma(id, endpoint) {
|
||||
|
||||
@@ -10,7 +10,7 @@ export class PermaLink {
|
||||
|
||||
let endpoint;
|
||||
while (true) {
|
||||
endpoint = 'N';
|
||||
endpoint = 'P';
|
||||
for (let i = 0; i < 7; i++)
|
||||
endpoint += possible[Math.floor(Math.random() * possible.length)];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user