From 2667ec93ce0bc3c6651a7c17a23a66568a9bc18b Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sat, 20 Apr 2024 05:06:28 +0400 Subject: [PATCH] Made full use of Service* constants in util. --- internal/http/web_handlers.go | 6 +++--- pkg/mindflow/mindflow.go | 4 ++-- pkg/util/util.go | 32 ++++++++++++++++---------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/http/web_handlers.go b/internal/http/web_handlers.go index 58b0b8b..ac3e5fe 100644 --- a/internal/http/web_handlers.go +++ b/internal/http/web_handlers.go @@ -42,9 +42,9 @@ func (h *Handlers) Index(w http.ResponseWriter, r *http.Request) { func (h *Handlers) Privacy(w http.ResponseWriter, r *http.Request) { web.Privacy("/ Privacy statements", - util.GetServiceByHost(r.Host, "radio"), - util.GetServiceByHost(r.Host, "files"), - util.GetServiceByHost(r.Host, "upload"), w) + util.GetServiceByHost(r.Host, util.ServiceRadio), + util.GetServiceByHost(r.Host, util.ServiceRadio), + util.GetServiceByHost(r.Host, util.ServiceUpload), w) } func (h *Handlers) Stuff(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/mindflow/mindflow.go b/pkg/mindflow/mindflow.go index 2e97839..efae1a9 100644 --- a/pkg/mindflow/mindflow.go +++ b/pkg/mindflow/mindflow.go @@ -56,10 +56,10 @@ func (p *Post) PostURL(host string, rss bool) string { return strings.Replace(p.URL, p.URL[:lastColon+2], util.GetServiceByHost(host, service), 1) } else if rss && p.URL[0] == '/' { - return util.GetServiceByHost(host, "") + p.URL + return util.GetServiceByHost(host, util.ServiceHome) + p.URL } } else if p.URL == "" && rss { - return util.GetServiceByHost(host, "") + "/mindflow#" + p.PostID() + return util.GetServiceByHost(host, util.ServiceHome) + "/mindflow#" + p.PostID() } return p.URL } diff --git a/pkg/util/util.go b/pkg/util/util.go index fa4d7e4..1f5352e 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -19,52 +19,52 @@ const ( func GetServiceByHost(host, service string) string { if strings.HasSuffix(host, "i2p") { switch service { - case "radio": + case ServiceRadio: return "http://radio.arav.i2p" - case "files": + case ServiceFiles: return "http://files.arav.i2p" - case "upload": + case ServiceUpload: return "http://upload.arav.i2p" - case "git": + case ServiceGit: return "http://git.arav.i2p" default: return "http://arav.i2p" } } else if strings.HasPrefix(host, "[300") { switch service { - case "radio": + case ServiceRadio: return "http://[300:a98d:d6d0:8a08::e]" - case "files": + case ServiceFiles: return "http://[300:a98d:d6d0:8a08::d]" - case "upload": + case ServiceUpload: return "http://[300:a98d:d6d0:8a08::c]" - case "git": + case ServiceGit: return "http://[300:a98d:d6d0:8a08::b]" default: return "http://[300:a98d:d6d0:8a08::f]" } } else if strings.HasSuffix(host, "onion") { switch service { - case "radio": + case ServiceRadio: return "http://wsmkgnmhmzqm7kyzv7jnzzafvgm7xlmlfvzhgorpapd5or2arnhuktqd.onion" - case "files": + case ServiceFiles: return "http://qf5e43nlhvnrutmikuvbdfj3cmtthokpbaxtkm6mjlslttzvtgm4fxid.onion" - case "upload": + case ServiceUpload: return "http://4usftbmjpfexkr2x5xbp5ukmygpmg4fgrnx2wbifsexqctooz5hmviyd.onion" - case "git": + case ServiceGit: return "http://qqitm7qlsbbubwmjos4cqzmvkqidg34rfnbyhuydhalep33fbvh22xyd.onion" default: return "http://moq7aejnf4xk5k2bkaltli3ftkhusy2mbrd3pj23nrca343ku2mgk4yd.onion" } } else { switch service { - case "radio": + case ServiceRadio: return "https://radio.arav.su" - case "files": + case ServiceFiles: return "https://files.arav.su" - case "upload": + case ServiceUpload: return "https://upload.arav.su" - case "git": + case ServiceGit: return "https://git.arav.su" default: return "https://arav.su"