aboutsummaryrefslogtreecommitdiff
path: root/activitypub
diff options
context:
space:
mode:
authorFChannel <>2022-05-02 17:43:39 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit328c9150228156c04d1045469c7dbcd7b5f4fedf (patch)
treeae4e281b4e0b6df3c54919756d55bfeff90f0ef0 /activitypub
parent62edcb3745f414212ee102c13429056f02cf31bd (diff)
admin auth and manage page working for initial pass through
Diffstat (limited to 'activitypub')
-rw-r--r--activitypub/actor.go12
-rw-r--r--activitypub/object.go33
2 files changed, 39 insertions, 6 deletions
diff --git a/activitypub/actor.go b/activitypub/actor.go
index 3fbcb75..757f6bf 100644
--- a/activitypub/actor.go
+++ b/activitypub/actor.go
@@ -339,7 +339,7 @@ func GetActorFollowTotal(id string) (int, int, error) {
return following, followers, nil
}
-func GetActorFollowers(w http.ResponseWriter, id string) error {
+func GetActorFollowers(ctx *fiber.Ctx, id string) error {
var following Collection
var err error
@@ -356,12 +356,12 @@ func GetActorFollowers(w http.ResponseWriter, id string) error {
}
enc, _ := json.MarshalIndent(following, "", "\t")
- w.Header().Set("Content-Type", config.ActivityStreams)
- _, err = w.Write(enc)
+ ctx.Response().Header.Set("Content-Type", config.ActivityStreams)
+ _, err = ctx.Write(enc)
return err
}
-func GetActorFollowing(w http.ResponseWriter, id string) error {
+func GetActorFollowing(ctx *fiber.Ctx, id string) error {
var following Collection
var err error
@@ -378,8 +378,8 @@ func GetActorFollowing(w http.ResponseWriter, id string) error {
}
enc, _ := json.MarshalIndent(following, "", "\t")
- w.Header().Set("Content-Type", config.ActivityStreams)
- _, err = w.Write(enc)
+ ctx.Response().Header.Set("Content-Type", config.ActivityStreams)
+ _, err = ctx.Write(enc)
return err
}
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
+}