From 2c3a1299709f2612e96c37e4e121c83ad4df7a56 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 9 Nov 2022 23:48:31 -0700 Subject: Profile fetching now working on state machine --- users/migrations/0001_initial.py | 68 +++++++++++++++++++++- ...follow_state_follow_state_attempted_and_more.py | 44 -------------- ...ow_accepted_remove_follow_requested_and_more.py | 31 ---------- .../0004_remove_follow_state_locked_and_more.py | 21 ------- ...follow_state_locked_until_follow_state_ready.py | 23 -------- 5 files changed, 65 insertions(+), 122 deletions(-) delete mode 100644 users/migrations/0002_follow_state_follow_state_attempted_and_more.py delete mode 100644 users/migrations/0003_remove_follow_accepted_remove_follow_requested_and_more.py delete mode 100644 users/migrations/0004_remove_follow_state_locked_and_more.py delete mode 100644 users/migrations/0005_follow_state_locked_until_follow_state_ready.py (limited to 'users/migrations') diff --git a/users/migrations/0001_initial.py b/users/migrations/0001_initial.py index f5ebf55..2f64337 100644 --- a/users/migrations/0001_initial.py +++ b/users/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.1.3 on 2022-11-07 04:19 +# Generated by Django 4.1.3 on 2022-11-10 05:58 import functools @@ -6,7 +6,10 @@ import django.db.models.deletion from django.conf import settings from django.db import migrations, models +import stator.models +import users.models.follow import users.models.identity +import users.models.inbox_message class Migration(migrations.Migration): @@ -77,6 +80,37 @@ class Migration(migrations.Migration): ), ], ), + migrations.CreateModel( + name="InboxMessage", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("state_ready", models.BooleanField(default=False)), + ("state_changed", models.DateTimeField(auto_now_add=True)), + ("state_attempted", models.DateTimeField(blank=True, null=True)), + ("state_locked_until", models.DateTimeField(blank=True, null=True)), + ("message", models.JSONField()), + ( + "state", + stator.models.StateField( + choices=[("received", "received"), ("processed", "processed")], + default="received", + graph=users.models.inbox_message.InboxMessageStates, + max_length=100, + ), + ), + ], + options={ + "abstract": False, + }, + ), migrations.CreateModel( name="UserEvent", fields=[ @@ -124,7 +158,20 @@ class Migration(migrations.Migration): verbose_name="ID", ), ), + ("state_ready", models.BooleanField(default=False)), + ("state_changed", models.DateTimeField(auto_now_add=True)), + ("state_attempted", models.DateTimeField(blank=True, null=True)), + ("state_locked_until", models.DateTimeField(blank=True, null=True)), ("actor_uri", models.CharField(max_length=500, unique=True)), + ( + "state", + stator.models.StateField( + choices=[("outdated", "outdated"), ("updated", "updated")], + default="outdated", + graph=users.models.identity.IdentityStates, + max_length=100, + ), + ), ("local", models.BooleanField()), ("username", models.CharField(blank=True, max_length=500, null=True)), ("name", models.CharField(blank=True, max_length=500, null=True)), @@ -239,10 +286,25 @@ class Migration(migrations.Migration): verbose_name="ID", ), ), + ("state_ready", models.BooleanField(default=False)), + ("state_changed", models.DateTimeField(auto_now_add=True)), + ("state_attempted", models.DateTimeField(blank=True, null=True)), + ("state_locked_until", models.DateTimeField(blank=True, null=True)), ("uri", models.CharField(blank=True, max_length=500, null=True)), ("note", models.TextField(blank=True, null=True)), - ("requested", models.BooleanField(default=False)), - ("accepted", models.BooleanField(default=False)), + ( + "state", + stator.models.StateField( + choices=[ + ("pending", "pending"), + ("requested", "requested"), + ("accepted", "accepted"), + ], + default="pending", + graph=users.models.follow.FollowStates, + max_length=100, + ), + ), ("created", models.DateTimeField(auto_now_add=True)), ("updated", models.DateTimeField(auto_now=True)), ( diff --git a/users/migrations/0002_follow_state_follow_state_attempted_and_more.py b/users/migrations/0002_follow_state_follow_state_attempted_and_more.py deleted file mode 100644 index b33236a..0000000 --- a/users/migrations/0002_follow_state_follow_state_attempted_and_more.py +++ /dev/null @@ -1,44 +0,0 @@ -# Generated by Django 4.1.3 on 2022-11-07 19:22 - -import django.utils.timezone -from django.db import migrations, models - -import stator.models -import users.models.follow - - -class Migration(migrations.Migration): - - dependencies = [ - ("users", "0001_initial"), - ] - - operations = [ - migrations.AddField( - model_name="follow", - name="state", - field=stator.models.StateField( - choices=[ - ("pending", "pending"), - ("requested", "requested"), - ("accepted", "accepted"), - ], - default="pending", - graph=users.models.follow.FollowStates, - max_length=100, - ), - ), - migrations.AddField( - model_name="follow", - name="state_attempted", - field=models.DateTimeField(blank=True, null=True), - ), - migrations.AddField( - model_name="follow", - name="state_changed", - field=models.DateTimeField( - auto_now_add=True, default=django.utils.timezone.now - ), - preserve_default=False, - ), - ] diff --git a/users/migrations/0003_remove_follow_accepted_remove_follow_requested_and_more.py b/users/migrations/0003_remove_follow_accepted_remove_follow_requested_and_more.py deleted file mode 100644 index 180bfdd..0000000 --- a/users/migrations/0003_remove_follow_accepted_remove_follow_requested_and_more.py +++ /dev/null @@ -1,31 +0,0 @@ -# Generated by Django 4.1.3 on 2022-11-08 03:58 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("users", "0002_follow_state_follow_state_attempted_and_more"), - ] - - operations = [ - migrations.RemoveField( - model_name="follow", - name="accepted", - ), - migrations.RemoveField( - model_name="follow", - name="requested", - ), - migrations.AddField( - model_name="follow", - name="state_locked", - field=models.DateTimeField(blank=True, null=True), - ), - migrations.AddField( - model_name="follow", - name="state_runner", - field=models.CharField(blank=True, max_length=100, null=True), - ), - ] diff --git a/users/migrations/0004_remove_follow_state_locked_and_more.py b/users/migrations/0004_remove_follow_state_locked_and_more.py deleted file mode 100644 index bf98080..0000000 --- a/users/migrations/0004_remove_follow_state_locked_and_more.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Django 4.1.3 on 2022-11-09 05:15 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ("users", "0003_remove_follow_accepted_remove_follow_requested_and_more"), - ] - - operations = [ - migrations.RemoveField( - model_name="follow", - name="state_locked", - ), - migrations.RemoveField( - model_name="follow", - name="state_runner", - ), - ] diff --git a/users/migrations/0005_follow_state_locked_until_follow_state_ready.py b/users/migrations/0005_follow_state_locked_until_follow_state_ready.py deleted file mode 100644 index 3aba08e..0000000 --- a/users/migrations/0005_follow_state_locked_until_follow_state_ready.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.1.3 on 2022-11-10 03:24 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("users", "0004_remove_follow_state_locked_and_more"), - ] - - operations = [ - migrations.AddField( - model_name="follow", - name="state_locked_until", - field=models.DateTimeField(blank=True, null=True), - ), - migrations.AddField( - model_name="follow", - name="state_ready", - field=models.BooleanField(default=False), - ), - ] -- cgit v1.2.3