-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathreports.js
More file actions
47 lines (42 loc) · 1.47 KB
/
reports.js
File metadata and controls
47 lines (42 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* reports tracks flagging of inappropriate content. Similarly to threads, an entity_id/type pairing
* is used to relate to multiple tables, requiring additional filtering and querying. For true SQL
* correctness, this could probably be split out into individual tables per entity.
*/
module.exports = function(sequelize, db) {
const r = sequelize.define("reports",
{
id: {
type: db.INTEGER,
primaryKey: true,
autoIncrement: true
},
// user id
uid: db.TEXT,
// dropdown reason
reason: db.TEXT,
// user description of issue
comment: db.TEXT,
// id of reported entity
report_id: db.INTEGER,
// type of reported entity
type: db.TEXT,
// reports get addressed by admins (new, approved, banned)
status: db.TEXT,
// link to offending content (DEPRECATED / UNUSED)
permalink: db.TEXT
},
{
freezeTableName: true,
timestamps: false
}
);
r.associate = models => {
// r.belongsTo(models.users, {foreignKey: "uid", targetKey: "id", as: "user"});
r.belongsTo(models.codeblocks, {foreignKey: "report_id", targetKey: "id", as: "codeblock"});
r.belongsTo(models.projects, {foreignKey: "report_id", targetKey: "id", as: "project"});
r.belongsTo(models.threads, {foreignKey: "report_id", targetKey: "id", as: "thread"});
r.belongsTo(models.comments, {foreignKey: "report_id", targetKey: "id", as: "commentref"});
};
return r;
};