Now with extra replies
All checks were successful
/ docker (push) Successful in 4m26s

This commit is contained in:
Melody Becker 2025-05-16 21:45:43 +02:00
parent c70928ec7b
commit 1b0c63a3b1

View file

@ -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 {