From 1b0c63a3b111137fd8ff144e17e60c6d2a94fe93 Mon Sep 17 00:00:00 2001 From: mstar Date: Fri, 16 May 2025 21:45:43 +0200 Subject: [PATCH] Now with extra replies --- web/public/api/activitypub/inbox.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web/public/api/activitypub/inbox.go b/web/public/api/activitypub/inbox.go index 9f57266..8e6abe4 100644 --- a/web/public/api/activitypub/inbox.go +++ b/web/public/api/activitypub/inbox.go @@ -8,6 +8,7 @@ import ( "net/http" "regexp" "strconv" + "strings" "time" webutils "git.mstar.dev/mstar/goutils/http" @@ -17,6 +18,7 @@ import ( "gorm.io/gorm" "git.mstar.dev/mstar/linstrom/activitypub" + "git.mstar.dev/mstar/linstrom/config" "git.mstar.dev/mstar/linstrom/shared" "git.mstar.dev/mstar/linstrom/storage-new/dbgen" "git.mstar.dev/mstar/linstrom/storage-new/models" @@ -747,6 +749,16 @@ func handleCreate(w http.ResponseWriter, r *http.Request, object map[string]any) if objectNote.Summary != nil { dbNote.ContentWarning = sql.NullString{Valid: true, String: *objectNote.Summary} } + if objectNote.InReplyTo != nil { + replyUrl := *objectNote.InReplyTo + if strings.HasPrefix(replyUrl, config.GlobalConfig.General.GetFullPublicUrl()) { + // This is going to panic if the regex doesn't match. Who cares? Not me + id := objectIdRegex.FindStringSubmatch(replyUrl)[1] + dbNote.RepliesTo = sql.NullString{Valid: true, String: id} + } else { + dbNote.RepliesTo = sql.NullString{Valid: true, String: replyUrl} + } + } tx := dbgen.Q.Begin() err = tx.Note.Create(&dbNote) if err != nil {