mastoapi: fields for AS response, add verified and pcf fields
This commit is contained in:
parent
d3d6558913
commit
1834742bb9
@ -200,6 +200,43 @@ proc getActivityStream*(user: User, cfg: Config, prefs: Prefs): JsonNode =
|
|||||||
asProps["movedTo"] = contextMovedTo
|
asProps["movedTo"] = contextMovedTo
|
||||||
context.add(asProps)
|
context.add(asProps)
|
||||||
|
|
||||||
|
var fields: seq[JsonNode] = @[]
|
||||||
|
|
||||||
|
if user.location.len > 0:
|
||||||
|
var location = newJObject()
|
||||||
|
location["type"] = %"PropertyValue"
|
||||||
|
location["name"] = %"Location"
|
||||||
|
location["value"] = %user.location
|
||||||
|
fields.add(location)
|
||||||
|
|
||||||
|
if user.website.len > 0:
|
||||||
|
var website = newJObject()
|
||||||
|
website["type"] = %"PropertyValue"
|
||||||
|
website["name"] = %"Website"
|
||||||
|
website["value"] = %(&"<a href=\"{user.website}\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no\">{user.website}</a>")
|
||||||
|
fields.add(website)
|
||||||
|
|
||||||
|
if user.botOwner.len > 0:
|
||||||
|
var botOwner = newJObject()
|
||||||
|
botOwner["type"] = %"PropertyValue"
|
||||||
|
botOwner["name"] = %"Automated by"
|
||||||
|
botOwner["value"] = %(&"<a href=\"{getUrlPrefix(cfg)}/{user.botOwner}\" translate=\"no\">{user.botOwner}</a>")
|
||||||
|
fields.add(botOwner)
|
||||||
|
|
||||||
|
if user.pcf != "" and user.pcf != "None":
|
||||||
|
var pcf = newJObject()
|
||||||
|
pcf["type"] = %"PropertyValue"
|
||||||
|
pcf["name"] = %"PCF Label"
|
||||||
|
pcf["value"] = %user.pcf
|
||||||
|
fields.add(pcf)
|
||||||
|
|
||||||
|
if user.verifiedType != none:
|
||||||
|
var verified = newJObject()
|
||||||
|
verified["type"] = %"PropertyValue"
|
||||||
|
verified["name"] = %"Verified Type"
|
||||||
|
verified["value"] = %user.verifiedType
|
||||||
|
fields.add(verified)
|
||||||
|
|
||||||
var userJson = newJObject()
|
var userJson = newJObject()
|
||||||
userJson["@context"] = %context
|
userJson["@context"] = %context
|
||||||
userJson["id"] = %userUrl
|
userJson["id"] = %userUrl
|
||||||
@ -221,7 +258,7 @@ proc getActivityStream*(user: User, cfg: Config, prefs: Prefs): JsonNode =
|
|||||||
userJson["memorial"] = %false
|
userJson["memorial"] = %false
|
||||||
userJson["publicKey"] = newJNull()
|
userJson["publicKey"] = newJNull()
|
||||||
userJson["tag"] = newJArray()
|
userJson["tag"] = newJArray()
|
||||||
userJson["attachment"] = newJArray()
|
userJson["attachment"] = %fields
|
||||||
userJson["endpoints"] = newJObject()
|
userJson["endpoints"] = newJObject()
|
||||||
userJson["icon"] = %*{
|
userJson["icon"] = %*{
|
||||||
"type": "Image",
|
"type": "Image",
|
||||||
@ -260,6 +297,20 @@ proc getMastoAPIUser*(user: User, cfg: Config): JsonNode =
|
|||||||
botOwner["verified_at"] = newJNull()
|
botOwner["verified_at"] = newJNull()
|
||||||
fields.add(botOwner)
|
fields.add(botOwner)
|
||||||
|
|
||||||
|
if user.pcf != "" and user.pcf != "None":
|
||||||
|
var pcf = newJObject()
|
||||||
|
pcf["name"] = %"PCF Label"
|
||||||
|
pcf["value"] = %user.pcf
|
||||||
|
pcf["verified_at"] = newJNull()
|
||||||
|
fields.add(pcf)
|
||||||
|
|
||||||
|
if user.verifiedType != none:
|
||||||
|
var verified = newJObject()
|
||||||
|
verified["name"] = %"Verified Type"
|
||||||
|
verified["value"] = %user.verifiedType
|
||||||
|
verified["verified_at"] = newJNull()
|
||||||
|
fields.add(verified)
|
||||||
|
|
||||||
var userJson = newJObject()
|
var userJson = newJObject()
|
||||||
userJson["id"] = %user.id
|
userJson["id"] = %user.id
|
||||||
userJson["username"] = %user.username
|
userJson["username"] = %user.username
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user