mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-24 03:43:42 -08:00
Reviewed-on: https://codeberg.org/rimu/pyfedi/pulls/114
This commit is contained in:
commit
40246fee1e
11 changed files with 42 additions and 5 deletions
|
@ -195,7 +195,7 @@ def user_profile(actor):
|
||||||
if is_activitypub_request():
|
if is_activitypub_request():
|
||||||
server = current_app.config['SERVER_NAME']
|
server = current_app.config['SERVER_NAME']
|
||||||
actor_data = { "@context": default_context(),
|
actor_data = { "@context": default_context(),
|
||||||
"type": "Person",
|
"type": "Person" if not user.bot else "Service",
|
||||||
"id": f"https://{server}/u/{actor}",
|
"id": f"https://{server}/u/{actor}",
|
||||||
"preferredUsername": actor,
|
"preferredUsername": actor,
|
||||||
"name": user.title if user.title else user.user_name,
|
"name": user.title if user.title else user.user_name,
|
||||||
|
|
|
@ -488,7 +488,7 @@ def refresh_community_profile_task(community_id):
|
||||||
|
|
||||||
|
|
||||||
def actor_json_to_model(activity_json, address, server):
|
def actor_json_to_model(activity_json, address, server):
|
||||||
if activity_json['type'] == 'Person':
|
if activity_json['type'] == 'Person' or activity_json['type'] == 'Service':
|
||||||
try:
|
try:
|
||||||
user = User(user_name=activity_json['preferredUsername'],
|
user = User(user_name=activity_json['preferredUsername'],
|
||||||
title=activity_json['name'] if 'name' in activity_json else None,
|
title=activity_json['name'] if 'name' in activity_json else None,
|
||||||
|
@ -508,6 +508,7 @@ def actor_json_to_model(activity_json, address, server):
|
||||||
ap_fetched_at=utcnow(),
|
ap_fetched_at=utcnow(),
|
||||||
ap_domain=server,
|
ap_domain=server,
|
||||||
public_key=activity_json['publicKey']['publicKeyPem'],
|
public_key=activity_json['publicKey']['publicKeyPem'],
|
||||||
|
bot=True if activity_json['type'] == 'Service' else False,
|
||||||
instance_id=find_instance_id(server)
|
instance_id=find_instance_id(server)
|
||||||
# language=community_json['language'][0]['identifier'] # todo: language
|
# language=community_json['language'][0]['identifier'] # todo: language
|
||||||
)
|
)
|
||||||
|
|
|
@ -282,6 +282,14 @@ h1 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fe-bot-account {
|
||||||
|
position: relative;
|
||||||
|
top: 1px;
|
||||||
|
&:before {
|
||||||
|
content: "\e94d";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.fe-video {
|
.fe-video {
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
|
|
|
@ -305,6 +305,14 @@ h1 .fe-bell, h1 .fe-no-bell {
|
||||||
content: "\e986";
|
content: "\e986";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fe-bot-account {
|
||||||
|
position: relative;
|
||||||
|
top: 1px;
|
||||||
|
}
|
||||||
|
.fe-bot-account:before {
|
||||||
|
content: "\e94d";
|
||||||
|
}
|
||||||
|
|
||||||
.fe-video {
|
.fe-video {
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
|
|
|
@ -304,6 +304,14 @@ h1 .fe-bell, h1 .fe-no-bell {
|
||||||
content: "\e986";
|
content: "\e986";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fe-bot-account {
|
||||||
|
position: relative;
|
||||||
|
top: 1px;
|
||||||
|
}
|
||||||
|
.fe-bot-account:before {
|
||||||
|
content: "\e94d";
|
||||||
|
}
|
||||||
|
|
||||||
.fe-video {
|
.fe-video {
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
{% if user.created_recently() %}
|
{% if user.created_recently() %}
|
||||||
<span class="fe fe-new-account" title="New account"> </span>
|
<span class="fe fe-new-account" title="New account"> </span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if user.bot %}
|
||||||
|
<span class="fe fe-bot-account" title="Bot account"> </span>
|
||||||
|
{% endif %}
|
||||||
{% if user.reputation < -10 %}
|
{% if user.reputation < -10 %}
|
||||||
<span class="fe fe-warning red" title="Very low reputation. Beware."> </span>
|
<span class="fe fe-warning red" title="Very low reputation. Beware."> </span>
|
||||||
<span class="fe fe-warning red" title="Very low reputation. Beware!"> </span>
|
<span class="fe fe-warning red" title="Very low reputation. Beware!"> </span>
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
{% if comment['comment'].author.created_recently() %}
|
{% if comment['comment'].author.created_recently() %}
|
||||||
<span class="fe fe-new-account small" title="New account"> </span>
|
<span class="fe fe-new-account small" title="New account"> </span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if comment['comment'].author.bot %}
|
||||||
|
<span class="fe fe-bot-account small" title="Bot account"> </span>
|
||||||
|
{% endif %}
|
||||||
{% if comment['comment'].author.id != current_user.id %}
|
{% if comment['comment'].author.id != current_user.id %}
|
||||||
{% if comment['comment'].author.reputation < -10 %}
|
{% if comment['comment'].author.reputation < -10 %}
|
||||||
<span class="fe fe-warning red" title="Very low reputation. Beware."> </span>
|
<span class="fe fe-warning red" title="Very low reputation. Beware."> </span>
|
||||||
|
|
|
@ -90,6 +90,9 @@
|
||||||
{% if comment['comment'].author.created_recently() %}
|
{% if comment['comment'].author.created_recently() %}
|
||||||
<span class="fe fe-new-account small" title="New account"> </span>
|
<span class="fe fe-new-account small" title="New account"> </span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if comment['comment'].author.bot %}
|
||||||
|
<span class="fe fe-bot-account small" title="Bot account"> </span>
|
||||||
|
{% endif %}
|
||||||
{% if comment['comment'].author.id != current_user.id %}
|
{% if comment['comment'].author.id != current_user.id %}
|
||||||
{% if comment['comment'].author.reputation < -10 %}
|
{% if comment['comment'].author.reputation < -10 %}
|
||||||
<span class="fe fe-warning red" title="Very low reputation. Beware."> </span>
|
<span class="fe fe-warning red" title="Very low reputation. Beware."> </span>
|
||||||
|
|
|
@ -57,6 +57,9 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p class="small">{{ _('Joined') }}: {{ moment(user.created).fromNow(refresh=True) }}<br />
|
<p class="small">{{ _('Joined') }}: {{ moment(user.created).fromNow(refresh=True) }}<br />
|
||||||
|
{% if user.bot %}
|
||||||
|
{{ _('Bot Account') }}<br />
|
||||||
|
{% endif %}
|
||||||
{{ _('Attitude') }}: <span title="{{ _('Ratio of upvotes cast to downvotes cast. Higher is more positive.') }}">{{ (user.attitude * 100) | round | int }}%</span></p>
|
{{ _('Attitude') }}: <span title="{{ _('Ratio of upvotes cast to downvotes cast. Higher is more positive.') }}">{{ (user.attitude * 100) | round | int }}%</span></p>
|
||||||
{{ user.about_html|safe }}
|
{{ user.about_html|safe }}
|
||||||
{% if posts %}
|
{% if posts %}
|
||||||
|
|
|
@ -149,7 +149,7 @@ def search_for_user(address: str):
|
||||||
if user_data.status_code == 200:
|
if user_data.status_code == 200:
|
||||||
user_json = user_data.json()
|
user_json = user_data.json()
|
||||||
user_data.close()
|
user_data.close()
|
||||||
if user_json['type'] == 'Person':
|
if user_json['type'] == 'Person' or user_json['type'] == 'Service':
|
||||||
user = actor_json_to_model(user_json, name, server)
|
user = actor_json_to_model(user_json, name, server)
|
||||||
return user
|
return user
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -448,7 +448,7 @@ def banned_ip_addresses() -> List[str]:
|
||||||
|
|
||||||
|
|
||||||
def can_downvote(user, community: Community, site=None) -> bool:
|
def can_downvote(user, community: Community, site=None) -> bool:
|
||||||
if user is None or community is None or user.banned:
|
if user is None or community is None or user.banned or user.bot:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if site is None:
|
if site is None:
|
||||||
|
@ -473,7 +473,7 @@ def can_downvote(user, community: Community, site=None) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def can_upvote(user, community: Community) -> bool:
|
def can_upvote(user, community: Community) -> bool:
|
||||||
if user is None or community is None or user.banned:
|
if user is None or community is None or user.banned or user.bot:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if community.id in communities_banned_from(user.id):
|
if community.id in communities_banned_from(user.id):
|
||||||
|
|
Loading…
Add table
Reference in a new issue