From b6c03f8aa0ce125a76464699a72ff156769feb0e Mon Sep 17 00:00:00 2001 From: FChannel <=> Date: Wed, 20 Jan 2021 14:55:50 -0800 Subject: added actor object to context json --- main.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 8c7ff94..865d1ef 100644 --- a/main.go +++ b/main.go @@ -271,8 +271,6 @@ func main() { return } - - actor := GetActorFromPath(db, id, "/") if !HasAuth(db, auth[1], actor.Id) { @@ -280,7 +278,7 @@ func main() { w.Write([]byte("")) return } - + reported := DeleteReportActivity(db, id) if reported { w.Write([]byte("")) @@ -709,7 +707,10 @@ func GetActor(id string) Actor { resp, err := http.DefaultClient.Do(req) - CheckError(err, "error with getting actor resp") + if err != nil { + fmt.Println("error with getting actor resp") + return respActor + } defer resp.Body.Close() @@ -910,7 +911,7 @@ func ReportActivity(db *sql.DB, id string) bool { } if count < 1 { - query = fmt.Sprintf("insert into reported (id, count, board) values ('%s', %d, '%s')", id, 1, actor.Actor) + query = fmt.Sprintf("insert into reported (id, count, board) values ('%s', %d, '%s')", id, 1, actor.Actor.Id) _, err := db.Exec(query) @@ -966,16 +967,20 @@ func GetActorReported(w http.ResponseWriter, r *http.Request, db *sql.DB, id str func MakeActivityRequest(activity Activity) { j, _ := json.MarshalIndent(activity, "", "\t") + for _, e := range activity.To { + actor := GetActor(e) + if actor.Inbox != "" { req, err := http.NewRequest("POST", actor.Inbox, bytes.NewBuffer(j)) CheckError(err, "error with sending activity req to") _, err = http.DefaultClient.Do(req) - CheckError(err, "error with sending activity resp to") + CheckError(err, "error with sending activity resp to") + } } } -- cgit v1.2.3