aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorFChannel <=>2021-01-19 16:41:31 -0800
committerFChannel <=>2021-01-19 16:41:31 -0800
commitcecfc9b08bbce20b14c367577ba728f27d51fb55 (patch)
tree97e1eacd16ac51c5f23419b30b61f37659b48576 /main.go
parent328eff4285c94d3840659c04921d7c8048ea1f55 (diff)
cache system and follow/follower connections
Diffstat (limited to 'main.go')
-rw-r--r--main.go56
1 files changed, 48 insertions, 8 deletions
diff --git a/main.go b/main.go
index bf714e8..e7af54b 100644
--- a/main.go
+++ b/main.go
@@ -701,7 +701,7 @@ func CheckValidActivity(id string) (Collection, bool) {
func GetActor(id string) Actor {
- var respActor Actor
+ var respActor Actor
req, err := http.NewRequest("GET", id, nil)
@@ -747,7 +747,6 @@ func GetActorCollection(collection string) Collection {
return nCollection
}
-
func IsValidActor(id string) (Actor, bool) {
var respCollection Actor
req, err := http.NewRequest("GET", id, nil)
@@ -969,7 +968,7 @@ func MakeActivityRequest(activity Activity) {
j, _ := json.MarshalIndent(activity, "", "\t")
for _, e := range activity.To {
actor := GetActor(e)
-
+
req, err := http.NewRequest("POST", actor.Inbox, bytes.NewBuffer(j))
CheckError(err, "error with sending activity req to")
@@ -994,13 +993,16 @@ func GetCollectionFromID(id string) Collection {
return nColl
}
- defer resp.Body.Close()
-
- body, _ := ioutil.ReadAll(resp.Body)
+ if resp.StatusCode == 200 {
+ defer resp.Body.Close()
+
+ body, _ := ioutil.ReadAll(resp.Body)
- err = json.Unmarshal(body, &nColl)
+ err = json.Unmarshal(body, &nColl)
- CheckError(err, "error getting collection resp from json body")
+ CheckError(err, "error getting collection resp from json body")
+
+ }
return nColl
}
@@ -1088,3 +1090,41 @@ func GetUniqueFilename(_type string) string {
return ""
}
+
+func DeleteObjectRequest(db *sql.DB, id string) {
+ var nObj ObjectBase
+ nObj.Id = id
+
+ activity := CreateActivity("Delete", nObj)
+
+ obj := GetObjectFromPath(db, id)
+ followers := GetActorFollowDB(db, obj.Actor.Id)
+ for _, e := range followers {
+ activity.To = append(activity.To, e.Id)
+ }
+
+ following := GetActorFollowingDB(db, obj.Actor.Id)
+ for _, e := range following {
+ activity.To = append(activity.To, e.Id)
+ }
+
+ MakeActivityRequest(activity)
+}
+
+func DeleteObjectAndRepliesRequest(db *sql.DB, id string) {
+ var nObj ObjectBase
+ nObj.Id = id
+
+ activity := CreateActivity("Delete", nObj)
+
+ obj := GetObjectFromPath(db, id)
+
+ followers := GetActorFollowDB(db, obj.Actor.Id)
+ for _, e := range followers {
+ activity.To = append(activity.To, e.Id)
+ }
+
+ MakeActivityRequest(activity)
+}
+
+