Skip to content

Commit

Permalink
Renamed comment model 'target' to 'post' and 'responseTarget' to 'par…
Browse files Browse the repository at this point in the history
…ent'
  • Loading branch information
MKHenson committed May 17, 2016
1 parent 2131ae3 commit 4c8022c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions server/dist/definitions/modepress-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions server/dist/src/controllers/comments-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions server/dist/src/models/comments-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions server/src/controllers/comments-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class CommentsController extends Controller
router.get("/users/:user/comments/:id", <any>[hasId("id", "ID"), this.getComment.bind(this)]);
router.delete("/users/:user/comments/:id", <any>[canEdit, hasId("id", "ID"), this.remove.bind(this)]);
router.put("/users/:user/comments/:id", <any>[canEdit, hasId("id", "ID"), this.update.bind(this)]);
router.post("/posts/:postId/comments/:target?", <any>[canEdit, hasId("postId", "Post ID"), hasId("target", "Target ID"), this.create.bind(this)]);
router.post("/posts/:postId/comments/:parent?", <any>[canEdit, hasId("postId", "parent ID"), hasId("parent", "Parent ID", true), this.create.bind(this)]);

// Register the path
e.use( "/api", router );
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions server/src/definitions/custom/modepress-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions server/src/models/comments-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4c8022c

Please sign in to comment.