diff options
author | FChannel <> | 2022-05-06 22:45:27 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 39012c6b17073f6933a5ead8beed64df555f7348 (patch) | |
tree | 7784d092fe196a9051c81cf6833997607ad2d268 /db/database.go | |
parent | af542e339e5a611d2a1b5876450bee841b577640 (diff) |
converting functions to activitypub object functions
Diffstat (limited to 'db/database.go')
-rw-r--r-- | db/database.go | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/db/database.go b/db/database.go index eb0bb98..4c97fe5 100644 --- a/db/database.go +++ b/db/database.go @@ -388,7 +388,7 @@ func IsInactiveTimestamp(timeStamp string) bool { func ArchivePosts(actor activitypub.Actor) error { if actor.Id != "" && actor.Id != config.Domain { - col, err := activitypub.GetAllActorArchiveDB(actor.Id, 165) + col, err := actor.GetAllArchive(165) if err != nil { return err } @@ -409,27 +409,6 @@ func ArchivePosts(actor activitypub.Actor) error { return nil } -func UnArchiveLast(actorId string) error { - col, err := activitypub.GetActorCollectionDBTypeLimit(actorId, "Archive", 1) - if err != nil { - return err - } - - for _, e := range col.OrderedItems { - for _, k := range e.Replies.OrderedItems { - if err := activitypub.UpdateObjectTypeDB(k.Id, "Note"); err != nil { - return err - } - } - - if err := activitypub.UpdateObjectTypeDB(e.Id, "Note"); err != nil { - return err - } - } - - return nil -} - func IsReplyInThread(inReplyTo string, id string) (bool, error) { obj, _, err := webfinger.CheckValidActivity(inReplyTo) if err != nil { @@ -628,17 +607,19 @@ func GetActorReported(w http.ResponseWriter, r *http.Request, id string) error { return err } + actor, _ := activitypub.GetActorFromDB(id) + var following activitypub.Collection var err error following.AtContext.Context = "https://www.w3.org/ns/activitystreams" following.Type = "Collection" - following.TotalItems, err = activitypub.GetActorReportedTotal(id) + following.TotalItems, err = actor.GetReportedTotal() if err != nil { return err } - following.Items, err = activitypub.GetActorReportedDB(id) + following.Items, err = actor.GetReported() if err != nil { return err } @@ -686,8 +667,8 @@ func DeleteObjectRequest(id string) error { return err } activity.Actor = &actor - - followers, err := activitypub.GetActorFollowDB(obj.Actor) + objActor, _ := webfinger.GetActor(obj.Actor) + followers, err := objActor.GetFollow() if err != nil { return err } @@ -696,7 +677,7 @@ func DeleteObjectRequest(id string) error { activity.To = append(activity.To, e.Id) } - following, err := activitypub.GetActorFollowingDB(obj.Actor) + following, err := objActor.GetFollowing() if err != nil { return err } @@ -727,7 +708,8 @@ func DeleteObjectAndRepliesRequest(id string) error { activity.Object = &obj.OrderedItems[0] - followers, err := activitypub.GetActorFollowDB(obj.OrderedItems[0].Actor) + objActor, _ := webfinger.GetActor(obj.OrderedItems[0].Actor) + followers, err := objActor.GetFollow() if err != nil { return err } @@ -735,7 +717,7 @@ func DeleteObjectAndRepliesRequest(id string) error { activity.To = append(activity.To, e.Id) } - following, err := activitypub.GetActorFollowingDB(obj.OrderedItems[0].Actor) + following, err := objActor.GetFollowing() if err != nil { return err } @@ -746,3 +728,18 @@ func DeleteObjectAndRepliesRequest(id string) error { return MakeActivityRequest(activity) } + +// root actor is used to follow remote feeds that are not local +//name, prefname, summary, auth requirements, restricted +func InitInstance() { + if config.InstanceName != "" { + if _, err := CreateNewBoardDB(*activitypub.CreateNewActor("", config.InstanceName, config.InstanceSummary, config.AuthReq, false)); err != nil { + //panic(err) + } + + if config.PublicIndexing == "true" { + // TODO: comment out later + //AddInstanceToIndex(config.Domain) + } + } +} |