diff --git a/headers.go b/headers.go index cfe3b3a..538ba23 100644 --- a/headers.go +++ b/headers.go @@ -22,6 +22,10 @@ const ( KEEPALIVE = 607 ) +type ObjectType struct { + Id string `json:"id"` +} + // Parsing Unmarshal JSON type type ReportPost struct { diff --git a/retrieve.go b/retrieve.go index dd7c5c0..e2a0fd1 100644 --- a/retrieve.go +++ b/retrieve.go @@ -90,7 +90,6 @@ func check_post(uri string) (PostJson, error) { selectRet := pool.QueryRow(context.Background(), "SELECT id, inReplyTo, published, summary, content, normalized, attributedto, posthash, received_at FROM posts WHERE id = $1", uri) err := selectRet.Scan(&postjson.ID, &postjson.InReplyTo, &postjson.Published, &postjson.Summary, &postjson.Content, &postjson.normalized, &postjson.AttributedTo, &postjson.posthash, &postjson.receivedAt) - if err == nil { return postjson, nil } @@ -101,7 +100,6 @@ func check_post(uri string) (PostJson, error) { } postjson.instance = uri[8:endslash+8] - o := GetHTTPSession(postjson.instance) req, _ := http.NewRequest("GET", uri, nil) req.Header.Add("Accept", "application/ld+json") @@ -167,7 +165,7 @@ func check_user(uri string) (UserJson, error) { selectRet := pool.QueryRow(context.Background(), "SELECT id, actor_type, inbox, outbox, followers, following, url, preferredUsername, name, summary, icon, image, publicKey, instance FROM accounts WHERE id = $1", uri) err := selectRet.Scan(&userjson.ID, &userjson.Type, &userjson.Inbox, &userjson.Outbox, &userjson.Followers, &userjson.Following, &userjson.Url, &userjson.PreferredUsername, &userjson.Name, &userjson.Summary, &userjson.Icon.Url, &userjson.Image.Url, &userjson.PublicKey.PublicKeyPem, &userjson.instance) if err == nil { - return userjson, errors.New("Unable to perform select on " + uri) + return userjson, nil } endslash := strings.Index(uri[8:], "/") if endslash == -1 { diff --git a/web.go b/web.go index 66bf5b0..5032ee7 100644 --- a/web.go +++ b/web.go @@ -15,6 +15,7 @@ import ( // CreateObject - Used by post web receiver type CreateObject struct { + ID string `json:"id"` Actor string `json:"actor"` Cc []string `json:"cc"` Content string `json:"content"` @@ -98,8 +99,6 @@ func webfinger(w http.ResponseWriter, r *http.Request) { func inboxHandler() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - fmt.Println("PATH --> ", r.URL.Path) - body, err := ioutil.ReadAll(r.Body) if err != nil { fmt.Println(err) @@ -109,21 +108,16 @@ func inboxHandler() http.HandlerFunc { var findtype RelayBase err = json.Unmarshal(body, &findtype) - fmt.Println(string(body)) - switch findtype.Type { case "Create": var createobject CreateObject - var newpost ReportPost err = json.Unmarshal(findtype.Object, &createobject) if err != nil { return } - newpost.Uri = findtype.ID - log.Print(newpost.Uri) - + go check_post(createobject.ID) case "Like": case "Announcement": case "Delete":