diff options
author | FChannel <> | 2022-05-08 14:57:40 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 580dec5b89215310ce34341e11ff17fe38bdb63a (patch) | |
tree | 894424df66a9d9f7e41805822f29adac8fb490fe /db/cache.go | |
parent | f7bf818d29393ceaccf4d2906557351fa6a4f49f (diff) |
more cleanup, logging and error logging everywhere
things are mostly in place can work on "features" and polish
Diffstat (limited to 'db/cache.go')
-rw-r--r-- | db/cache.go | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/db/cache.go b/db/cache.go deleted file mode 100644 index d1c1fe7..0000000 --- a/db/cache.go +++ /dev/null @@ -1,72 +0,0 @@ -package db - -import ( - "github.com/FChannel0/FChannel-Server/activitypub" - "github.com/FChannel0/FChannel-Server/config" - "github.com/FChannel0/FChannel-Server/webfinger" - _ "github.com/lib/pq" -) - -func WriteObjectReplyToCache(obj activitypub.ObjectBase) error { - for i, e := range obj.InReplyTo { - res, err := IsReplyInThread(obj.InReplyTo[0].Id, e.Id) - if err != nil { - return err - } - - if i == 0 || res { - query := `select id from replies where id=$1` - - rows, err := config.DB.Query(query, obj.Id) - if err != nil { - return err - } - defer rows.Close() - - var id string - rows.Next() - err = rows.Scan(&id) - if err != nil { - return err - } else if id != "" { - return nil // TODO: error? - } - - query = `insert into cachereplies (id, inreplyto) values ($1, $2)` - - _, err = config.DB.Exec(query, obj.Id, e.Id) - if err != nil { - return err - } - } - } - - if len(obj.InReplyTo) < 1 { - query := `insert into cachereplies (id, inreplyto) values ($1, $2)` - - _, err := config.DB.Exec(query, obj.Id, "") - return err - } - - return nil -} - -func WriteActorToCache(actorID string) error { - actor, err := webfinger.FingerActor(actorID) - if err != nil { - return err - } - - collection, err := webfinger.GetActorCollection(actor.Outbox) - if err != nil { - return err - } - - for _, e := range collection.OrderedItems { - if err := e.WriteCache(); err != nil { - return err - } - } - - return nil -} |