This commit is contained in:
parent
c70928ec7b
commit
1b0c63a3b1
1 changed files with 12 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue