feat: Cleanup api keys and webhooks for suspended users (#3756)

This commit is contained in:
Tom Moor
2022-07-13 09:59:31 +02:00
committed by GitHub
parent d1b01d28e6
commit 47e73cee4e
11 changed files with 264 additions and 29 deletions

View File

@@ -8,6 +8,7 @@ import {
DataType,
IsUrl,
} from "sequelize-typescript";
import { SaveOptions } from "sequelize/types";
import { Event } from "@server/types";
import Team from "./Team";
import User from "./User";
@@ -55,7 +56,18 @@ class WebhookSubscription extends ParanoidModel {
teamId: string;
// methods
validForEvent = (event: Event): bool => {
/**
* Disables the webhook subscription
*
* @param options Save options
* @returns Promise<void>
*/
public async disable(options?: SaveOptions<WebhookSubscription>) {
return this.update({ enabled: false }, options);
}
public validForEvent = (event: Event): bool => {
if (this.events.length === 1 && this.events[0] === "*") {
return true;
}