fcm-django
fcm-django copied to clipboard
Emit signal on active change
active
is being changed through update()
, which does not emit a signal that I need. Would it make sense to add signal to update?
Something similar to the following in https://github.com/xtrinch/fcm-django/blob/master/fcm_django/models.py#L38
class FCMDeviceQuerySet(models.query.QuerySet):
def update(self, **kwargs):
post_save.send(self.__class__, **kwargs) # some signal
return super(FCMDeviceQuerySet, self).update(**kwargs)
Well the question at hand is how much worse will the performance be, if you call save on individual models so that the post_save handler would be triggered.
What is the use case of using post_save? Is it anything that could be handled differently?
I think adding a signal for something scalable like notifications would be potentially harmful. Over at djangorestframework-simplejwt, I considered the same problem and came to the conclusion that we could add a setting saying whether we wanted to emit a signal. I don't think a signal will be necessary though. On the one hand, if a device is being deactivated, you can receive the ids from the QuerySet API response (from #160). From DRF, override some views. And from admins, override the ModelAdmin class