page to see rejected

This commit is contained in:
Arnas Udovic 2025-07-01 22:43:36 +03:00
parent 9217c047b7
commit 13e4bc04a7
5 changed files with 38 additions and 2 deletions

View file

@ -10,14 +10,15 @@ App can be called directly and do management in console.
- `peertube-instance-index-filter -command index -url https://instances.joinpeertube.org/api/v1/instances/hosts -instance-url https://instances.joinpeertube.org/api/v1/instances` - add url to index of hosts. Later it will be used to collect instances
- `peertube-instance-index-filter -command collect` - collect instances from index of hosts urls
- `peertube-instance-index-filter -command reject -host www.example.com` - reject instance from index to exclude it from global index
- `peertube-instance-index-filter -command audit -filter dead` - go through not rejected instances and check by filters: dead, duplicates
- `peertube-instance-index-filter -command reject -host www.example.com -reject-reason "no local videos"` - reject instance from index to exclude it from global index
- `peertube-instance-index-filter -command audit -filter dead -last-id 0` - go through not rejected instances and check by filters: dead (no http response), duplicates (duplicate entries in db), empty (no local videos and created before 3 months)
## Links
- `/` - some html information about this filter and stats
- `/instances` - list of instances in json format with more information. Supports pagination, filter by instance creation date: `?start=3&count=100&since=2024-01-10`. Sorted by descending creation date. Also it can be used as search by host: `?search=www.example.com`
- `/instances/hosts` - list of hosts in json format. Supports pagination, filter by instance creation date: `?start=3&count=100&since=2024-01-10`. Sorted by descending creation date
- `/rejected` - list of rejected instances. This could be c/p to Peertube moderation muted servers.
## Setup

16
db.go
View file

@ -237,3 +237,19 @@ func getInstance(db *sql.DB, url string) (Instance, error) {
func removeInstance(db *sql.DB, id string) {
db.Exec("DELETE FROM instances WHERE id = ?", id)
}
func getRejectedHosts(db *sql.DB) []string {
hosts := []string{}
rows, err := db.Query("SELECT url FROM instances WHERE rejected = 1")
if err != nil {
return hosts
}
for rows.Next() {
var host string
rows.Scan(&host)
hosts = append(hosts, host)
}
return hosts
}

View file

@ -201,6 +201,12 @@ func serve() {
})
})
r.GET("/rejected", func(c *gin.Context) {
c.HTML(http.StatusOK, "rejected.tmpl", gin.H{
"hosts": getRejectedHosts(db),
})
})
r.GET("/instances", func(c *gin.Context) {
start := c.DefaultQuery("start", "0")
count := c.DefaultQuery("count", "20")

View file

@ -43,6 +43,7 @@
<li><a href="/">/</a> - some html information about this filter (this page)</li>
<li><a href="/instances">/instances</a> - list of instances in json format with more information. Supports pagination, filter by instance creation date: <code>?start=3&amp;count=100&amp;since=2024-01-10</code>. Sorted by descending creation date. Also it can be used as search by host: <code>?search=www.example.com</code></li>
<li><a href="/instances/hosts">/instances/hosts</a> - list of hosts in json format. Supports pagination, filter by instance creation date: <code>?start=3&amp;count=100&amp;since=2024-01-10</code>. Sorted by descending creation date. <b>This should be given to Peertube instance</b></li>
<li><a href="/rejected">/rejected</a> - list of rejected instances. This could be c/p to Peertube moderation muted servers.</li>
</ul>
<h2>Setup</h2>

12
templates/rejected.tmpl Normal file
View file

@ -0,0 +1,12 @@
<html>
<head>
<meta charset="utf-8">
<title>Peertube instance index - rejected</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
{{range .hosts}}
{{.}}<br>
{{end}}
</body>
</html>