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 = ""
|
||||
|
||||
# stupid hack to trick discord lmao
|
||||
if id.find("_") != -1:
|
||||
let parts = id.split("_")
|
||||
id = parts[0]
|
||||
query = parts[1]
|
||||
if id.startsWith("422209040515"):
|
||||
query = "video"
|
||||
id.removePrefix("422209040515")
|
||||
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):
|
||||
resp Http404, {"Content-Type": "application/json"}, """{"error":"Invalid record ID"}"""
|
||||
@ -215,10 +219,14 @@ proc createActivityPubRouter*(cfg: Config) =
|
||||
query = ""
|
||||
|
||||
# stupid hack to trick discord lmao
|
||||
if id.find("_") != -1:
|
||||
let parts = id.split("_")
|
||||
id = parts[0]
|
||||
query = parts[1]
|
||||
if id.startsWith("422209040515"):
|
||||
query = "video"
|
||||
id.removePrefix("422209040515")
|
||||
elif id.startsWith("421608152015"):
|
||||
query = "photo:"
|
||||
id.removePrefix("421608152015")
|
||||
query &= id[0]
|
||||
id = id[1..^1]
|
||||
|
||||
var
|
||||
mediaType = ""
|
||||
|
||||
@ -167,9 +167,17 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
||||
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")
|
||||
|
||||
var fediUrl = &"{getUrlPrefix(cfg)}/users/i/statuses/{id}"
|
||||
var fediUrl = &"{getUrlPrefix(cfg)}/users/i/statuses/"
|
||||
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")
|
||||
|
||||
# this is last so images are also preloaded
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user