normalizing additions + light reorg
This commit is contained in:
parent
7f293b9dd3
commit
f7dd23bc55
@ -8,12 +8,9 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"github.com/microcosm-cc/bluemonday"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func startctl(reportPostChan chan ReportPost) {
|
func startctl(reportPostChan chan ReportPost) {
|
||||||
p = bluemonday.NewPolicy()
|
|
||||||
|
|
||||||
log.Print("Starting ctl listener on 127.0.0.1:5555")
|
log.Print("Starting ctl listener on 127.0.0.1:5555")
|
||||||
l, err := net.Listen("tcp", "127.0.0.1:5555")
|
l, err := net.Listen("tcp", "127.0.0.1:5555")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"regexp"
|
||||||
"html"
|
"html"
|
||||||
"time"
|
"time"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -14,6 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var p *bluemonday.Policy
|
var p *bluemonday.Policy
|
||||||
|
var spaceReg *regexp.Regexp
|
||||||
|
|
||||||
func PollMastodonPleroma(endpoint string, reportPostChan chan ReportPost) {
|
func PollMastodonPleroma(endpoint string, reportPostChan chan ReportPost) {
|
||||||
newposts := make([]ReportPost, 0)
|
newposts := make([]ReportPost, 0)
|
||||||
@ -163,6 +165,8 @@ func PollMastodonPleroma(endpoint string, reportPostChan chan ReportPost) {
|
|||||||
newpost.posthash = posthash.Sum(nil)
|
newpost.posthash = posthash.Sum(nil)
|
||||||
|
|
||||||
newpost.normalized = html.UnescapeString(strings.ToLower(p.Sanitize(newpost.Content)))
|
newpost.normalized = html.UnescapeString(strings.ToLower(p.Sanitize(newpost.Content)))
|
||||||
|
newpost.normalized = strings.ReplaceAll(newpost.normalized, "\t", " ")
|
||||||
|
newpost.normalized = spaceReg.ReplaceAllString(newpost.normalized, " ")
|
||||||
|
|
||||||
// Validate time
|
// Validate time
|
||||||
t, err := time.Parse(time.RFC3339, newpost.Created_at)
|
t, err := time.Parse(time.RFC3339, newpost.Created_at)
|
||||||
|
@ -4,7 +4,9 @@ import (
|
|||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
"regexp"
|
||||||
"log"
|
"log"
|
||||||
|
"github.com/microcosm-cc/bluemonday"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Current instances
|
// Current instances
|
||||||
@ -26,6 +28,8 @@ func main() {
|
|||||||
|
|
||||||
pool := get_db_pool()
|
pool := get_db_pool()
|
||||||
|
|
||||||
|
p = bluemonday.NewPolicy()
|
||||||
|
spaceReg = regexp.MustCompile(`\s+`)
|
||||||
|
|
||||||
go startctl(reportPostChan)
|
go startctl(reportPostChan)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user