automation labels
This commit is contained in:
parent
536f9d7fab
commit
f76cfcc154
@ -30,8 +30,6 @@ proc parseUser(js: JsonNode; id=""): User =
|
|||||||
result.expandUserEntities(js)
|
result.expandUserEntities(js)
|
||||||
|
|
||||||
proc parseGraphUser*(js: JsonNode): User =
|
proc parseGraphUser*(js: JsonNode): User =
|
||||||
echo "node: ", $js
|
|
||||||
|
|
||||||
var user = js{"data", "user", "result"}
|
var user = js{"data", "user", "result"}
|
||||||
if user.isNull:
|
if user.isNull:
|
||||||
user = js{"user_results", "result"}
|
user = js{"user_results", "result"}
|
||||||
@ -40,6 +38,16 @@ proc parseGraphUser*(js: JsonNode): User =
|
|||||||
|
|
||||||
result = parseUser(user{"legacy"}, user{"rest_id"}.getStr)
|
result = parseUser(user{"legacy"}, user{"rest_id"}.getStr)
|
||||||
|
|
||||||
|
let label = user{"affiliates_highlighted_label", "label"}
|
||||||
|
if not label.isNull and label{"userLabelType"}.getStr == "AutomatedLabel":
|
||||||
|
result.bot = true
|
||||||
|
let entities = label{"longDescription", "entities"}
|
||||||
|
if not entities.isNull:
|
||||||
|
for ent in entities:
|
||||||
|
if ent{"ref", "type"}.getStr != "TimelineRichTextMention": continue
|
||||||
|
result.botOwner = ent{"ref", "screen_name"}.getStr
|
||||||
|
break
|
||||||
|
|
||||||
if result.verifiedType == VerifiedType.none and user{"is_blue_verified"}.getBool(false):
|
if result.verifiedType == VerifiedType.none and user{"is_blue_verified"}.getBool(false):
|
||||||
result.verifiedType = blue
|
result.verifiedType = blue
|
||||||
|
|
||||||
|
|||||||
@ -128,6 +128,14 @@ proc getTweetById*(id: string; after=""): Future[string] {.async.} =
|
|||||||
params = {"variables": variables, "features": gqlFeatures}
|
params = {"variables": variables, "features": gqlFeatures}
|
||||||
result = await fetchRaw(graphTweet ? params, Api.tweetDetail)
|
result = await fetchRaw(graphTweet ? params, Api.tweetDetail)
|
||||||
|
|
||||||
|
proc getUser*(username: string): Future[string] {.async.} =
|
||||||
|
if username.len == 0: return
|
||||||
|
let
|
||||||
|
variables = """{"screen_name":"$1"}""" % username
|
||||||
|
fieldToggles = """{"withAuxiliaryUserLabels":true}"""
|
||||||
|
params = {"variables": variables, "features": gqlFeatures, "fieldToggles": fieldToggles}
|
||||||
|
result = await fetchRaw(graphUser ? params, Api.userScreenName)
|
||||||
|
|
||||||
proc createTwitterApiRouter*(cfg: Config) =
|
proc createTwitterApiRouter*(cfg: Config) =
|
||||||
router api:
|
router api:
|
||||||
get "/api/echo":
|
get "/api/echo":
|
||||||
@ -135,8 +143,8 @@ proc createTwitterApiRouter*(cfg: Config) =
|
|||||||
|
|
||||||
get "/api/user/@username":
|
get "/api/user/@username":
|
||||||
let username = @"username"
|
let username = @"username"
|
||||||
let response = await getUserProfileJson(username)
|
let response = await getUser(username)
|
||||||
respJson response
|
resp Http200, { "Content-Type": "application/json" }, response
|
||||||
|
|
||||||
#get "/api/user/@id/tweets":
|
#get "/api/user/@id/tweets":
|
||||||
# let id = @"id"
|
# let id = @"id"
|
||||||
|
|||||||
@ -82,7 +82,8 @@
|
|||||||
|
|
||||||
.profile-joindate,
|
.profile-joindate,
|
||||||
.profile-location,
|
.profile-location,
|
||||||
.profile-website {
|
.profile-website,
|
||||||
|
.profile-automated {
|
||||||
color: var(--fg_faded);
|
color: var(--fg_faded);
|
||||||
margin: 1px 0;
|
margin: 1px 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
@import '_variables';
|
@import "_variables";
|
||||||
@import '_mixins';
|
@import "_mixins";
|
||||||
@import 'thread';
|
@import "thread";
|
||||||
@import 'media';
|
@import "media";
|
||||||
@import 'video';
|
@import "video";
|
||||||
@import 'embed';
|
@import "embed";
|
||||||
@import 'card';
|
@import "card";
|
||||||
@import 'poll';
|
@import "poll";
|
||||||
@import 'quote';
|
@import "quote";
|
||||||
@import 'community_note';
|
@import "community_note";
|
||||||
|
|
||||||
.tweet-body {
|
.tweet-body {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@ -32,7 +32,7 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
flex-basis: 100%;
|
flex-basis: 100%;
|
||||||
margin-bottom: .2em;
|
margin-bottom: 0.2em;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@ -65,17 +65,26 @@
|
|||||||
.username {
|
.username {
|
||||||
@include ellipsis;
|
@include ellipsis;
|
||||||
min-width: 1.6em;
|
min-width: 1.6em;
|
||||||
margin-left: .4em;
|
margin-left: 0.4em;
|
||||||
word-wrap: normal;
|
word-wrap: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user-automated {
|
||||||
|
@include ellipsis;
|
||||||
|
min-width: 1px;
|
||||||
|
margin-left: 0.4em;
|
||||||
|
color: var(--fg_faded);
|
||||||
|
}
|
||||||
|
|
||||||
.tweet-date {
|
.tweet-date {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tweet-date a, .username, .show-more a {
|
.tweet-date a,
|
||||||
|
.username,
|
||||||
|
.show-more a {
|
||||||
color: var(--fg_dark);
|
color: var(--fg_dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +167,8 @@
|
|||||||
padding-right: 2px;
|
padding-right: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-tag, .icon-container {
|
.media-tag,
|
||||||
|
.icon-container {
|
||||||
color: var(--fg_faded);
|
color: var(--fg_faded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +190,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.retweet-header, .pinned, .tweet-stats {
|
.retweet-header,
|
||||||
|
.pinned,
|
||||||
|
.tweet-stats {
|
||||||
align-content: center;
|
align-content: center;
|
||||||
color: var(--grey);
|
color: var(--grey);
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@ -99,6 +99,8 @@ type
|
|||||||
protected*: bool
|
protected*: bool
|
||||||
suspended*: bool
|
suspended*: bool
|
||||||
joinDate*: DateTime
|
joinDate*: DateTime
|
||||||
|
bot*: bool
|
||||||
|
botOwner*: string
|
||||||
|
|
||||||
VideoType* = enum
|
VideoType* = enum
|
||||||
m3u8 = "application/x-mpegURL"
|
m3u8 = "application/x-mpegURL"
|
||||||
|
|||||||
@ -221,13 +221,18 @@ proc getMastoAPIUser*(user: User, cfg: Config): JsonNode =
|
|||||||
website["verified_at"] = newJNull()
|
website["verified_at"] = newJNull()
|
||||||
fields.add(website)
|
fields.add(website)
|
||||||
|
|
||||||
|
if user.botOwner.len > 0:
|
||||||
|
var botOwner = newJObject()
|
||||||
|
botOwner["name"] = %"Automated by"
|
||||||
|
botOwner["value"] = %(&"<a href=\"{getUrlPrefix(cfg)}/{user.botOwner}\" translate=\"no\">{user.botOwner}</a>")
|
||||||
|
|
||||||
var userJson = newJObject()
|
var userJson = newJObject()
|
||||||
userJson["id"] = %user.id
|
userJson["id"] = %user.id
|
||||||
userJson["username"] = %user.username
|
userJson["username"] = %user.username
|
||||||
userJson["acct"] = %user.username
|
userJson["acct"] = %user.username
|
||||||
userJson["display_name"] = %user.fullname
|
userJson["display_name"] = %user.fullname
|
||||||
userJson["locked"] = %user.protected
|
userJson["locked"] = %user.protected
|
||||||
userJson["bot"] = %false # TODO?
|
userJson["bot"] = %user.bot
|
||||||
userJson["discoverable"] = %true
|
userJson["discoverable"] = %true
|
||||||
userJson["indexable"] = %false
|
userJson["indexable"] = %false
|
||||||
userJson["group"] = %false
|
userJson["group"] = %false
|
||||||
|
|||||||
@ -35,6 +35,15 @@ proc renderUserCard*(user: User; prefs: Prefs; path: string): VNode =
|
|||||||
buttonReferer "/unfollow/" & user.username, "Unfollow", path, "profile-card-follow-button"
|
buttonReferer "/unfollow/" & user.username, "Unfollow", path, "profile-card-follow-button"
|
||||||
|
|
||||||
tdiv(class="profile-card-extra"):
|
tdiv(class="profile-card-extra"):
|
||||||
|
if user.bot:
|
||||||
|
tdiv(class="profile-automated"):
|
||||||
|
span:
|
||||||
|
if user.botOwner.len > 0:
|
||||||
|
icon "cog", "Automated by "
|
||||||
|
a(href=(&"/{user.botOwner}")): text &"@{user.botOwner}"
|
||||||
|
else:
|
||||||
|
icon "cog", "Automated"
|
||||||
|
|
||||||
if user.bio.len > 0:
|
if user.bio.len > 0:
|
||||||
tdiv(class="profile-bio"):
|
tdiv(class="profile-bio"):
|
||||||
p(dir="auto"):
|
p(dir="auto"):
|
||||||
|
|||||||
@ -34,6 +34,8 @@ proc renderHeader(tweet: Tweet; retweet: string; pinned: bool; prefs: Prefs): VN
|
|||||||
tdiv(class="fullname-and-username"):
|
tdiv(class="fullname-and-username"):
|
||||||
linkUser(tweet.user, class="fullname")
|
linkUser(tweet.user, class="fullname")
|
||||||
linkUser(tweet.user, class="username")
|
linkUser(tweet.user, class="username")
|
||||||
|
if tweet.user.bot:
|
||||||
|
tdiv(class="user-automated"): icon "cog", "Automated"
|
||||||
|
|
||||||
span(class="tweet-date"):
|
span(class="tweet-date"):
|
||||||
a(href=getLink(tweet), title=tweet.getTime):
|
a(href=getLink(tweet), title=tweet.getTime):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user