From 328c9150228156c04d1045469c7dbcd7b5f4fedf Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Mon, 2 May 2022 17:43:39 -0700 Subject: admin auth and manage page working for initial pass through --- activitypub/object.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'activitypub/object.go') diff --git a/activitypub/object.go b/activitypub/object.go index 1256fac..c461310 100644 --- a/activitypub/object.go +++ b/activitypub/object.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "log" "mime/multipart" "net/http" "os" @@ -1777,3 +1778,35 @@ func WriteWalletToDB(obj ObjectBase) error { } return nil } + +func GetRecentPostsDB(actorID string) []ObjectBase { + var collection []ObjectBase + + query := `select id, actor, content, published, attachment from activitystream where actor=$1 and type='Note' union select id, actor, content, published, attachment from cacheactivitystream where actor in (select follower from follower where id=$1) and type='Note' order by published desc limit 20` + + rows, err := config.DB.Query(query, actorID) + + if err != nil { + log.Println("Could not get recent posts") + } + + defer rows.Close() + for rows.Next() { + var nObj ObjectBase + var attachmentID string + rows.Scan(&nObj.Id, &nObj.Actor, &nObj.Content, &nObj.Published, &attachmentID) + + isOP, _ := CheckIfObjectOP(nObj.Id) + nObj.Attachment, _ = GetObjectAttachment(attachmentID) + + if !isOP { + var reply ObjectBase + reply.Id = nObj.Id + nObj.InReplyTo = append(nObj.InReplyTo, reply) + } + + collection = append(collection, nObj) + } + + return collection +} -- cgit v1.2.3