From 8f7386f2906716d40099fb50f029d48796dd1bbd Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Fri, 23 Jul 2021 22:45:44 -0700 Subject: added cross post support. could blow up if referencing a link that is not local to the database or cache. --- database.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'database.go') 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) -- cgit v1.2.3