From 13e4bc04a72adf65ee7a25c2220a4cb3b4dc560b Mon Sep 17 00:00:00 2001 From: Arnas Udovic Date: Tue, 1 Jul 2025 22:43:36 +0300 Subject: [PATCH] page to see rejected --- README.md | 5 +++-- db.go | 16 ++++++++++++++++ main.go | 6 ++++++ templates/index.tmpl | 1 + templates/rejected.tmpl | 12 ++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 templates/rejected.tmpl diff --git a/README.md b/README.md index 7f9eee1..63a87fe 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/db.go b/db.go index dbdf6b0..e4d922b 100644 --- a/db.go +++ b/db.go @@ -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 +} diff --git a/main.go b/main.go index d84ff2b..2375cb8 100644 --- a/main.go +++ b/main.go @@ -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") diff --git a/templates/index.tmpl b/templates/index.tmpl index 4e71263..97a63c8 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -43,6 +43,7 @@
  • / - some html information about this filter (this page)
  • /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. This should be given to Peertube instance
  • +
  • /rejected - list of rejected instances. This could be c/p to Peertube moderation muted servers.
  • Setup

    diff --git a/templates/rejected.tmpl b/templates/rejected.tmpl new file mode 100644 index 0000000..f98786c --- /dev/null +++ b/templates/rejected.tmpl @@ -0,0 +1,12 @@ + + + + Peertube instance index - rejected + + + + {{range .hosts}} + {{.}}
    + {{end}} + +