mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Recognise 'service' type as bots
This commit is contained in:
parent
82a092eec8
commit
0966ce4346
3 changed files with 4 additions and 3 deletions
|
@ -195,7 +195,7 @@ def user_profile(actor):
|
|||
if is_activitypub_request():
|
||||
server = current_app.config['SERVER_NAME']
|
||||
actor_data = { "@context": default_context(),
|
||||
"type": "Person",
|
||||
"type": "Person" if not user.bot else "Service",
|
||||
"id": f"https://{server}/u/{actor}",
|
||||
"preferredUsername": actor,
|
||||
"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):
|
||||
if activity_json['type'] == 'Person':
|
||||
if activity_json['type'] == 'Person' or activity_json['type'] == 'Service':
|
||||
try:
|
||||
user = User(user_name=activity_json['preferredUsername'],
|
||||
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_domain=server,
|
||||
public_key=activity_json['publicKey']['publicKeyPem'],
|
||||
bot=True if activity_json['type'] == 'Service' else False,
|
||||
instance_id=find_instance_id(server)
|
||||
# language=community_json['language'][0]['identifier'] # todo: language
|
||||
)
|
||||
|
|
|
@ -149,7 +149,7 @@ def search_for_user(address: str):
|
|||
if user_data.status_code == 200:
|
||||
user_json = user_data.json()
|
||||
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)
|
||||
return user
|
||||
return None
|
||||
|
|
Loading…
Add table
Reference in a new issue