attempt to fix a weird edge case with replies
This commit is contained in:
parent
7a6548cb2b
commit
38f2ede5c0
@ -53,10 +53,10 @@ proc createActivityPubRouter*(cfg: Config) =
|
|||||||
mediaObj["type"] = %"image"
|
mediaObj["type"] = %"image"
|
||||||
mediaObj["url"] = %image
|
mediaObj["url"] = %image
|
||||||
mediaObj["preview_url"] = %image
|
mediaObj["preview_url"] = %image
|
||||||
mediaObj["remote_url"] = newJNull()
|
mediaObj["remote_url"] = %image
|
||||||
mediaObj["preview_remote_url"] = newJNull()
|
mediaObj["preview_remote_url"] = %image
|
||||||
mediaObj["text_url"] = newJNull()
|
mediaObj["text_url"] = newJNull()
|
||||||
mediaObj["description"] = newJNull() # FIXME (not used by discord, i like a11y)
|
mediaObj["description"] = newJNull() # FIXME this requires refactoring images
|
||||||
# FIXME but this probably isnt used by discord
|
# FIXME but this probably isnt used by discord
|
||||||
mediaObj["meta"] = newJObject()
|
mediaObj["meta"] = newJObject()
|
||||||
|
|
||||||
@ -66,32 +66,40 @@ proc createActivityPubRouter*(cfg: Config) =
|
|||||||
let
|
let
|
||||||
videoObj = get(tweet.video)
|
videoObj = get(tweet.video)
|
||||||
vars = videoObj.variants.filterIt(it.contentType == mp4)
|
vars = videoObj.variants.filterIt(it.contentType == mp4)
|
||||||
|
videoUrl = vars[^1].url
|
||||||
|
videoPreview = getUrlPrefix(cfg) & getPicUrl(videoObj.thumb)
|
||||||
var mediaObj = newJObject()
|
var mediaObj = newJObject()
|
||||||
|
var description = videoObj.title
|
||||||
|
if videoObj.description.len > 0:
|
||||||
|
description = videoObj.description
|
||||||
|
|
||||||
mediaObj["id"] = %"150745989836308480"
|
mediaObj["id"] = %"150745989836308480"
|
||||||
mediaObj["type"] = %"video"
|
mediaObj["type"] = %"video"
|
||||||
mediaObj["url"] = %vars[^1].url
|
mediaObj["url"] = %videoUrl
|
||||||
mediaObj["preview_url"] = %(getUrlPrefix(cfg) & getPicUrl(videoObj.thumb))
|
mediaObj["preview_url"] = %videoPreview
|
||||||
mediaObj["remote_url"] = newJNull()
|
mediaObj["remote_url"] = %videoUrl
|
||||||
mediaObj["preview_remote_url"] = newJNull()
|
mediaObj["preview_remote_url"] = %videoPreview
|
||||||
mediaObj["text_url"] = newJNull()
|
mediaObj["text_url"] = newJNull()
|
||||||
mediaObj["description"] = newJNull() # FIXME (not used by discord, i like a11y)
|
mediaObj["description"] = %description
|
||||||
# FIXME but this probably isnt used by discord
|
# FIXME but this probably isnt used by discord
|
||||||
mediaObj["meta"] = newJObject()
|
mediaObj["meta"] = newJObject()
|
||||||
|
|
||||||
media.add(mediaObj)
|
media.add(mediaObj)
|
||||||
elif tweet.gif.isSome():
|
elif tweet.gif.isSome():
|
||||||
let gif = get(tweet.gif)
|
let
|
||||||
|
gif = get(tweet.gif)
|
||||||
|
gifUrl = getUrlPrefix(cfg) & getPicUrl(gif.url)
|
||||||
|
gifPreview = getUrlPrefix(cfg) & getPicUrl(gif.thumb)
|
||||||
var mediaObj = newJObject()
|
var mediaObj = newJObject()
|
||||||
|
|
||||||
mediaObj["id"] = %"150745989836308480"
|
mediaObj["id"] = %"150745989836308480"
|
||||||
mediaObj["type"] = %"video"
|
mediaObj["type"] = %"video"
|
||||||
mediaObj["url"] = %(&"https://{gif.url}")
|
mediaObj["url"] = %gifUrl
|
||||||
mediaObj["preview_url"] = %(getUrlPrefix(cfg) & getPicUrl(gif.thumb))
|
mediaObj["preview_url"] = %gifPreview
|
||||||
mediaObj["remote_url"] = newJNull()
|
mediaObj["remote_url"] = %gifUrl
|
||||||
mediaObj["preview_remote_url"] = newJNull()
|
mediaObj["preview_remote_url"] = %gifPreview
|
||||||
mediaObj["text_url"] = newJNull()
|
mediaObj["text_url"] = newJNull()
|
||||||
mediaObj["description"] = newJNull() # FIXME (not used by discord, i like a11y)
|
mediaObj["description"] = newJNull() # FIXME this requires refactoring gifs
|
||||||
# FIXME but this probably isnt used by discord
|
# FIXME but this probably isnt used by discord
|
||||||
mediaObj["meta"] = newJObject()
|
mediaObj["meta"] = newJObject()
|
||||||
|
|
||||||
@ -105,8 +113,9 @@ proc createActivityPubRouter*(cfg: Config) =
|
|||||||
postJson["edited_at"] = newJNull()
|
postJson["edited_at"] = newJNull()
|
||||||
postJson["reblog"] = newJNull()
|
postJson["reblog"] = newJNull()
|
||||||
if tweet.replyId != 0:
|
if tweet.replyId != 0:
|
||||||
|
let replyUser = await getGraphUser(tweet.replyHandle)
|
||||||
postJson["in_reply_to_id"] = %(&"{tweet.replyId}")
|
postJson["in_reply_to_id"] = %(&"{tweet.replyId}")
|
||||||
postJson["in_reply_to_account_id"] = %""
|
postJson["in_reply_to_account_id"] = %replyUser.id
|
||||||
else:
|
else:
|
||||||
postJson["in_reply_to_id"] = newJNull()
|
postJson["in_reply_to_id"] = newJNull()
|
||||||
postJson["in_reply_to_account_id"] = newJNull()
|
postJson["in_reply_to_account_id"] = newJNull()
|
||||||
|
|||||||
@ -59,12 +59,14 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
|||||||
script(src="/js/baguetteBox.min.js", `async`="")
|
script(src="/js/baguetteBox.min.js", `async`="")
|
||||||
script(src="/js/zoom.js")
|
script(src="/js/zoom.js")
|
||||||
|
|
||||||
|
let isDiscord = req.headers.getOrDefault("User-Agent").toString().contains("Discordbot")
|
||||||
|
|
||||||
if theme.len > 0:
|
if theme.len > 0:
|
||||||
link(rel="stylesheet", type="text/css", href=(&"/css/themes/{theme}.css"))
|
link(rel="stylesheet", type="text/css", href=(&"/css/themes/{theme}.css"))
|
||||||
|
|
||||||
link(rel="icon", type="image/png", sizes="32x32", href=(&"{getUrlPrefix(cfg)}/favicon-32x32.png"))
|
link(rel="icon", type="image/png", sizes="32x32", href=(&"{getUrlPrefix(cfg)}/favicon-32x32.png"))
|
||||||
link(rel="icon", type="image/png", sizes="16x16", href=(&"{getUrlPrefix(cfg)}/favicon-16x16.png"))
|
link(rel="icon", type="image/png", sizes="16x16", href=(&"{getUrlPrefix(cfg)}/favicon-16x16.png"))
|
||||||
link(rel="apple-touch-icon", sizes="180x180", href="/apple-touch-icon.png")
|
link(rel="apple-touch-icon", sizes="180x180", href="/apple-touch-icon.png?v=2")
|
||||||
link(rel="manifest", href="/site.webmanifest")
|
link(rel="manifest", href="/site.webmanifest")
|
||||||
link(rel="mask-icon", href="/safari-pinned-tab.svg", color="#ff6c60")
|
link(rel="mask-icon", href="/safari-pinned-tab.svg", color="#ff6c60")
|
||||||
link(rel="search", type="application/opensearchdescription+xml", title=cfg.title,
|
link(rel="search", type="application/opensearchdescription+xml", title=cfg.title,
|
||||||
@ -103,9 +105,6 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
|
|||||||
meta(property="og:locale", content="en_US")
|
meta(property="og:locale", content="en_US")
|
||||||
|
|
||||||
var siteName = "Nitter"
|
var siteName = "Nitter"
|
||||||
|
|
||||||
let isDiscord = req.headers.getOrDefault("User-Agent").toString().contains("Discordbot")
|
|
||||||
|
|
||||||
if time.isSome and not isDiscord:
|
if time.isSome and not isDiscord:
|
||||||
let timeObj = time.get
|
let timeObj = time.get
|
||||||
let timeStr = $timeObj
|
let timeStr = $timeObj
|
||||||
|
|||||||
@ -39,11 +39,13 @@ proc getActivityStream*(tweet: Tweet, cfg: Config, prefs: Prefs): JsonNode =
|
|||||||
|
|
||||||
if tweet.photos.len > 0:
|
if tweet.photos.len > 0:
|
||||||
for url in tweet.photos:
|
for url in tweet.photos:
|
||||||
let image = getUrlPrefix(cfg) & getPicUrl(url)
|
let
|
||||||
var mediaObj = newJObject()
|
image = getUrlPrefix(cfg) & getPicUrl(url)
|
||||||
|
splitUrl = url.split('.')
|
||||||
|
|
||||||
|
var mediaObj = newJObject()
|
||||||
mediaObj["type"] = %"Document"
|
mediaObj["type"] = %"Document"
|
||||||
mediaObj["mediaType"] = %"image/png"
|
mediaObj["mediaType"] = %("image/" & splitUrl[^1])
|
||||||
mediaObj["url"] = %image
|
mediaObj["url"] = %image
|
||||||
mediaObj["name"] = newJNull() # FIXME a11y
|
mediaObj["name"] = newJNull() # FIXME a11y
|
||||||
|
|
||||||
@ -53,21 +55,26 @@ proc getActivityStream*(tweet: Tweet, cfg: Config, prefs: Prefs): JsonNode =
|
|||||||
let
|
let
|
||||||
videoObj = get(tweet.video)
|
videoObj = get(tweet.video)
|
||||||
vars = videoObj.variants.filterIt(it.contentType == mp4)
|
vars = videoObj.variants.filterIt(it.contentType == mp4)
|
||||||
var mediaObj = newJObject()
|
var description = videoObj.title
|
||||||
|
if videoObj.description.len > 0:
|
||||||
|
description = videoObj.description
|
||||||
|
|
||||||
|
var mediaObj = newJObject()
|
||||||
mediaObj["type"] = %"Document"
|
mediaObj["type"] = %"Document"
|
||||||
mediaObj["mediaType"] = %"video/mp4"
|
mediaObj["mediaType"] = %"video/mp4"
|
||||||
mediaObj["url"] = %vars[^1].url
|
mediaObj["url"] = %vars[^1].url
|
||||||
mediaObj["name"] = newJNull() # FIXME a11y
|
mediaObj["name"] = %description
|
||||||
|
|
||||||
media.add(mediaObj)
|
media.add(mediaObj)
|
||||||
elif tweet.gif.isSome():
|
elif tweet.gif.isSome():
|
||||||
let gif = get(tweet.gif)
|
let
|
||||||
var mediaObj = newJObject()
|
gif = get(tweet.gif)
|
||||||
|
gifUrl = getUrlPrefix(cfg) & getPicUrl(gif.url)
|
||||||
|
|
||||||
|
var mediaObj = newJObject()
|
||||||
mediaObj["type"] = %"Document"
|
mediaObj["type"] = %"Document"
|
||||||
mediaObj["mediaType"] = %"video/mp4"
|
mediaObj["mediaType"] = %"video/mp4"
|
||||||
mediaObj["url"] = %(&"https://{gif.url}")
|
mediaObj["url"] = %gifUrl
|
||||||
mediaObj["name"] = newJNull() # FIXME a11y
|
mediaObj["name"] = newJNull() # FIXME a11y
|
||||||
|
|
||||||
media.add(mediaObj)
|
media.add(mediaObj)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user