diff options
author | FChannel <> | 2021-07-23 22:45:44 -0700 |
---|---|---|
committer | FChannel <> | 2021-07-23 22:45:44 -0700 |
commit | 8f7386f2906716d40099fb50f029d48796dd1bbd (patch) | |
tree | 790b290434220a94e384eb8970d26dea1967e6f9 /database.go | |
parent | c5eff11c39d0a07f5cb7401835d04ba4df9edcbf (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.go | 12 |
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) |