diff --git a/poll/db.go b/poll/db.go index ec05271..9c18bd5 100644 --- a/poll/db.go +++ b/poll/db.go @@ -15,7 +15,7 @@ func writePost(pool *pgxpool.Pool, reportpost ReportPost) { // Insert new account if new var accountid int - err = conn.QueryRow(context.Background(), "INSERT INTO accounts (acct, avatar, bot, created_at, display_name, url) VALUES($1, $2, $3, $4, $5, $6) ON CONFLICT(acct) DO UPDATE SET acct=EXCLUDED.acct RETURNING id", reportpost.Account.Acct, reportpost.Account.Avatar, reportpost.Account.Bot, reportpost.Account.Created_at, reportpost.Account.Display_name, reportpost.Account.Url).Scan(&accountid) + err = conn.QueryRow(context.Background(), "INSERT INTO accounts (acct, avatar, bot, created_at, display_name, uri) VALUES($1, $2, $3, $4, $5, $6) ON CONFLICT(acct) DO UPDATE SET acct=EXCLUDED.acct RETURNING id", reportpost.Account.Acct, reportpost.Account.Avatar, reportpost.Account.Bot, reportpost.Account.Created_at, reportpost.Account.Display_name, reportpost.Account.Url).Scan(&accountid) if err != nil { log.Print("First ", err) log.Print("--------------------------") @@ -33,7 +33,7 @@ func writePost(pool *pgxpool.Pool, reportpost ReportPost) { } // Insert new post if new - _, err = conn.Exec(context.Background(), "INSERT INTO posts (url, content, created_at, normalized, account_id, posthash) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (posthash) DO NOTHING", reportpost.Url, reportpost.Content, reportpost.Created_at, reportpost.normalized, accountid, reportpost.posthash) + _, err = conn.Exec(context.Background(), "INSERT INTO posts (uri, content, created_at, normalized, account_id, posthash) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (posthash) DO NOTHING", reportpost.Url, reportpost.Content, reportpost.Created_at, reportpost.normalized, accountid, reportpost.posthash) if err != nil { // For now I want to know why this failed. log.Print("Second ", err) log.Print("--------------------------") diff --git a/poll/headers.go b/poll/headers.go index aa111cb..267cfd6 100644 --- a/poll/headers.go +++ b/poll/headers.go @@ -21,7 +21,7 @@ type ReportPost struct { // Retrieved values Id string `json:"id"` - Url string `json:"url"` + Url string `json:"uri"` Account AccountType Content string `json:"content"` Created_at string `json:"created_at"` @@ -37,7 +37,7 @@ type AccountType struct { Bot bool `json:"bot"` Created_at string `json:"created_at"` Display_name string `json:"display_name"` - Url string `json:"url"` + Url string `json:"uri"` } // Instance's new min_id value diff --git a/poll/instance.go b/poll/instance.go index ef13bf8..bf3d03d 100644 --- a/poll/instance.go +++ b/poll/instance.go @@ -85,7 +85,7 @@ func PollMastodonPleroma(endpoint string, reportPostChan chan ReportPost) { m.Status = CLIENT_ISSUE runninginstances[endpoint] = m ri_mutex.Unlock() - log.Print("Failure here", err.Error()) + log.Fatal("Failure here", err.Error()) return } @@ -216,10 +216,10 @@ func GetNodeInfo(endpoint string) (NodeInfo) { * Mastodon/Pleroma * Um..nothing else yet */ - pleromastodon_nodeinfo_url := "https://" + endpoint + "/nodeinfo/2.0.json" + pleromastodon_nodeinfo_uri := "https://" + endpoint + "/nodeinfo/2.0.json" //http_client := http.Client{Timeout: 10 * time.Second} http_client := http.Client{} - pleromastodon_api_resp, err := http_client.Get(pleromastodon_nodeinfo_url) + pleromastodon_api_resp, err := http_client.Get(pleromastodon_nodeinfo_uri) if err != nil { return NodeInfo{} } else { @@ -236,8 +236,8 @@ func GetNodeInfo(endpoint string) (NodeInfo) { } // Check the front page - index_url := "https://" + endpoint + "/" - resp_index, err := http_client.Get(index_url) + index_uri := "https://" + endpoint + "/" + resp_index, err := http_client.Get(index_uri) if err != nil { log.Print("Unable to connect to " + endpoint + ", giving up") return NodeInfo{} diff --git a/poll/tables.sql b/poll/tables.sql index c32d6e7..a0b1085 100644 --- a/poll/tables.sql +++ b/poll/tables.sql @@ -6,13 +6,13 @@ CREATE TABLE accounts ( bot boolean, created_at timestamptz DEFAULT NOW(), display_name VARCHAR(2000) NOT NULL, - url VARCHAR(2083) NOT NULL + uri VARCHAR(2083) NOT NULL ); CREATE TABLE posts ( id serial NOT NULL PRIMARY KEY, - url VARCHAR(2083) NOT NULL, + uri VARCHAR(2083) NOT NULL, content text, created_at timestamptz DEFAULT NOW(), diff --git a/poll/web.go b/poll/web.go index 6374e0d..d32e2f3 100644 --- a/poll/web.go +++ b/poll/web.go @@ -166,7 +166,7 @@ func users_fedilogue(w http.ResponseWriter, r *http.Request) { userjsonmap["summary"] = "" userjsonmap["tag"] = tag userjsonmap["type"] = "Person" - userjsonmap["url"] = "https://" + host + "/users/fedilogue" + userjsonmap["uri"] = "https://" + host + "/users/fedilogue" userjsonbin, err := json.Marshal(userjsonmap) if err != nil {