diff options
author | FChannel <=> | 2021-01-23 22:37:20 -0800 |
---|---|---|
committer | FChannel <=> | 2021-01-23 22:37:20 -0800 |
commit | 2ca021e2c6599b39e6225fdbd449093517a34418 (patch) | |
tree | de65bb297a63765f4e471ddd488975466e438df1 /main.go | |
parent | 000c206417a91d0f910cba35d16d433a1f038530 (diff) |
caching progress
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -80,8 +80,6 @@ func main() { path = re.ReplaceAllString(path, "") } - - var mainActor bool var mainInbox bool var mainOutbox bool @@ -1024,6 +1022,16 @@ func CreateObject(objType string) ObjectBase { return nObj } +func AddFollowersToActivity(db *sql.DB, activity Activity) Activity{ + followers := GetActorFollowingDB(db, activity.Actor.Id) + + for _, e := range followers { + activity.To = append(activity.To, e.Id) + } + + return activity +} + func CreateActivity(activityType string, obj ObjectBase) Activity { var newActivity Activity @@ -1370,9 +1378,23 @@ func IsActorLocal(db *sql.DB, id string) bool { func IsObjectLocal(db *sql.DB, id string) bool { - query := fmt.Sprintf("select id from activitystream where id='%s'", id) + query := `select id from activitystream where id=$1` - rows, err := db.Query(query) + rows, err := db.Query(query, id) + + defer rows.Close() + + if err != nil { + return false + } + + return true +} + +func IsObjectCached(db *sql.DB, id string) bool { + + query := `select id from cacheactivitystream where id=$1` + rows, err := db.Query(query, id) defer rows.Close() @@ -1525,6 +1547,8 @@ func MakeActivityRequest(activity Activity) { j, _ := json.MarshalIndent(activity, "", "\t") for _, e := range activity.To { + + fmt.Println(e) actor := GetActor(e) |