From a81cf01844b7128b1bd1aaf61e27a58fd3a10b7f Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Thu, 1 Oct 2020 13:18:05 -0400 Subject: [PATCH] fix for external attachments not having xid anymore --- database.go | 1 + honk.go | 17 ++++++++++------- views/honk.html | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/database.go b/database.go index d1c11dd..dd1176e 100644 --- a/database.go +++ b/database.go @@ -401,6 +401,7 @@ func donksforhonks(honks []*Honk) { log.Printf("error scanning donk: %s", err) continue } + d.External = !strings.HasPrefix(d.URL, serverPrefix) h := hmap[hid] h.Donks = append(h.Donks, d) } diff --git a/honk.go b/honk.go index e741e18..ea2ceac 100644 --- a/honk.go +++ b/honk.go @@ -156,13 +156,14 @@ func (honk *Honk) IsReacted() bool { } type Donk struct { - FileID int64 - XID string - Name string - Desc string - URL string - Media string - Local bool + FileID int64 + XID string + Name string + Desc string + URL string + Media string + Local bool + External bool } type Place struct { @@ -231,6 +232,7 @@ const ( ) var serverName string +var serverPrefix string var masqName string var dataDir = "." var viewDir = "." @@ -281,6 +283,7 @@ func main() { if masqName == "" { masqName = serverName } + serverPrefix = fmt.Sprintf("https://%s/", serverName) getconfig("usersep", &userSep) getconfig("honksep", &honkSep) getconfig("debug", &debugMode) diff --git a/views/honk.html b/views/honk.html index 436dc74..4c1d196 100644 --- a/views/honk.html +++ b/views/honk.html @@ -78,7 +78,7 @@ in reply to: {{ .RID }} {{ end }} {{ end }} {{ else }} -{{ if .XID }} +{{ if .External }}

External Attachment: {{ .Name }}{{ if not (eq .Desc .Name) }} {{ .Desc }}{{ end }} {{ else }} {{ if eq .Media "video/mp4" }}