diff --git a/server/dist/definitions/modepress-api.d.ts b/server/dist/definitions/modepress-api.d.ts index 581edf7c..b180814a 100644 --- a/server/dist/definitions/modepress-api.d.ts +++ b/server/dist/definitions/modepress-api.d.ts @@ -52,8 +52,8 @@ declare module Modepress export interface IComment extends IModelEntry { author?: string; - target?: string; - responseTarget?: string; + post?: string; + parent?: string; public?: boolean; content?: string; createdOn?: number; diff --git a/server/dist/src/controllers/comments-controller.js b/server/dist/src/controllers/comments-controller.js index 28a4db15..a67f8e1e 100644 --- a/server/dist/src/controllers/comments-controller.js +++ b/server/dist/src/controllers/comments-controller.js @@ -38,7 +38,7 @@ class CommentsController extends controller_1.Controller { router.get("/users/:user/comments/:id", [permission_controllers_1.hasId("id", "ID"), this.getComment.bind(this)]); router.delete("/users/:user/comments/:id", [permission_controllers_1.canEdit, permission_controllers_1.hasId("id", "ID"), this.remove.bind(this)]); router.put("/users/:user/comments/:id", [permission_controllers_1.canEdit, permission_controllers_1.hasId("id", "ID"), this.update.bind(this)]); - router.post("/posts/:postId/comments/:target?", [permission_controllers_1.canEdit, permission_controllers_1.hasId("postId", "Post ID"), permission_controllers_1.hasId("target", "Target ID"), this.create.bind(this)]); + router.post("/posts/:postId/comments/:parent?", [permission_controllers_1.canEdit, permission_controllers_1.hasId("postId", "parent ID"), permission_controllers_1.hasId("parent", "Parent ID", true), this.create.bind(this)]); // Register the path e.use("/api", router); } @@ -216,7 +216,8 @@ class CommentsController extends controller_1.Controller { var comments = this.getModel("comments"); // User is passed from the authentication function token.author = req._user.username; - token.responseTarget = req.params.target; + token.post = req.params.postId; + token.parent = req.params.parent; comments.createInstance(token).then(function (instance) { return instance.schema.getAsJson(instance._id, { verbose: true }); }).then(function (json) { diff --git a/server/dist/src/models/comments-model.js b/server/dist/src/models/comments-model.js index d4303fde..6d9c1aee 100644 --- a/server/dist/src/models/comments-model.js +++ b/server/dist/src/models/comments-model.js @@ -6,9 +6,9 @@ class CommentsModel extends model_1.Model { constructor() { super("comments"); this.defaultSchema.add(new schema_item_factory_1.text("author", "")).setRequired(true); - this.defaultSchema.add(new schema_item_factory_1.foreignKey("target", "", "posts", false)).setRequired(true); - this.defaultSchema.add(new schema_item_factory_1.text("responseTarget", "")); - this.defaultSchema.add(new schema_item_factory_1.html("content", "", schema_html_1.SchemaHtml.defaultTags.concat("img"), undefined, false)); + this.defaultSchema.add(new schema_item_factory_1.foreignKey("post", "", "posts", false)).setRequired(true); + this.defaultSchema.add(new schema_item_factory_1.foreignKey("parent", "", "comments")); + this.defaultSchema.add(new schema_item_factory_1.html("content", "", schema_html_1.SchemaHtml.defaultTags.concat("img"), undefined, true)); this.defaultSchema.add(new schema_item_factory_1.bool("public", true)); this.defaultSchema.add(new schema_item_factory_1.date("createdOn")).setIndexable(true); this.defaultSchema.add(new schema_item_factory_1.date("lastUpdated", undefined, true)).setIndexable(true); diff --git a/server/src/controllers/comments-controller.ts b/server/src/controllers/comments-controller.ts index bbe32d94..436158f6 100644 --- a/server/src/controllers/comments-controller.ts +++ b/server/src/controllers/comments-controller.ts @@ -38,7 +38,7 @@ export default class CommentsController extends Controller router.get("/users/:user/comments/:id", [hasId("id", "ID"), this.getComment.bind(this)]); router.delete("/users/:user/comments/:id", [canEdit, hasId("id", "ID"), this.remove.bind(this)]); router.put("/users/:user/comments/:id", [canEdit, hasId("id", "ID"), this.update.bind(this)]); - router.post("/posts/:postId/comments/:target?", [canEdit, hasId("postId", "Post ID"), hasId("target", "Target ID"), this.create.bind(this)]); + router.post("/posts/:postId/comments/:parent?", [canEdit, hasId("postId", "parent ID"), hasId("parent", "Parent ID", true), this.create.bind(this)]); // Register the path e.use( "/api", router ); @@ -262,7 +262,8 @@ export default class CommentsController extends Controller // User is passed from the authentication function token.author = req._user.username; - token.responseTarget = req.params.target; + token.post = req.params.postId; + token.parent = req.params.parent; comments.createInstance(token).then(function (instance) { diff --git a/server/src/definitions/custom/modepress-api.d.ts b/server/src/definitions/custom/modepress-api.d.ts index 51128fee..6cca5278 100644 --- a/server/src/definitions/custom/modepress-api.d.ts +++ b/server/src/definitions/custom/modepress-api.d.ts @@ -52,8 +52,8 @@ export interface IComment extends IModelEntry { author?: string; - target?: string; - responseTarget?: string; + post?: string; + parent?: string; public?: boolean; content?: string; createdOn?: number; diff --git a/server/src/models/comments-model.ts b/server/src/models/comments-model.ts index 730e0b57..1377498e 100644 --- a/server/src/models/comments-model.ts +++ b/server/src/models/comments-model.ts @@ -10,9 +10,9 @@ export class CommentsModel extends Model super("comments"); this.defaultSchema.add(new text("author", "")).setRequired(true) - this.defaultSchema.add(new foreignKey( "target", "", "posts", false)).setRequired(true) - this.defaultSchema.add(new text("responseTarget", "")) - this.defaultSchema.add(new html("content", "", SchemaHtml.defaultTags.concat("img"), undefined, false)); + this.defaultSchema.add(new foreignKey("post", "", "posts", false)).setRequired(true) + this.defaultSchema.add(new foreignKey("parent", "", "comments")) + this.defaultSchema.add(new html( "content", "", SchemaHtml.defaultTags.concat("img"), undefined, true)); this.defaultSchema.add(new bool("public", true)); this.defaultSchema.add(new date("createdOn")).setIndexable(true); this.defaultSchema.add(new date("lastUpdated", undefined, true)).setIndexable(true);