1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Implement auto tag on comments and videos

* Comments and videos can be automatically tagged using core rules or
   watched word lists
 * These tags can be used to automatically filter videos and comments
 * Introduce a new video comment policy where comments must be approved
   first
 * Comments may have to be approved if the user auto block them using
   core rules or watched word lists
 * Implement FEP-5624 to federate reply control policies
This commit is contained in:
Chocobozzz 2024-03-29 14:25:03 +01:00 committed by Chocobozzz
parent b3e39df59e
commit 29329d6c45
241 changed files with 8090 additions and 1399 deletions

View file

@ -1,17 +1,26 @@
import { BindOrReplacements, Op, QueryTypes, Sequelize } from 'sequelize'
import { forceNumber } from '@peertube/peertube-core-utils'
import { BindOrReplacements, Op, QueryOptionsWithType, QueryTypes, Sequelize, Transaction } from 'sequelize'
import { Fn } from 'sequelize/types/utils'
import validator from 'validator'
import { forceNumber } from '@peertube/peertube-core-utils'
function doesExist (sequelize: Sequelize, query: string, bind?: BindOrReplacements) {
const options = {
type: QueryTypes.SELECT as QueryTypes.SELECT,
async function doesExist (options: {
sequelize: Sequelize
query: string
bind?: BindOrReplacements
transaction?: Transaction
}) {
const { sequelize, query, bind, transaction } = options
const queryOptions: QueryOptionsWithType<QueryTypes.SELECT> = {
type: QueryTypes.SELECT,
bind,
raw: true
raw: true,
transaction
}
return sequelize.query(query, options)
.then(results => results.length === 1)
const results = await sequelize.query(query, queryOptions)
return results.length === 1
}
// FIXME: have to specify the result type to not break peertube typings generation
@ -64,13 +73,8 @@ function searchAttribute (sourceField?: string, targetField?: string) {
}
export {
doesExist,
createSimilarityAttribute,
buildWhereIdOrUUID,
parseAggregateResult,
parseRowCountResult,
createSafeIn,
searchAttribute
buildWhereIdOrUUID, createSafeIn, createSimilarityAttribute, doesExist, parseAggregateResult,
parseRowCountResult, searchAttribute
}
// ---------------------------------------------------------------------------