changed url to uri

This commit is contained in:
farhan 2020-12-07 15:47:44 -05:00
parent f7dd23bc55
commit a3644cce8f
5 changed files with 12 additions and 12 deletions

View File

@ -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("--------------------------")

View File

@ -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

View File

@ -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{}

View File

@ -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(),

View File

@ -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 {