less breaking and better way to transmit query params in ids
since discord will never have a fully compliant activitystream parser
This commit is contained in:
parent
a6412968fe
commit
4064bd5c11
@ -38,10 +38,14 @@ proc createActivityPubRouter*(cfg: Config) =
|
|||||||
query = ""
|
query = ""
|
||||||
|
|
||||||
# stupid hack to trick discord lmao
|
# stupid hack to trick discord lmao
|
||||||
if id.find("_") != -1:
|
if id.startsWith("422209040515"):
|
||||||
let parts = id.split("_")
|
query = "video"
|
||||||
id = parts[0]
|
id.removePrefix("422209040515")
|
||||||
query = parts[1]
|
elif id.startsWith("421608152015"):
|
||||||
|
query = "photo:"
|
||||||
|
id.removePrefix("421608152015")
|
||||||
|
query &= id[0]
|
||||||
|
id = id[1..^1]
|
||||||
|
|
||||||
if id.len > 19 or id.any(c => not c.isDigit):
|
if id.len > 19 or id.any(c => not c.isDigit):
|
||||||
resp Http404, {"Content-Type": "application/json"}, """{"error":"Invalid record ID"}"""
|
resp Http404, {"Content-Type": "application/json"}, """{"error":"Invalid record ID"}"""
|
||||||
@ -215,10 +219,14 @@ proc createActivityPubRouter*(cfg: Config) =
|
|||||||
query = ""
|
query = ""
|
||||||
|
|
||||||
# stupid hack to trick discord lmao
|
# stupid hack to trick discord lmao
|
||||||
if id.find("_") != -1:
|
if id.startsWith("422209040515"):
|
||||||
let parts = id.split("_")
|
query = "video"
|
||||||
id = parts[0]
|
id.removePrefix("422209040515")
|
||||||
query = parts[1]
|
elif id.startsWith("421608152015"):
|
||||||
|
query = "photo:"
|
||||||
|
id.removePrefix("421608152015")
|
||||||
|
query &= id[0]
|
||||||
|
id = id[1..^1]
|
||||||
|
|
||||||
var
|
var
|
||||||
mediaType = ""
|
mediaType = ""
|
||||||
|
|||||||
@ -167,9 +167,17 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
|||||||
author = encodeUrl(context)
|
author = encodeUrl(context)
|
||||||
link(rel="alternate", href=(&"{getUrlPrefix(cfg)}/oembed.json?type=video&provider={encodeUrl(siteName)}&title={title}&user={author}&url={encodeUrl(contextUrl)}"), type="application/json+oembed")
|
link(rel="alternate", href=(&"{getUrlPrefix(cfg)}/oembed.json?type=video&provider={encodeUrl(siteName)}&title={title}&user={author}&url={encodeUrl(contextUrl)}"), type="application/json+oembed")
|
||||||
|
|
||||||
var fediUrl = &"{getUrlPrefix(cfg)}/users/i/statuses/{id}"
|
var fediUrl = &"{getUrlPrefix(cfg)}/users/i/statuses/"
|
||||||
if media.len > 0:
|
if media.len > 0:
|
||||||
fediUrl &= "_" & media
|
if media == "video":
|
||||||
|
fediUrl &= "422209040515" # 42 + "video"
|
||||||
|
else:
|
||||||
|
let parts = media.split(":")
|
||||||
|
fediUrl &= "421608152015" # 42 + "photo"
|
||||||
|
if parts.len == 2:
|
||||||
|
fediUrl &= parts[1] # + index
|
||||||
|
|
||||||
|
fediUrl &= id
|
||||||
link(rel="alternate", href=fediUrl, type="application/activity+json")
|
link(rel="alternate", href=fediUrl, type="application/activity+json")
|
||||||
|
|
||||||
# this is last so images are also preloaded
|
# this is last so images are also preloaded
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user