Add Blacklists
- Add BlacklistedPhrase model to store blacklisted phrases - Add checking for blacklisted phrases inside of posts content, usernames, groupnames, eventnames - Add api to create, delete phrases and check if phrases contain blacklisted phrasespull/4/head
parent
81b0aa9657
commit
f58dc4a33c
@ -0,0 +1,10 @@
|
|||||||
|
import {BaseError} from "./BaseError";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an error that is thrown when a blacklisted phrase is used.
|
||||||
|
*/
|
||||||
|
export class BlacklistedError extends BaseError {
|
||||||
|
constructor(public phrases: string[], field: string = "input") {
|
||||||
|
super(`The ${field} contains the blacklisted words: ${phrases.join(",")}`);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
import * as sqz from "sequelize";
|
||||||
|
import {
|
||||||
|
BelongsTo,
|
||||||
|
BelongsToMany,
|
||||||
|
Column,
|
||||||
|
ForeignKey,
|
||||||
|
HasMany,
|
||||||
|
Model,
|
||||||
|
NotNull,
|
||||||
|
Table,
|
||||||
|
Unique,
|
||||||
|
} from "sequelize-typescript";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a blacklisted phrase
|
||||||
|
*/
|
||||||
|
@Table({underscored: true})
|
||||||
|
export class BlacklistedPhrase extends Model {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The phrase that is blacklisted
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
@Unique
|
||||||
|
@Column({allowNull: false, unique: true})
|
||||||
|
public phrase: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional language
|
||||||
|
*/
|
||||||
|
@Column({type: sqz.STRING(2), defaultValue: "en"})
|
||||||
|
public language: string;
|
||||||
|
}
|
Loading…
Reference in New Issue