aboutsummaryrefslogtreecommitdiff
path: root/database.go
diff options
context:
space:
mode:
authorFChannel <>2021-07-23 22:45:44 -0700
committerFChannel <>2021-07-23 22:45:44 -0700
commit8f7386f2906716d40099fb50f029d48796dd1bbd (patch)
tree790b290434220a94e384eb8970d26dea1967e6f9 /database.go
parentc5eff11c39d0a07f5cb7401835d04ba4df9edcbf (diff)
added cross post support. could blow up if referencing a link that is not local to the database or cache.
Diffstat (limited to 'database.go')
-rw-r--r--database.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/database.go b/database.go
index 3a20cb4..3d3f9ff 100644
--- a/database.go
+++ b/database.go
@@ -6,6 +6,7 @@ import (
"os"
"sort"
"strings"
+ "regexp"
"time"
"html/template"
@@ -558,7 +559,16 @@ func GetObjectFromDBFromID(db *sql.DB, id string) Collection {
var nColl Collection
var result []ObjectBase
- query := `select x.id, x.name, x.content, x.type, x.published, x.updated, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode, x.sensitive from (select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where id=$1 and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from cacheactivitystream where id=$1 and type='Note') as x order by x.updated`
+ query := `select x.id, x.name, x.content, x.type, x.published, x.updated, x.attributedto, x.attachment, x.preview, x.actor, x.tripcode, x.sensitive from (select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from activitystream where id like $1 and type='Note' union select id, name, content, type, published, updated, attributedto, attachment, preview, actor, tripcode, sensitive from cacheactivitystream where id like $1 and type='Note') as x order by x.updated`
+
+ re := regexp.MustCompile(`f(\w+)\-`)
+ match := re.FindStringSubmatch(id)
+
+ if len(match) > 0 {
+ re := regexp.MustCompile(`(.+)\-`)
+ id = re.ReplaceAllString(id, "")
+ id = "%" + match[1] + "/" + id
+ }
rows, err := db.Query(query, id)