Add some easy moderation tools
This commit is contained in:
parent
0ef1e37ad6
commit
8f62cc5577
|
@ -22,6 +22,12 @@ instances-index:
|
|||
# Must answer the following format: https://framagit.org/framasoft/peertube/instances-peertube#peertube-auto-follow-global-search
|
||||
url: 'https://instances.joinpeertube.org/api/v1/instances/hosts'
|
||||
|
||||
whitelist:
|
||||
enabled: false
|
||||
hosts: null
|
||||
# Useful to do tests
|
||||
whitelist:
|
||||
enabled: false
|
||||
hosts: null
|
||||
|
||||
api:
|
||||
blacklist:
|
||||
enabled: false
|
||||
hosts: null
|
||||
|
|
|
@ -3,13 +3,20 @@ elastic_search:
|
|||
videos: 'peertube-index-videos-test1'
|
||||
channels: 'peertube-index-channels-test1'
|
||||
|
||||
whitelist:
|
||||
enabled: true
|
||||
hosts:
|
||||
- 'peertube.cpy.re'
|
||||
- 'peertube2.cpy.re'
|
||||
- 'peertube3.cpy.re'
|
||||
- 'framatube.org'
|
||||
- 'aperi.tube'
|
||||
- 'peertube.datagueule.tv'
|
||||
- 'thinkerview.video'
|
||||
instances-index:
|
||||
whitelist:
|
||||
enabled: true
|
||||
hosts:
|
||||
- 'peertube.cpy.re'
|
||||
- 'peertube2.cpy.re'
|
||||
- 'peertube3.cpy.re'
|
||||
- 'framatube.org'
|
||||
- 'aperi.tube'
|
||||
- 'peertube.datagueule.tv'
|
||||
- 'thinkerview.video'
|
||||
|
||||
api:
|
||||
blacklist:
|
||||
enabled: true
|
||||
hosts:
|
||||
- 'peertube.cpy.re'
|
||||
|
|
|
@ -7,6 +7,7 @@ import { setDefaultSearchSort } from '../../middlewares/sort'
|
|||
import { paginationValidator } from '../../middlewares/validators/pagination'
|
||||
import { videoChannelsSearchValidator, commonFiltersValidators } from '../../middlewares/validators/search'
|
||||
import { channelsSearchSortValidator } from '../../middlewares/validators/sort'
|
||||
import { CONFIG } from '../../initializers/constants'
|
||||
|
||||
const searchChannelsRouter = express.Router()
|
||||
|
||||
|
@ -28,6 +29,15 @@ export { searchChannelsRouter }
|
|||
|
||||
async function searchChannels (req: express.Request, res: express.Response) {
|
||||
const query = Object.assign(req.query || {}, req.body || {}) as ChannelsSearchQuery
|
||||
|
||||
if (!Array.isArray(query.blockedHosts)) {
|
||||
query.blockedHosts = []
|
||||
}
|
||||
|
||||
if (CONFIG.API.BLACKLIST.ENABLED && Array.isArray(CONFIG.API.BLACKLIST.HOSTS)) {
|
||||
query.blockedHosts = query.blockedHosts.concat(CONFIG.API.BLACKLIST.HOSTS)
|
||||
}
|
||||
|
||||
const resultList = await queryChannels(query)
|
||||
|
||||
return res.json({
|
||||
|
|
|
@ -7,6 +7,7 @@ import { videosSearchSortValidator } from '../../middlewares/validators/sort'
|
|||
import { commonVideosFiltersValidator, videosSearchValidator, commonFiltersValidators } from '../../middlewares/validators/search'
|
||||
import { setDefaultSearchSort } from '../../middlewares/sort'
|
||||
import { VideosSearchQuery } from 'server/types/video-search.model'
|
||||
import { CONFIG } from '../../initializers/constants'
|
||||
|
||||
const searchVideosRouter = express.Router()
|
||||
|
||||
|
@ -30,6 +31,14 @@ export { searchVideosRouter }
|
|||
async function searchVideos (req: express.Request, res: express.Response) {
|
||||
const query = Object.assign(req.query || {}, req.body || {}) as VideosSearchQuery
|
||||
|
||||
if (!Array.isArray(query.blockedHosts)) {
|
||||
query.blockedHosts = []
|
||||
}
|
||||
|
||||
if (CONFIG.API.BLACKLIST.ENABLED && Array.isArray(CONFIG.API.BLACKLIST.HOSTS)) {
|
||||
query.blockedHosts = query.blockedHosts.concat(CONFIG.API.BLACKLIST.HOSTS)
|
||||
}
|
||||
|
||||
const resultList = await queryVideos(query)
|
||||
|
||||
return res.json({
|
||||
|
|
|
@ -24,11 +24,17 @@ const CONFIG = {
|
|||
LEVEL: config.get<string>('log.level')
|
||||
},
|
||||
INSTANCES_INDEX: {
|
||||
URL: config.get<string>('instances-index.url')
|
||||
URL: config.get<string>('instances-index.url'),
|
||||
WHITELIST: {
|
||||
ENABLED: config.get<boolean>('instances-index.whitelist.enabled'),
|
||||
HOSTS: config.get<string[]>('instances-index.whitelist.hosts')
|
||||
}
|
||||
},
|
||||
WHITELIST: {
|
||||
ENABLED: config.get<boolean>('whitelist.enabled'),
|
||||
HOSTS: config.get<string[]>('whitelist.hosts')
|
||||
API: {
|
||||
BLACKLIST: {
|
||||
ENABLED: config.get<boolean>('api.blacklist.enabled'),
|
||||
HOSTS: config.get<string[]>('api.blacklist.hosts')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ async function listIndexInstances () {
|
|||
async function buildInstanceHosts () {
|
||||
let indexHosts = await listIndexInstancesHost()
|
||||
|
||||
if (CONFIG.WHITELIST.ENABLED) {
|
||||
const whitelistHosts = Array.isArray(CONFIG.WHITELIST.HOSTS) ? CONFIG.WHITELIST.HOSTS : []
|
||||
if (CONFIG.INSTANCES_INDEX.WHITELIST.ENABLED) {
|
||||
const whitelistHosts = Array.isArray(CONFIG.INSTANCES_INDEX.WHITELIST.HOSTS) ? CONFIG.INSTANCES_INDEX.WHITELIST.HOSTS : []
|
||||
|
||||
indexHosts = indexHosts.filter(h => whitelistHosts.includes(h))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue