django-restit 4.2.102__py3-none-any.whl → 4.2.104__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- account/migrations/0022_alter_memberdevice_modified.py +18 -0
- account/models/device.py +5 -3
- account/models/member.py +28 -4
- {django_restit-4.2.102.dist-info → django_restit-4.2.104.dist-info}/METADATA +1 -1
- {django_restit-4.2.102.dist-info → django_restit-4.2.104.dist-info}/RECORD +8 -7
- taskqueue/models.py +1 -1
- {django_restit-4.2.102.dist-info → django_restit-4.2.104.dist-info}/LICENSE.md +0 -0
- {django_restit-4.2.102.dist-info → django_restit-4.2.104.dist-info}/WHEEL +0 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
# Generated by Django 4.2.11 on 2024-06-18 17:05
|
2
|
+
|
3
|
+
from django.db import migrations, models
|
4
|
+
|
5
|
+
|
6
|
+
class Migration(migrations.Migration):
|
7
|
+
|
8
|
+
dependencies = [
|
9
|
+
('account', '0021_alter_cloudcredentials_group'),
|
10
|
+
]
|
11
|
+
|
12
|
+
operations = [
|
13
|
+
migrations.AlterField(
|
14
|
+
model_name='memberdevice',
|
15
|
+
name='modified',
|
16
|
+
field=models.DateTimeField(auto_now=True, db_index=True),
|
17
|
+
),
|
18
|
+
]
|
account/models/device.py
CHANGED
@@ -16,7 +16,7 @@ class MemberDevice(models.Model, rm.RestModel, rm.MetaDataModel):
|
|
16
16
|
This can include mobile and desktop devices.
|
17
17
|
"""
|
18
18
|
created = models.DateTimeField(auto_now_add=True)
|
19
|
-
modified = models.DateTimeField(auto_now=True)
|
19
|
+
modified = models.DateTimeField(auto_now=True, db_index=True)
|
20
20
|
|
21
21
|
member = models.ForeignKey("account.Member", related_name="devices", on_delete=models.CASCADE)
|
22
22
|
|
@@ -41,13 +41,15 @@ class MemberDevice(models.Model, rm.RestModel, rm.MetaDataModel):
|
|
41
41
|
def sendData(self, message, **kwargs):
|
42
42
|
messenger = getCloudMessenger(self.cm_provider)
|
43
43
|
if messenger:
|
44
|
-
|
44
|
+
resp = messenger.sendToDevice(self, message)
|
45
|
+
return resp
|
45
46
|
return objict(status_code=404, reason=self.cm_provider)
|
46
47
|
|
47
48
|
def sendNotification(self, title, body):
|
48
49
|
messenger = getCloudMessenger(self.cm_provider)
|
49
50
|
if messenger:
|
50
|
-
|
51
|
+
resp = messenger.sendNotification(self.cm_token, title, body)
|
52
|
+
return resp
|
51
53
|
return objict(status_code=404, reason=self.cm_provider)
|
52
54
|
|
53
55
|
def notify(self, title, body):
|
account/models/member.py
CHANGED
@@ -627,10 +627,24 @@ class Member(User, RestModel, MetaDataModel):
|
|
627
627
|
# for slog in qset:
|
628
628
|
# slog.logout()
|
629
629
|
|
630
|
-
def notifyMobile(self, data=None, title=None, body=None):
|
631
|
-
|
632
|
-
|
633
|
-
|
630
|
+
def notifyMobile(self, data=None, title=None, body=None, delay=None):
|
631
|
+
if delay:
|
632
|
+
Task = RestModel.getModel("taskqueue", "Task")
|
633
|
+
if delay < 60:
|
634
|
+
Task.Publish(
|
635
|
+
"account.Member", "on_task_cm",
|
636
|
+
data=dict(pk=self.pk, delay=delay, data=data, title=title, body=body),
|
637
|
+
stale_after_seconds=300,
|
638
|
+
channel="tq_app_handler")
|
639
|
+
else:
|
640
|
+
Task.Publish(
|
641
|
+
"account.Member", "on_task_cm",
|
642
|
+
data=dict(pk=self.pk, data=data, title=title, body=body),
|
643
|
+
scheduled_for=datetime.now() + timedelta(seconds=delay),
|
644
|
+
channel="tq_app_handler")
|
645
|
+
return
|
646
|
+
stale = datetime.now() - timedelta(days=60)
|
647
|
+
for device in self.devices.filter(state=1, modified__gt=stale).exclude(cm_provider="ws", cm_token__isnull=True):
|
634
648
|
if data is not None:
|
635
649
|
device.sendData(data)
|
636
650
|
else:
|
@@ -1227,6 +1241,16 @@ class Member(User, RestModel, MetaDataModel):
|
|
1227
1241
|
return None
|
1228
1242
|
return cls.objects.filter(pk=uid).last()
|
1229
1243
|
|
1244
|
+
@classmethod
|
1245
|
+
def on_task_cm(cls, task):
|
1246
|
+
member = cls.objects.filter(pk=task.data.pk).last()
|
1247
|
+
if not member:
|
1248
|
+
task.failed("could not find member")
|
1249
|
+
return False
|
1250
|
+
if task.data.delay:
|
1251
|
+
time.sleep(task.data.delay) # delay
|
1252
|
+
member.notifyMobile(data=task.data.data, title=task.data.title, body=task.data.body)
|
1253
|
+
|
1230
1254
|
|
1231
1255
|
class MemberMetaData(MetaDataBase):
|
1232
1256
|
parent = models.ForeignKey(Member, related_name="properties", on_delete=models.CASCADE)
|
@@ -23,13 +23,14 @@ account/migrations/0018_userpasskey.py,sha256=SdXYo4TkIeP5wLNfCza3Jq5-gKuUufzTHG
|
|
23
23
|
account/migrations/0019_group_location.py,sha256=EfMB_w4qWUGDqQeNc453PFZwpjpTeoA6xr6Qgo_YAOM,601
|
24
24
|
account/migrations/0020_cloudcredentials_cloudcredentialsmetadata.py,sha256=mHwxkyDfA4ueQOt34w5ndJB4XwNTDLv79CkKgzhlz-c,2250
|
25
25
|
account/migrations/0021_alter_cloudcredentials_group.py,sha256=zoFYmE-hd3uRGX6DRO9k-osPwH0jFeTU7S-pjCOtakk,561
|
26
|
+
account/migrations/0022_alter_memberdevice_modified.py,sha256=9eeKcdr9p6qFJ8ZxSnKSj1KxZjW8NZfM0YCMck6i0QQ,424
|
26
27
|
account/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
28
|
account/models/__init__.py,sha256=cV_lMnT2vL_mjiYtT4hlcIHo52ocFbGSNVkOIHHLXZY,385
|
28
|
-
account/models/device.py,sha256=
|
29
|
+
account/models/device.py,sha256=0AFeLMGk4im4KZVd3eGSyRbK4eQEXiFM2cdY8GUzihs,5934
|
29
30
|
account/models/feeds.py,sha256=vI7fG4ASY1M0Zjke24RdnfDcuWeATl_yR_25jPmT64g,2011
|
30
31
|
account/models/group.py,sha256=mjWwePt3ogQUo9m0EhURMz0aBrVVx_0Drr0lNDESQio,22281
|
31
32
|
account/models/legacy.py,sha256=zYdtv4LC0ooxPVqWM-uToPwV-lYWQLorSE6p6yn1xDw,2720
|
32
|
-
account/models/member.py,sha256=
|
33
|
+
account/models/member.py,sha256=JziyYNC13SFWX07Thtoe2V_YlrKNn2RHJZcRk15Zh-s,54205
|
33
34
|
account/models/membership.py,sha256=90EpAhOsGaqphDAkONP6j_qQ0OWSRaQsI8H7E7fgMkE,9249
|
34
35
|
account/models/notify.py,sha256=TOkuVBLAsbzT58FOxII_G3Cj_IDQx16vyehyEsNrDcY,15306
|
35
36
|
account/models/passkeys.py,sha256=TJxITUi4DT4_1tW2K7ZlOcRjJuMVl2NtKz7pKQU8-Tw,1516
|
@@ -454,7 +455,7 @@ taskqueue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
454
455
|
taskqueue/admin.py,sha256=E6zXoToS_ea3MdoGjZzF1JiepWFtDSoZUQdan8H-pXI,208
|
455
456
|
taskqueue/migrations/0001_initial.py,sha256=JwYib8CK5ftSXlfxKZUcKEEVsXktNB5q3h-2tu9inGk,4738
|
456
457
|
taskqueue/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
457
|
-
taskqueue/models.py,sha256=
|
458
|
+
taskqueue/models.py,sha256=i8v0vQqlz4X3rVFVJsUSldA-26NEPWnsMZF2Kly_1Qo,22398
|
458
459
|
taskqueue/periodic.py,sha256=2i0271khrCow3hDmlNEcoAZnesBVl40jd7MIim2Cxs4,3543
|
459
460
|
taskqueue/rpc.py,sha256=Lf5VUoqCRkfWUAIvx_s508mjAtDPwpiWyxg0ryqWbQA,5793
|
460
461
|
taskqueue/tq.py,sha256=PzSoDrawYcqZylruEgsK95gcJ4J_VhdM6rxg9V6_X8E,942
|
@@ -507,7 +508,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
|
|
507
508
|
ws4redis/settings.py,sha256=K0yBiLUuY81iDM4Yr-k8hbvjn5VVHu5zQhmMK8Dtz0s,1536
|
508
509
|
ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
|
509
510
|
ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
|
510
|
-
django_restit-4.2.
|
511
|
-
django_restit-4.2.
|
512
|
-
django_restit-4.2.
|
513
|
-
django_restit-4.2.
|
511
|
+
django_restit-4.2.104.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
|
512
|
+
django_restit-4.2.104.dist-info/METADATA,sha256=HsONd8WhUPc5fhviH3GzFFyW0mu-LUo17xAdeFDtrRQ,7663
|
513
|
+
django_restit-4.2.104.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
514
|
+
django_restit-4.2.104.dist-info/RECORD,,
|
taskqueue/models.py
CHANGED
@@ -392,7 +392,7 @@ class Task(models.Model, RestModel):
|
|
392
392
|
return task
|
393
393
|
|
394
394
|
@classmethod
|
395
|
-
def PublishModelTask(cls, model_name, fname, data, stale_after_seconds=0, channel="tq_model_handler", scheduled_for=
|
395
|
+
def PublishModelTask(cls, model_name, fname, data, stale_after_seconds=0, channel="tq_model_handler", scheduled_for=None):
|
396
396
|
return cls.Publish(cls, model_name, fname, data, stale_after_seconds, channel, scheduled_for)
|
397
397
|
|
398
398
|
@classmethod
|
File without changes
|
File without changes
|