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