automation labels
This commit is contained in:
parent
536f9d7fab
commit
f76cfcc154
@ -30,8 +30,6 @@ proc parseUser(js: JsonNode; id=""): User =
|
||||
result.expandUserEntities(js)
|
||||
|
||||
proc parseGraphUser*(js: JsonNode): User =
|
||||
echo "node: ", $js
|
||||
|
||||
var user = js{"data", "user", "result"}
|
||||
if user.isNull:
|
||||
user = js{"user_results", "result"}
|
||||
@ -40,6 +38,16 @@ proc parseGraphUser*(js: JsonNode): User =
|
||||
|
||||
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):
|
||||
result.verifiedType = blue
|
||||
|
||||
|
||||
@ -128,6 +128,14 @@ proc getTweetById*(id: string; after=""): Future[string] {.async.} =
|
||||
params = {"variables": variables, "features": gqlFeatures}
|
||||
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) =
|
||||
router api:
|
||||
get "/api/echo":
|
||||
@ -135,8 +143,8 @@ proc createTwitterApiRouter*(cfg: Config) =
|
||||
|
||||
get "/api/user/@username":
|
||||
let username = @"username"
|
||||
let response = await getUserProfileJson(username)
|
||||
respJson response
|
||||
let response = await getUser(username)
|
||||
resp Http200, { "Content-Type": "application/json" }, response
|
||||
|
||||
#get "/api/user/@id/tweets":
|
||||
# let id = @"id"
|
||||
|
||||
@ -82,7 +82,8 @@
|
||||
|
||||
.profile-joindate,
|
||||
.profile-location,
|
||||
.profile-website {
|
||||
.profile-website,
|
||||
.profile-automated {
|
||||
color: var(--fg_faded);
|
||||
margin: 1px 0;
|
||||
width: 100%;
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
@import '_variables';
|
||||
@import '_mixins';
|
||||
@import 'thread';
|
||||
@import 'media';
|
||||
@import 'video';
|
||||
@import 'embed';
|
||||
@import 'card';
|
||||
@import 'poll';
|
||||
@import 'quote';
|
||||
@import 'community_note';
|
||||
@import "_variables";
|
||||
@import "_mixins";
|
||||
@import "thread";
|
||||
@import "media";
|
||||
@import "video";
|
||||
@import "embed";
|
||||
@import "card";
|
||||
@import "poll";
|
||||
@import "quote";
|
||||
@import "community_note";
|
||||
|
||||
.tweet-body {
|
||||
flex: 1;
|
||||
@ -32,7 +32,7 @@
|
||||
padding: 0;
|
||||
vertical-align: bottom;
|
||||
flex-basis: 100%;
|
||||
margin-bottom: .2em;
|
||||
margin-bottom: 0.2em;
|
||||
|
||||
a {
|
||||
display: inline-block;
|
||||
@ -65,17 +65,26 @@
|
||||
.username {
|
||||
@include ellipsis;
|
||||
min-width: 1.6em;
|
||||
margin-left: .4em;
|
||||
margin-left: 0.4em;
|
||||
word-wrap: normal;
|
||||
}
|
||||
|
||||
.user-automated {
|
||||
@include ellipsis;
|
||||
min-width: 1px;
|
||||
margin-left: 0.4em;
|
||||
color: var(--fg_faded);
|
||||
}
|
||||
|
||||
.tweet-date {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.tweet-date a, .username, .show-more a {
|
||||
.tweet-date a,
|
||||
.username,
|
||||
.show-more a {
|
||||
color: var(--fg_dark);
|
||||
}
|
||||
|
||||
@ -158,7 +167,8 @@
|
||||
padding-right: 2px;
|
||||
}
|
||||
|
||||
.media-tag, .icon-container {
|
||||
.media-tag,
|
||||
.icon-container {
|
||||
color: var(--fg_faded);
|
||||
}
|
||||
}
|
||||
@ -180,7 +190,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
.retweet-header, .pinned, .tweet-stats {
|
||||
.retweet-header,
|
||||
.pinned,
|
||||
.tweet-stats {
|
||||
align-content: center;
|
||||
color: var(--grey);
|
||||
display: flex;
|
||||
|
||||
@ -99,6 +99,8 @@ type
|
||||
protected*: bool
|
||||
suspended*: bool
|
||||
joinDate*: DateTime
|
||||
bot*: bool
|
||||
botOwner*: string
|
||||
|
||||
VideoType* = enum
|
||||
m3u8 = "application/x-mpegURL"
|
||||
|
||||
@ -221,13 +221,18 @@ proc getMastoAPIUser*(user: User, cfg: Config): JsonNode =
|
||||
website["verified_at"] = newJNull()
|
||||
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()
|
||||
userJson["id"] = %user.id
|
||||
userJson["username"] = %user.username
|
||||
userJson["acct"] = %user.username
|
||||
userJson["display_name"] = %user.fullname
|
||||
userJson["locked"] = %user.protected
|
||||
userJson["bot"] = %false # TODO?
|
||||
userJson["bot"] = %user.bot
|
||||
userJson["discoverable"] = %true
|
||||
userJson["indexable"] = %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"
|
||||
|
||||
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:
|
||||
tdiv(class="profile-bio"):
|
||||
p(dir="auto"):
|
||||
|
||||
@ -34,6 +34,8 @@ proc renderHeader(tweet: Tweet; retweet: string; pinned: bool; prefs: Prefs): VN
|
||||
tdiv(class="fullname-and-username"):
|
||||
linkUser(tweet.user, class="fullname")
|
||||
linkUser(tweet.user, class="username")
|
||||
if tweet.user.bot:
|
||||
tdiv(class="user-automated"): icon "cog", "Automated"
|
||||
|
||||
span(class="tweet-date"):
|
||||
a(href=getLink(tweet), title=tweet.getTime):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user