mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-10 17:31:03 +00:00
Allow other Actor types
This commit is contained in:
parent
ee669ff568
commit
6eaaa6eac4
4 changed files with 32 additions and 2 deletions
|
@ -82,7 +82,7 @@ class Searcher:
|
|||
type = document.get("type", "unknown").lower()
|
||||
|
||||
# Is it an identity?
|
||||
if type == "person":
|
||||
if type in Identity.ACTOR_TYPES:
|
||||
# Try and retrieve the profile by actor URI
|
||||
identity = Identity.by_actor_uri(document["id"], create=True)
|
||||
if identity and identity.state == IdentityStates.outdated:
|
||||
|
|
18
users/migrations/0006_identity_actor_type.py
Normal file
18
users/migrations/0006_identity_actor_type.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 4.1.4 on 2022-12-20 06:47
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("users", "0005_report"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="identity",
|
||||
name="actor_type",
|
||||
field=models.CharField(default="person", max_length=100),
|
||||
),
|
||||
]
|
|
@ -66,6 +66,8 @@ class Identity(StatorModel):
|
|||
limited = 1
|
||||
blocked = 2
|
||||
|
||||
ACTOR_TYPES = ["person", "service", "application", "group", "organization"]
|
||||
|
||||
# The Actor URI is essentially also a PK - we keep the default numeric
|
||||
# one around as well for making nice URLs etc.
|
||||
actor_uri = models.CharField(max_length=500, unique=True)
|
||||
|
@ -102,6 +104,7 @@ class Identity(StatorModel):
|
|||
image_uri = models.CharField(max_length=500, blank=True, null=True)
|
||||
followers_uri = models.CharField(max_length=500, blank=True, null=True)
|
||||
following_uri = models.CharField(max_length=500, blank=True, null=True)
|
||||
actor_type = models.CharField(max_length=100, default="person")
|
||||
|
||||
icon = models.ImageField(
|
||||
upload_to=partial(upload_namer, "profile_images"), blank=True, null=True
|
||||
|
@ -317,7 +320,7 @@ class Identity(StatorModel):
|
|||
def to_ap(self):
|
||||
response = {
|
||||
"id": self.actor_uri,
|
||||
"type": "Person",
|
||||
"type": self.actor_type.title(),
|
||||
"inbox": self.actor_uri + "inbox/",
|
||||
"outbox": self.actor_uri + "outbox/",
|
||||
"preferredUsername": self.username,
|
||||
|
@ -475,6 +478,7 @@ class Identity(StatorModel):
|
|||
self.outbox_uri = document.get("outbox")
|
||||
self.followers_uri = document.get("followers")
|
||||
self.following_uri = document.get("following")
|
||||
self.actor_type = document["type"].lower()
|
||||
self.shared_inbox_uri = document.get("endpoints", {}).get("sharedInbox")
|
||||
self.summary = document.get("summary")
|
||||
self.username = document.get("preferredUsername")
|
||||
|
|
|
@ -44,6 +44,14 @@ class InboxMessageStates(StateGraph):
|
|||
await sync_to_async(Post.handle_update_ap)(instance.message)
|
||||
case "person":
|
||||
await sync_to_async(Identity.handle_update_ap)(instance.message)
|
||||
case "service":
|
||||
await sync_to_async(Identity.handle_update_ap)(instance.message)
|
||||
case "group":
|
||||
await sync_to_async(Identity.handle_update_ap)(instance.message)
|
||||
case "organization":
|
||||
await sync_to_async(Identity.handle_update_ap)(instance.message)
|
||||
case "application":
|
||||
await sync_to_async(Identity.handle_update_ap)(instance.message)
|
||||
case "question":
|
||||
pass # Drop for now
|
||||
case unknown:
|
||||
|
|
Loading…
Reference in a new issue