diff --git a/api/admin.py b/api/admin.py index b771c041..33d78554 100644 --- a/api/admin.py +++ b/api/admin.py @@ -263,7 +263,6 @@ class OrderAdmin(AdminChangeLinksMixin, admin.ModelAdmin): order.status in [Order.Status.DIS, Order.Status.WFR] and order.is_disputed ): - order.maker.robot.earned_rewards = order.maker_bond.num_satoshis order.maker.robot.save(update_fields=["earned_rewards"]) order.taker.robot.earned_rewards = order.taker_bond.num_satoshis @@ -421,7 +420,7 @@ class UserRobotAdmin(AdminChangeLinksMixin, admin.ModelAdmin): change_links = ["user"] readonly_fields = ["avatar_tag"] search_fields = ["user__username", "id"] - readonly_fields = ("public_key", "encrypted_private_key") + readonly_fields = ("hash_id", "public_key", "encrypted_private_key") @admin.register(Currency) diff --git a/api/migrations/0040_robot_hash_id.py b/api/migrations/0040_robot_hash_id.py new file mode 100644 index 00000000..3a93c378 --- /dev/null +++ b/api/migrations/0040_robot_hash_id.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.2 on 2023-07-18 17:15 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("api", "0039_alter_currency_currency"), + ] + + operations = [ + migrations.AddField( + model_name="robot", + name="hash_id", + field=models.CharField( + blank=True, default=None, max_length=64, null=True, unique=True + ), + ), + ] diff --git a/api/models/robot.py b/api/models/robot.py index 7e558664..d0a1f987 100644 --- a/api/models/robot.py +++ b/api/models/robot.py @@ -12,6 +12,15 @@ from django.utils.html import mark_safe class Robot(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) + # Hash id (second sha256 of robot token) + hash_id = models.CharField( + max_length=64, + unique=True, + default=None, + blank=True, + null=True, + ) + # PGP keys, used for E2E chat encryption. Priv key is encrypted with user's passphrase (highEntropyToken) public_key = models.TextField( # Actually only 400-500 characters for ECC, but other types might be longer