From f7bf818d29393ceaccf4d2906557351fa6a4f49f Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sat, 7 May 2022 21:21:38 -0700 Subject: added error func and general cleanup/organization --- db/cache.go | 2 +- db/database.go | 2 +- db/follow.go | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'db') diff --git a/db/cache.go b/db/cache.go index a20a8ed..d1c1fe7 100644 --- a/db/cache.go +++ b/db/cache.go @@ -63,7 +63,7 @@ func WriteActorToCache(actorID string) error { } for _, e := range collection.OrderedItems { - if _, err := e.WriteActorObjectToCache(); err != nil { + if err := e.WriteCache(); err != nil { return err } } diff --git a/db/database.go b/db/database.go index e92eec5..5d53f46 100644 --- a/db/database.go +++ b/db/database.go @@ -658,7 +658,7 @@ func DeleteObjectRequest(id string) error { return err } - obj, err := activitypub.GetObjectFromPath(id) + obj, err := nObj.GetFromPath() if err != nil { return err } diff --git a/db/follow.go b/db/follow.go index e3c0583..3932ea1 100644 --- a/db/follow.go +++ b/db/follow.go @@ -77,7 +77,7 @@ func SetActorFollowingDB(activity activitypub.Activity) (activitypub.Activity, e if alreadyFollowing && alreadyFollower { query = `delete from following where id=$1 and following=$2` activity.Summary = activity.Object.Actor + " Unfollowing " + activity.Actor.Id - if res, err := activitypub.IsActorLocal(activity.Actor.Id); err == nil && !res { + if res, err := activity.Actor.IsLocal(); err == nil && !res { go activity.Actor.DeleteCache() } else { return activity, err @@ -95,7 +95,7 @@ func SetActorFollowingDB(activity activitypub.Activity) (activitypub.Activity, e query = `insert into following (id, following) values ($1, $2)` activity.Summary = activity.Object.Actor + " Following " + activity.Actor.Id - if res, err := activitypub.IsActorLocal(activity.Actor.Id); err == nil && !res { + if res, err := activity.Actor.IsLocal(); err == nil && !res { go WriteActorToCache(activity.Actor.Id) } if _, err := config.DB.Exec(query, activity.Object.Actor, activity.Actor.Id); err != nil { @@ -197,7 +197,7 @@ func MakeActivityRequestOutbox(activity activitypub.Activity) error { if activity.Actor.Id == config.Domain { instance = re.ReplaceAllString(config.Domain, "") } else { - _, instance = activitypub.GetActorInstance(activity.Actor.Id) + _, instance = activitypub.GetActorAndInstance(activity.Actor.Id) } date := time.Now().UTC().Format(time.RFC1123) @@ -233,7 +233,7 @@ func MakeActivityRequest(activity activitypub.Activity) error { } if actor.Id != "" { - _, instance := activitypub.GetActorInstance(actor.Id) + _, instance := activitypub.GetActorAndInstance(actor.Id) if actor.Inbox != "" { req, err := http.NewRequest("POST", actor.Inbox, bytes.NewBuffer(j)) -- cgit v1.2.3