diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 1084de75..799fb21e 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -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, diff --git a/app/activitypub/util.py b/app/activitypub/util.py index a094b19f..a59c5f19 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -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 ) diff --git a/app/user/utils.py b/app/user/utils.py index 87648d51..f92c5979 100644 --- a/app/user/utils.py +++ b/app/user/utils.py @@ -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