mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 01:21:07 +00:00
Add index for looking up KeyPair by remote id
This commit is contained in:
parent
5cfe7eca6f
commit
4d5a30d953
2 changed files with 26 additions and 0 deletions
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.2.25 on 2024-04-03 19:10
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bookwyrm", "0200_status_bookwyrm_st_thread__cf064f_idx"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name="keypair",
|
||||
index=models.Index(
|
||||
fields=["remote_id"], name="bookwyrm_ke_remote__472927_idx"
|
||||
),
|
||||
),
|
||||
]
|
|
@ -509,6 +509,13 @@ class KeyPair(ActivitypubMixin, BookWyrmModel):
|
|||
activity_serializer = activitypub.PublicKey
|
||||
serialize_reverse_fields = [("owner", "owner", "id")]
|
||||
|
||||
class Meta:
|
||||
"""indexes"""
|
||||
|
||||
indexes = [
|
||||
models.Index(fields=["remote_id"]),
|
||||
]
|
||||
|
||||
def get_remote_id(self):
|
||||
# self.owner is set by the OneToOneField on User
|
||||
return f"{self.owner.remote_id}/#main-key"
|
||||
|
|
Loading…
Reference in a new issue