Skip to content
This repository has been archived by the owner on Feb 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #320 from Hornwitser/rename-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
oof2win2 authored Jan 24, 2022
2 parents 14a54ce + c600372 commit 12d4115
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 298 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## UNRELEASED

### Changes

- Renamed report rules to categories

### Additions

- Added in Master Rules API to add and remove rules with a master API key
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"discord.js": "^13.6.0",
"dotenv": "^14.2.0",
"envalid": "^7.2.2",
"fagc-api-types": "^1.7.0",
"fagc-api-types": "^1.9.0",
"fastify": "^3.26.0",
"fastify-autoload": "^3.10.0",
"fastify-cors": "^6.0.2",
Expand Down
6 changes: 3 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fastify.register(fastifySwagger, {
// produces: ["application/json"],
tags: [
{ name: "community", description: "Community related end-points" },
{ name: "rules", description: "Rule related end-points" },
{ name: "categories", description: "Category related end-points" },
{ name: "reports", description: "Report related end-points" },
{ name: "profiles", description: "Profile related end-points" },
{
Expand Down Expand Up @@ -130,8 +130,8 @@ fastify.addSchema({
...generateSchema(Types.Community)
})
fastify.addSchema({
$id: "RuleClass",
...generateSchema(Types.Rule)
$id: "CategoryClass",
...generateSchema(Types.Category)
})
fastify.addSchema({
$id: "ReportClass",
Expand Down
12 changes: 6 additions & 6 deletions src/database/rule.ts → src/database/category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import IdModel, { IdType } from "./ids"

@modelOptions({
schemaOptions: {
collection: "rules",
collection: "categories",
},
})
@pre<RuleClass>("save", async function (next) {
@pre<CategoryClass>("save", async function (next) {
if (!this.id || !this._id) {
const id = await getUserStringFromID(IdType.COMMUNITY)
this.id = id.id
this._id = id._id
}
next()
})
export class RuleClass {
export class CategoryClass {
@prop({ unique: true })
id!: string

Expand All @@ -26,9 +26,9 @@ export class RuleClass {
longdesc!: string
}

const RuleModel = getModelForClass(RuleClass)
const CategoryModel = getModelForClass(CategoryClass)

const watcher = RuleModel.watch()
const watcher = CategoryModel.watch()
watcher.on("change", async (change) => {
if (change.operationType === "delete") {
// delete the ID from the db too
Expand All @@ -38,4 +38,4 @@ watcher.on("change", async (change) => {
}
})

export default RuleModel
export default CategoryModel
8 changes: 4 additions & 4 deletions src/database/guildconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Roles {
reports!: string
webhooks!: string
setConfig!: string
setRules!: string
setCategories!: string
setCommunities!: string
}

Expand All @@ -36,14 +36,14 @@ export class GuildConfigClass {
reports: String,
webhooks: String,
setConfig: String,
setRules: String,
setCategories: String,
setCommunities: String,
}),
default: {
reports: "",
webhooks: "",
setConfig: "",
setRules: "",
setCategories: "",
setCommunities: "",
}
})
Expand All @@ -53,7 +53,7 @@ export class GuildConfigClass {
trustedCommunities!: string[]

@prop({ type: [ String ], default: [] })
ruleFilters!: string[]
categoryFilters!: string[]
}

const GuildConfigModel = getModelForClass(GuildConfigClass)
Expand Down
2 changes: 1 addition & 1 deletion src/database/ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getModelForClass, modelOptions, prop } from "@typegoose/typegoose"

export enum IdType {
COMMUNITY = "community",
RULE = "rule",
CATEGORY = "category",
REPORT = "report",
REVOCATION = "revocation",
LOG = "log",
Expand Down
2 changes: 1 addition & 1 deletion src/database/reportinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ReportInfoClass {
communityId!: string

@prop()
brokenRule!: string
categoryId!: string

@prop()
proof!: string
Expand Down
Loading

0 comments on commit 12d4115

Please sign in to comment.